Clever Settings Flutter
A flutter package that provides useful flutter utilities for clever_settings.
Installation 💻
Add clever_settings_flutter
and clever_settings
to your pubspec.yaml
:
dependencies:
clever_settings: ^[version]
clever_settings_flutter: ^[version]
Install it:
flutter packages get
Initialization 🚀
Before you can start using Clever Settings, you need to initialize it first. Call the init function once at the start of your application:
await CleverSettingsFlutter.init();
This will initialize Hive and open the settings database.
If you want to configure Hive yourself, you can use CleverSettings.open()
after initializing Hive.
Usage 💡
This will only focus on the additional features of
clever_settings_flutter
. The readme for the basic usage ofclever_settings
can be found here.
SettingsValueBuilder
The SettingsValueBuilder
is a widget used for building other widgets that depend on a SettingsValue
object. It rebuilds whenever the value of the setting changes.
Example:
class Settings {
static const mySetting =
SettingsValue<bool>(name: 'mySetting', defaultValue: true);
}
...
SettingsValueBuilder(
setting: Settings.mySetting,
builder: (context, value, child) {
return Text(value.toString());
},
),
MultiSettingsValueBuilder
The MultiSettingsValueBuilder
is a widget that allows you to listen to and combine multiple SettingsValue
objects to build a widget that depends on all of them.
Example:
MultiSettingsValueBuilder(
settings: [
Settings.mySetting,
Settings.myOtherSetting,
],
builder: (context, child) {
// Updates when one of the settings changes.
return Text('${Settings.mySetting.value} ${Settings.myOtherSetting.value}');
},
)
Libraries
- clever_settings_flutter
- Library providing flutter utilities for
clever_settings
.