requests 2.0.1

flutter http json with cookies #

a flutter library to do modern http requests with cookies(inspired by python's requests module).

server side cookies (via response header SET-COOKIE) are stored using the assistance of shared_preferences. Stored cookies will be send seemlessly on the next http requests you make to the same domain (simple implementation, similar to a web browser)

Install #

Add this to your package's pubspec.yaml file:

dependencies:
  requests: ^2.0.1

Usage #

in your Dart code, you can use:

import 'package:requests/requests.dart';

HTTP get, body as plain text

String body = await Requests.get("https://mydomain.com");

HTTP get, body as parsed json

dynamic body = await Requests.get("https://mydomain.com/api/v1/foo", json: true);

HTTP post, body is map or a list (being sent as application/x-www-form-urlencoded, until stated otherwise in bodyEncoding parameter), result is json

dynamic body = await Requests.post("https://mydomain.com/api/v1/foo", json: true, body: {"foo":"bar"} );

HTTP delete

await Requests.delete("https://mydomain.com/api/v1/foo/123");

1.0.0 #

  • Initial version

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  requests: ^2.0.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:requests/requests.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
86
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
82
Overall:
Weighted score of the above. [more]
89
Learn more about scoring.

We analyzed this package on Jul 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Document public APIs. (-1 points)

26 out of 26 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/requests.dart.

Run flutter format to format lib/requests.dart.

Format lib/src/event.dart.

Run flutter format to format lib/src/event.dart.

Format lib/src/requests.dart.

Run flutter format to format lib/src/requests.dart.

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and requests.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

The package description is too short. (-8 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
crypto ^2.0.6 2.0.6
flutter 0.0.0
hex ^0.1.2 0.1.2
http ^0.12.0 0.12.0+2
logging ^0.11.3+2 0.11.3+2
shared_preferences ^0.5.2 0.5.3+4
Transitive dependencies
async 2.3.0
charcode 1.1.2
collection 1.14.11
convert 2.1.1
http_parser 3.1.3
meta 1.1.6 1.1.7
path 1.6.2
sky_engine 0.0.99
source_span 1.5.5
string_scanner 1.0.4
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test
pedantic ^1.0.0 1.8.0+1
test ^1.0.0

Admin