flutter_model_api

Creator: coderz1093

Last updated:

0 purchases

flutter_model_api Image
flutter_model_api Images
Add to Cart

Description:

flutter model api

Features #
Modeling of network requests, which manages input parameters and output parameters, which follows the "In-Out" naming convention.
Naming rules: #

The prefix of the input parameter: in

(inUsername, inPassword)


The prefix of the return value: out

(outLoginUser)



Getting started #
Usage #
doAsync() async {
LoginAPI api = await LoginAPI(inNickname: 'jack', inPassword: '12345',).launch();
if (api.hasError) {
alert(api.outError);
} else {
User? currentUser = api.outUser;
if(currentUser != null) {
pagePush();
} else {
alert('User does not exist');
}
}
}
copied to clipboard
doSync() {
LoginAPI(inNickname: 'jack', inPassword: '12345').onComplete((api) {
if (api.hasError) {
alert(api.outError);
} else {
User? currentUser = api.outUser;
if (currentUser != null) {
pagePush();
} else {
alert('User does not exist');
}
}
}).launch();
}
copied to clipboard
class define #
class LoginAPI extends ModelAPI<LoginAPI> {
LoginAPI({required this.inNickname, required this.inPassword});

String inNickname;

String inPassword;

User? outUser;

@override
loading() async {
try {
outUser = await httpRequestUser();
} catch (e) {
outError = e;
} finally {
complete();
}
}
}
copied to clipboard
Additional information #

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.