retrolite 1.1.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 50

retrolite #

retrolite is a RESTful API client for Dart and Flutter, with a simple API syntax, without reflection.

This package uses the abstraction classes from flutuate_api, used to create RESTful api clients.

Configuration #

Add retrolite to pubspec.yaml under the dependencies field.

  retrolite: ^latest_version

Import #

Add the following import in your library :

import 'package:retrolite/retrolite.dart';

Example #

Below, a simple provider sample to REQ|RES API:

/// [REQ|RES]( API provider 
class ReqResApi extends IApi {
  /// Get the users list.
  Future<Response<ListUsers>> listUsers(int page) => 
      contentType: ContentType.json,
      deserializer: ListUsers.deserialize,

  /// Request the users list with delay.
  Future<Response<ListUsers>> listUsersWithDelay(int delay) => 
      queryParameters: {
        'delay': delay
      contentType: ContentType.json,
      deserializer: ListUsers.deserialize,

  /// Request the register service with success.
  Future<Response<RegisterResult>> register(RegisterContent content) =><RegisterResult>(
      deserializer: RegisterResult.deserialize,
      contentType: ContentType.json,
      body: content

Usage #

The sample project has more details about how to use the Retrolite package.

Features and bugs #

Please file feature requests and bugs at the issue tracker.

1.1.2 #

  • Sources formatted

1.1.1 #

  • Sources formatted

1.1.0 #

  • Migrated package flutuate_api to here;
  • Implemented PUT, PATCH, HEAD, DELETE requests.

1.0.0 #

  • First release.

0.0.1 #

  • Initial version, created by Luciano Rodrigues


import 'dart:io';

import 'package:http/http.dart' as http;
import 'package:http/io_client.dart';
import 'package:retrolite/Secrets.dart';
import 'package:retrolite/flutuate_api.dart';
import 'package:retrolite/retrolite.dart';

import 'reqres/RegisterContent.dart';
import 'reqres/ReqResApi.dart';
import 'tmdb/TmdbApi.dart';

main() async {
  await listMoviesGenresFromTmdbApi();

  await registerFromReqResApi();

void listMoviesGenresFromTmdbApi() async {
  print('Calling TMDB api...\n');

  Retrolite retrolite = Retrolite(
    httpClientCreator: newHttpClient,

  Secrets secrets = await Secrets.loadFromFile();

  if (secrets.containsKey('tmdb_token')) {
    TmdbApi api =
        retrolite.register<TmdbApi>(new TmdbApi(secrets['tmdb_token']));

    await api.genresForMovies().then((response) {
      for (var genre in response.body.genres) {
  } else {
        'Please, specifies you TMDB API token in "resources/secrets.json" file.');

void registerFromReqResApi() async {
  print('Calling REQ|RES api...\n');

  Retrolite retrolite = Retrolite(
    httpClientCreator: newUnsafeHttpClient,

  ReqResApi api = retrolite.register<ReqResApi>(new ReqResApi());

  RegisterContent content = new RegisterContent('', 'pistol');

  await api.register(content).then((response) {

/// Returns an instance of the default http client.
http.BaseClient newHttpClient() {
  return newDefaultHttpClient();

/// Returns an http client that ignores unsafe SSL certificates.
http.BaseClient newUnsafeHttpClient() {
  final bool trustSelfSigned = true;
  HttpClient httpClient = new HttpClient()
    ..badCertificateCallback =
        ((X509Certificate cert, String host, int port) => trustSelfSigned);
  return new IOClient(httpClient);

Use this package as a library

1. Depend on it

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

  retrolite: ^1.1.2

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:retrolite/retrolite.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 7, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Health suggestions

Format lib/Secrets.dart.

Run dartfmt to format lib/Secrets.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0
collection ^1.14.11 1.14.12
http ^0.12.0+2 0.12.0+4
Transitive dependencies
async 2.4.1
charcode 1.1.3
http_parser 3.1.4
meta 1.1.8
path 1.6.4
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
pedantic ^1.0.0 1.9.0
test ^1.0.0