pref 2.8.0 copy "pref: ^2.8.0" to clipboard
pref: ^2.8.0 copied to clipboard

Create Preference Screens easily with advanced features and sub-pages

pref #

Create Preference Screens easily with advanced features and sub-pages

Demo video

Usage #

In your main method, add:

WidgetsFlutterBinding.ensureInitialized();

final service = await PrefServiceShared.init(
  defaults: {
    'start_page': 'posts',
    'ui_theme': 'light',
  },
);

runApp(
  PrefService(
    service: service,
    child: MyApp(),
  ),
);

And then you can use the widgets

Scaffold(
  appBar: AppBar(
    title: Text('Preferences Demo'),
  ),
  body: PrefPage(children: [
    PrefTitle(title: Text('General')),
    PrefDropdown<String>(
      title: Text('Start Page'),
      pref: 'start_page',
      items: [
        DropdownMenuItem(value: 'posts', child: Text('Posts')),
        DropdownMenuItem(value: 'timeline', child: Text('Timeline')),
        DropdownMenuItem(value: 'pm', child: Text('Private Messages')),
      ],
    ),
    PrefTitle(title: Text('Personalization')),
    PrefRadio(
      title: Text('Light Theme'),
      value: 'light',
      pref: 'ui_theme',
    ),
    PrefRadio(
      title: Text('Dark Theme'),
      value: 'dark',
      pref: 'ui_theme',
    ),
  ]),
);

To use the values inside your application:

final startPage = PrefService.of(context).get('start_page');

Look at the example for more information.

44
likes
150
points
960
downloads
screenshot

Documentation

API reference

Publisher

verified publishernfet.net

Weekly Downloads

Create Preference Screens easily with advanced features and sub-pages

Homepage
Repository (GitHub)
View/report issues

Topics

#persistence #shared-preferences #storage #settings #preferences

License

MIT (license)

Dependencies

flutter, logging, shared_preferences

More

Packages that depend on pref