pref 1.6.0

Flutter Android iOS web

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.

1
likes
100
pub points
54%
popularity

Publisher

nfet.net

Create Preference Screens easily with advanced features and sub-pages

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, shared_preferences

More

Packages that depend on pref