ms_persist 2.2.0 copy "ms_persist: ^2.2.0" to clipboard
ms_persist: ^2.2.0 copied to clipboard

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

10
likes
150
pub points
51%
popularity

Publisher

verified publishermarcussoftware.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

flutter, meta, ms_map_utils, path, path_provider, sembast, sembast_sqflite, sembast_web, sqflite, sqflite_common_ffi, uuid

More

Packages that depend on ms_persist