pref_gen 0.0.3 pref_gen: ^0.0.3 copied to clipboard
Generator to create boilerplate for shared preferences based on a provided interface. The generator is platform agnostic README for more details
pref_gen #
Generator to create boilerplate for shared preferences based on a provided interface.
The generated code is platform agnostic, there's an adapter interface inside the pref_gen_annotations package that can be used to inject an implementation based on the platform project.
This choice was made to give developers the ability to model persistance rapidly into packages shared between Flutter and Web apps.
Usage #
Suppose the shared model package is called A and B the platform specific annotation.
- Add this package as a dev dependency to your
A/pubspec.yaml
. - Add
pref_gen_annotations
as a dependency to yourA/pubspec.yaml
- Annotate classes with the PreferencesHolder (or the ReactivePreferencesHolder) annotation.
- Run
pub run build_runner build
to start the code generation. - Comsume the generated code into the
A
package. - Add
pref_gen_flutter
inB/pubspec.yaml
and inject fromB
the implementation of the adapter for Flutter into the model. - Consume the model into the views.