retrofit 0.1.0

  • Installing
  • Versions
  • new62

Retrofit For Dart #

retrofit.dart is an dio client generator using source_gen and inspired by Chopper and Retrofit.

Usage #

Generator #

Add the generator to your dev dependencies



Define and Generate your API #

import 'package:retrofit/http.dart';
import 'package:dio/dio.dart';

part 'demo.retrofit.dart';

@RestApi(baseUrl: "")
abstract class RestClient {
  static final RestClient instance([Dio dio]) = _RestClient(dio);

    "Header-One": " header 1",
  Future<Response<String>> ip(@Query('query1') String query,
      {@QueryMap() Map<String, dynamic> queryies,
      @Header("Header-Two") String header});

  Future<Response<String>> profile(@Path("id") String id,
      {@Query("role") String role = "user",
      @QueryMap() Map<String, dynamic> map = const {},
      @Body() Map<String, dynamic> map2});

    "Accept": "application/json",
  Future<Response<String>> createProfile(@Query('query2') String query,
      {@QueryMap() Map<String, dynamic> queryies,
      @Header("Header-One") String header,
      @Body() Map<String, dynamic> map2,
      @Field() int field,
      @Field("field-g") String ffff});

  Future<Response<String>> updateProfile2(@Query('query3') String query,
      {@QueryMap() Map<String, dynamic> queryies,
      @Header("Header-One") String header,
      @Field() int field,
      @Field("field-g") String ffff});

  Future<Response<String>> updateProfile(@Query('query4') String query,
      {@QueryMap() Map<String, dynamic> queryies,
      @Field() int field,
      @Field("field-g") String ffff});

then run the generator

pub run build_runner build

flutter packages pub run build_runner build

Use it #

import 'package:retrofit_example/demo.dart';
import 'package:dio/dio.dart';

main(List<String> args) {
  final dio = Dio();
  dio.options.headers["Demo-Header"] = "demo header";
  final client = RestClient.instance(dio);

  client.ip("trevor").then((it) => print(it));

0.1.0 #

  • fix helth issues

0.0.1 #

  • init

Use this package as a library

1. Depend on it

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

  retrofit: ^0.1.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:

import 'package:retrofit/http.dart';
Version Uploaded Documentation Archive
0.1.0 Apr 11, 2019 Go to the documentation of retrofit 0.1.0 Download retrofit 0.1.0 archive
0.0.2 Apr 11, 2019 Go to the documentation of retrofit 0.0.2 Download retrofit 0.0.2 archive
0.0.1 Apr 7, 2019 Go to the documentation of retrofit 0.0.1 Download retrofit 0.0.1 archive
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 11, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14


Detected platforms: Flutter, web, other

No platform restriction found in libraries.

Health issues and suggestions

Document public APIs. (-1 points)

46 out of 46 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.

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 retrofit.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.1.0 <3.0.0
meta ^1.1.7 1.1.7