The previous publication was talking about the low-level HTTP Client interface HttpClient offered by dart:io . This package does the job, but even the documentation recommends to use package:http instead. This is a higher-level implementation dealing with all the portability for different platforms and adding a lot of cool features. Instead of recreating a new project from scratch, we will improve the previous one created: httpcat .
First, we need to know how to install a package with Dart. Using an external package requires adding a new dependency in pubspec.yaml file present at the root of the project.
name : httpcat description : A sample command-line application. version : 1.0.0 # repository: https://github.com/my_org/my_repo
environment : sdk : ^3.11.5
# Add regular dependencies here. dependencies : path : ^1.9.0 http : ^1.6.0
dev_dependencies : lints : ^6.0.0 test : ^1.25.
Enter fullscreen mode
Exit fullscreen mode
The new line added is http: ^1.6.0 in the dependencies section.…