dartway_shared_preferences 0.1.1 copy "dartway_shared_preferences: ^0.1.1" to clipboard
dartway_shared_preferences: ^0.1.1 copied to clipboard

Shared-preferences plugin for DartWay: typed riverpod providers over local storage, reached as dw.plugins.prefs. Optional by design.

example/README.md

Example — a reactive preference #

Declare the plugin once:

DwFlutter(
  config: DwConfig(/* ... */),
  plugins: [DwSharedPreferences()],
);

Then a stored value is a provider the UI watches like any other:

final darkModeProvider = dw.plugins.prefs.provider<bool>(
  key: 'darkMode',
  defaultValue: false,
);

class DarkModeSwitch extends ConsumerWidget {
  const DarkModeSwitch({super.key});

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    final darkMode = ref.watch(darkModeProvider);
    return Switch(
      value: darkMode,
      onChanged: (value) =>
          ref.read(darkModeProvider.notifier).update(value),
    );
  }
}

The switch reflects storage and writes to it; no manual read/write, no reload. For a value that isn't a primitive, mappedProvider maps it to and from a String; for a one-off read, reach the underlying store with dw.plugins.prefs.raw.

0
likes
160
points
199
downloads

Documentation

API reference

Publisher

verified publisherdartway.dev

Weekly Downloads

Shared-preferences plugin for DartWay: typed riverpod providers over local storage, reached as dw.plugins.prefs. Optional by design.

Homepage
Repository (GitHub)
View/report issues

Topics

#dartway #shared-preferences #riverpod #storage

License

Apache-2.0 (license)

Dependencies

dartway_flutter, flutter, flutter_riverpod, shared_preferences

More

Packages that depend on dartway_shared_preferences