essential_rest 1.0.21

  • Readme
  • Changelog
  • Example
  • Installing
  • 79

essential_rest is an API to consume REST web services, it does the JSON mapping for the Entity, besides allowing to keep the data in CACHE using Local Storage for fast loading and load reduction to the Server

Usage #

A simple usage example:

import 'package:essential_rest/essential_rest.dart';
import 'package:essential_rest/src/response_list.dart';

//entity model definition
class ExampleModel {
  int id;
  int userId;
  String title;
  bool completed;

  ExampleModel({this.userId, this.id, this.title, this.completed});

  ExampleModel.fromMap(Map<String, dynamic> json) {
    userId = json['userId'];
    id = json['id'];
    title = json['title'];
    completed = json['completed'];
  }

  @override
  Map<String, dynamic> toMap() {
    final data = Map<String, dynamic>();
    data['userId'] = userId;
    data['id'] = id;
    data['title'] = title;
    data['completed'] = completed;
    return data;
  }
}

void main() async {
  var rest = RestClientGeneric<ExampleModel>(factory: {ExampleModel: (x) => ExampleModel.fromMap(x)});
  rest.protocol = ProtocolType.https;
  rest.host = 'jsonplaceholder.typicode.com';

  //get list of ExampleModel
  var resp = await rest.getAll('/todos');
  RList<ExampleModel> list = resp.resultListT;
  list.forEach((item) {
    print('list item: ${item.title}');
  });

  //get single ExampleModel
  resp = await rest.get('/todos/1');
  var item = resp.resultT;
  print('single item: ${item.title}');

  //create new item
  resp = await rest.post('/todos', body: ExampleModel(title: 'test').toMap());
  print('create item: ${resp.status}');
}

1.0.0 #

  • Versão Inicial

1.0.8 #

  • fix bug on basePath of RestClientGeneric

1.0.20 #

  • fix bugs, add stacktrace on catch exception and bodyEncoding for uploadFiles

example/README.md

Examples #

flutter_rest is Flutter Example #

dart-vm is Dart Virtual Machine Backend Example #

angular is AngularDart Web FrontAnd Example #

Use this package as a library

1. Depend on it

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


dependencies:
  essential_rest: ^1.0.21

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ 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:


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

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

  • Dart: 2.8.4
  • pana: 0.13.13

Health suggestions

Format lib/essential_rest.dart.

Run dartfmt to format lib/essential_rest.dart.

Format lib/src/html_fake.dart.

Run dartfmt to format lib/src/html_fake.dart.

Format lib/src/rest_client.dart.

Run dartfmt to format lib/src/rest_client.dart.

Format lib/src/rest_client_generic.dart.

Run dartfmt to format lib/src/rest_client_generic.dart.

Format lib/src/util.dart.

Run dartfmt to format lib/src/util.dart.

Maintenance suggestions

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.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
http >=0.12.0 <1.0.0 0.12.1
http_parser >=3.1.2 <4.0.0 3.1.4
universal_html >=1.2.2 <1.10.0 1.2.3
Transitive dependencies
async 2.4.1
charcode 1.1.3
collection 1.14.13
csslib 0.16.1
html 0.14.0+3
meta 1.1.8
path 1.7.0
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.2.0
universal_io 1.0.1
zone_local 0.1.2
Dev dependencies
pedantic ^1.8.0 1.9.0 1.9.1
test ^1.6.0