thyi 1.0.11 thyi: ^1.0.11 copied to clipboard
thyi annotations
How to use #
- First define a bean class
class User {
var username = "";
var nickname = "";
}
- Add the
json_serializable
dependency Thejson_serializble
usage please see it's doc. And then add JsonSerialzble to User class
@JsonSerializable()
class User {
var username = "";
var nickname = "";
}
- Then define the Api class wich define your api interface. Example api.dart.
/// the api.dart file
class API {
@GET("/user/1")
Future<User> getUser(@PARAM("id") int id);
}
-
Run
flutter pub run build_runner build
to generate api impl, by generate the api_thyi.dart file. -
New the api
/// the API_thyiImpl is the generate class(in api_thyi.dart file).
var api = new API_thyiImpl(Thyi(rootUrl));