ms_persist 1.0.0

Flutter Android iOS

A mixin that help you on handling model as a CRUD, you just need implement 3 overrides

MS Persist #

Pub GitHub stars Buy Me A Coffee donate button

A mixin that help you on handling model as a CRUD

Getting Started #

Is very simple to start use.

After set the lib in pubspec.yaml and run flutter pub get

import 'package:ms_persist/ms_persist.dart';

class YourModel with Persist<YourModel> {
  // .. a lot of another fields
  String someField;
  //TODO: implement field uuid
  @override
  String uuid;

  YourModel({this.uuid,this.someField/*other fields*/});

  //TODO: implement buildModel
  @override
  YourModel buildModel(Map<String, dynamic> map){
    return YourModel(
      uuid: map['uuid'],
      someField: map['someField'],
      );
  }

  //TODO: implement toMap
  @override
  Map<String, dynamic> toMap(){
    return {
      'uuid': this.uuid,
      'someField': someField,
      //TODO: add here every field or extra data that you want to save
    };
  }
}

// Now just use Persist to do hard word to persist data.
void main() async {
    var myModel = YourModel().find('42854c0c-018d-11eb-adc1-0242ac120002');
    myModel.someField = 'new value';
    await myModel.save();
    myModel.someField = 'other value';
    myModel.isDirty(); // returns true;
    await myModel.save();
    myModel.isDirty(); // returns false;
}

That's all folks!

I hope you enjoy this lib.

See another libs here

5
likes
100
pub points
28%
popularity

Publisher

marcussoftware.info

A mixin that help you on handling model as a CRUD, you just need implement 3 overrides

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

ms_map_utils, path, path_provider, sembast, sembast_sqflite, sqflite, uuid

More

Packages that depend on ms_persist