rest_simplified 0.0.5 copy "rest_simplified: ^0.0.5" to clipboard
rest_simplified: ^0.0.5 copied to clipboard

outdated

A Simplified Rest approach for Flutter. The concept of this package is to easily map json to bean and vice-versa.

example/example.md

Simple Rest get example #

import 'package:rest_simplified/beans.dart';
import 'package:rest_simplified/parsers_factory.dart';
import 'package:rest_simplified/rest_accessor.dart';
import 'package:rest_simplified/rest_simplified.dart';
void getExampleCall() async {

 RestSimplified rs = RestSimplified.build('https://catfact.ninja');
 rs.addFromJsonMapParser<CatFact>(CatFactJsonMapper());
 rs.addURL<CatFact>(Protocol.get, '/fact');

 ServiceResult result = await rs.getRestAccessor().get<CatFact>();

 CatFact catFact = result.entity;
 print(catFact.fact);
 print(catFact.length);
}

class CatFact {
  String? fact;
  int? length;
}

class CatFactJsonMapper implements FromJsonParser {
  @override
  List toList(json) {
    //No list
    throw UnimplementedError();
  }

  @override
  toObject(Map<String, dynamic> json) {
    CatFact fact = CatFact();
    fact.fact = json['fact'];
    fact.length = json['length'];
    return fact;
  }
}
0
likes
0
pub points
0%
popularity

Publisher

verified publisherlapetina.fr

A Simplified Rest approach for Flutter. The concept of this package is to easily map json to bean and vice-versa.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, http

More

Packages that depend on rest_simplified