flutter_model_api 1.0.0 copy "flutter_model_api: ^1.0.0" to clipboard
flutter_model_api: ^1.0.0 copied to clipboard

discontinuedreplaced by: flutter_api_model

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

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');
      }
    }
}
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();
}

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();
    }
  }
}

Additional information #

1
likes
140
points
13
downloads

Publisher

unverified uploader

Weekly Downloads

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

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_model_api