This project helps you manage user settings and application state in Dart and Flutter. It's a code generator that writes the boring, repetitive settings code for you, so you don't have to.
Stop worrying about typos in storage keys and manually converting data types. This tool creates a simple, tailor-made class for your project that makes managing preferences safe and easy.
- ✅ Forget Typos: All your setting keys are generated for you. Your code editor will catch any mistakes at compile-time, not crash your app at runtime.
- ✅ Use Any Storage: Works with your favorite storage solution. Whether you use
shared_preferences
, Hive, secure storage, or something else, the setup is simple. - ✅ Automatic Data Conversion: Forget about manually converting complex data like dates, times, colors, or your own custom classes. The generator handles the conversion to and from a storable format for you.
- ✅ Highly Customizable: Start with simple presets that match your needs, or fine-tune
everything. You can even set a project-wide convention, like making all storage keys
snake_case
, in a single line of configuration. - ✅ Ready for Reactive UIs: Easily build user interfaces that update automatically whenever a setting changes, without needing complex state management code.
Using the tool is a straightforward, three-step process:
-
Define a Blueprint You create a single, simple file where you list all the settings you need, like
username
orisDarkMode
, and their starting values. This is your single source of truth. -
Run the Generator You run a standard command in your terminal.
-
Use Your Custom Class The generator instantly creates a class that is perfectly tailored to your blueprint. You can now get and set preferences with simple, easy-to-read methods, and your code editor will help you avoid any mistakes.
This project is managed with Melos.
Package | Description |
---|---|
preferences_generator |
The main tool that generates your code. This is where you'll find the primary user documentation. |
preferences_annotation |
A lightweight helper package that provides the building blocks for your blueprint file. |
Example | Description |
---|---|
flutter_example |
A complete Flutter application demonstrating a reactive settings screen. |
console_example |
A command-line application showcasing all features in a pure Dart environment. |
Contributions are welcome! To get started with the development environment for this monorepo, follow these steps.
-
Activate Melos: (You only need to do this once)
dart pub global activate melos
-
Bootstrap the workspace: This command links all local packages together and installs their dependencies.
melos bootstrap
-
Run common tasks: Use these commands to run tasks across all packages in the workspace.
# Run all tests melos test # Run the code generator for all packages melos generate # Run static analysis melos analyze
This project is licensed under the MIT License - see the LICENSE
file for details.