A Dart and Flutter compatible library to simplify creating REST based API calls.
For Flutter based applications, this will offload the JSON decoding to a separate Isolate to avoid janking the UI thread on large JSON responses. For Dart Web / AngularDart based applications, this processes the JSON on the main thread because Isolates are not supported.
Using the library #
Add the repo to your Flutter
dependencies: rest_client: <<version>>
flutter packages get
The API Client offers the following two built in authorizers.
BasicAuthorizer-- To authenticate against an API using the BASIC username / password security models.
TokenAuthorizer-- To authorize against an API using
Bearertoken based authorization.
import 'package:rest_client/rest_client.dart' as rc; ... var client = rc.Client(); var request = rc.Request( url: 'https://google.com', ); var response = client.execute( authorizor: rc.TokenAuthorizer(token: 'my_token_goes_here'), request: request, ); var body = response.body; // do further processing here...
[1.0.3] - June 11th, 2020 #
- Deprecated internal Jsonable class in favor of the JsonClass package's version
[1.0.2] - May 6th, 2020 #
- Minor fix to
[1.0.1] - April 16th, 2020 #
- Updated project metadata
[1.0.0] - April 12th, 2020 #
- Initial release
Use this package as a library
1. Depend on it
Add this to your package's pubspec.yaml file:
dependencies: rest_client: ^1.0.3
2. Install it
You can install packages from the command line:
$ pub get
$ flutter pub get
Alternatively, your editor might support
pub get or
flutter pub get.
Check the docs for your editor to learn more.
3. Import it
Now in your Dart code, you can use:
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
We analyzed this package on Jul 3, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
- Dart: 2.8.4
- pana: 0.13.13
Maintain an example. (-10 points)
Create a short demo in the
example/ directory to show how to use this package.
Common filename patterns include
rest_client.dart. Packages with multiple examples should provide
For more information see the pub package layout conventions.
The description is too long. (-10 points)
Search engines display only the first part of the description. Try to keep the value of the
description field in your package's
pubspec.yaml file between 60 and 180 characters.
|Dart SDK||>=2.5.0 <3.0.0|