chlorine 0.1.0

  • Readme
  • Changelog
  • Installing
  • 37

Chlorine #

A lightweight json api network abstraction for flutter.

Chlorine uses async functions and give a easy way to access by binding responses and errors to two different closures.

Usage #

Import this package adding it in your pubspec.yaml.

    sdk: flutter
  chlorine: ">=0.1.0"

Create a Target:

import 'package:chlorine/chlorine_target.dart';

class UserTarget {

  String baseUrl = '';

  getUsers() {
    return ChlorineTarget()
        ..baseUrl = this.baseUrl
        ..path = 'users'
        ..method = ChlorineMethod.GET
        ..headers = Map.from({'Content-Type' : 'application/json'})

        //optional closures which will compute te results just before returning the response
        ..successClosure = (users) {
          return users;
        ..errorClosure = (error) {
          return error;

  getUser(int id) {
    return ChlorineTarget()
      ..baseUrl = this.baseUrl
      ..path = 'users/$id'
      ..method = ChlorineMethod.GET
      ..headers = Map.from({'Content-Type' : 'application/json'})

As you can see a builder methods like getUser() and getUsers() should return a ChlorineTarget. Dart's cascade notation make it very easy to build different instances of the same object.

Create a Chlorine instance and pass to it a builder method from your target class and relative success and error closure:

void main() {
    Chlorine chlorine = Chlorine();
        (response) {
        (error) {
            (response) {
            (error) {

Testing #

void main() {
  test('getUsers()', () {
    Chlorine chlorine = Chlorine();
    chlorine.jsonRequest(UserTarget().getUsers(), (response) {
      expect(response.statusCode, 200);
    }, (error) {
      return null;

Contributing #

  • Fork it!
  • Create your feature branch: git checkout -b my-new-feature
  • Commit your changes: git commit -am 'Add some feature'
  • Push to the branch: git push origin my-new-feature
  • Submit a pull request.

[0.1.0] - 9/12/2018 #

  • Initial Open Source release.

Use this package as a library

1. Depend on it

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

  chlorine: ^0.1.0

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:chlorine/chlorine.dart';
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]
Learn more about scoring.

We analyzed this package on Apr 8, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health issues and suggestions

Document public APIs. (-1 points)

67 out of 67 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/chlorine.dart.

Run flutter format to format lib/chlorine.dart.

Format lib/chlorine_target.dart.

Run flutter format to format lib/chlorine_target.dart.

Maintenance suggestions

Package is getting outdated. (-32.88 points)

The package was last published 69 weeks ago.

The package description is too short. (-20 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.

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 chlorine.dart. Packages with multiple examples should provide example/

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
flutter 0.0.0
http >=0.12.0 <0.13.0 0.12.0+4
Transitive dependencies
async 2.4.1
charcode 1.1.3
collection 1.14.11 1.14.12
http_parser 3.1.4
meta 1.1.8
path 1.6.4
pedantic 1.9.0
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies