flutter_api_generator 0.0.1 copy "flutter_api_generator: ^0.0.1" to clipboard
flutter_api_generator: ^0.0.1 copied to clipboard

package that help you to generate Http Restful Api by annotation.

Usage #

part 'login.api.g.dart';

@RestApi()
abstract class LoginApi {
  factory LoginApi() => _LoginApi();

  @POST("app/login")
  HttpApi<UserEntity> login(@Body() LoginRequest request);

  @GET("app/{userId}")
  HttpApi<UserEntity?> getUser(@Path() String userId);
}

Then run the build_runner by 'flutter packages pub run build_runner build'.

You can get the following information from the generated HttpApi:

/// @Method
String method;

/// Url of @Method and @Path
String url;

/// baseUrl in @HttpApi
String? baseUrl;

/// @Body
Object? body;

/// @Query
Map<String, dynamic>? queryParams;

/// @Field
Map<String, dynamic>? fields;

/// @FormUrlEncoded
bool formUrlEncoded;

/// Type of response, as T
Type responseType;

/// @FromJson
FromJsonTransform<RESPONSE>? fromJson;

/// @Options, contains headers, responseType, receiveTimeout, sendTimeout
final HttpOptions? options;
0
likes
90
points
95
downloads

Publisher

unverified uploader

Weekly Downloads

package that help you to generate Http Restful Api by annotation.

Repository (GitHub)

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

analyzer, build, built_collection, code_builder, dart_style, flutter, meta, source_gen

More

Packages that depend on flutter_api_generator