http_api_generator

Last updated:

0 purchases

http_api_generator Image
http_api_generator Images
Add to Cart

Description:

http api generator

Features #
Generate Http api info by annotation
Getting started #
Add dependency to your pubspec:
http_api_generator: latest_version
copied to clipboard
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);
}
copied to clipboard
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;
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.