Last updated:
0 purchases
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 #
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.