preferences 5.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 96

preferences #

Create Preference Screens easily with advanced features and subpages

Screenshots #

Features #

  • Easy addition of preferences

  • Subpages

  • Customization options

  • Hide preferences dynamically

  • Reset state on Exception

Installing #

You should ensure that you add preferences as a dependency in your flutter project.

  preferences: ^4.0.0

Then run flutter packages get to get the package.

Usage #

Change your main method to

import 'package:preferences/preferences.dart';

main() async {
  await PrefService.init(prefix: 'pref_');

And then you can use the widgets

return Scaffold(
      appBar: AppBar(
        title: Text('Preferences Demo'),
      body: PreferencePage([
          'Start Page',
          defaultVal: 'Timeline',
          values: ['Posts', 'Timeline', 'Private Messages'],
          'Light Theme',
          isDefault: true,
          'Dark Theme',

Look at the example for more information.

[5.0.1] - 04.10.2019

  • You can now use PrefService without init() if you use caching.

[5.0.0] - 03.10.2019

  • Added validation for TextFieldPreference
  • Added obscureText, hintText, style, keyboardType, labelStyle and decoration for TextFieldPreference
  • Added disabled option for every widget
  • Added leading and subtitle for PreferenceText

[4.0.0] - 11.06.2019

  • Added setDefaultValues function to PrefService
  • CheckboxPreference, DropdownPreference, SwitchPreference, TextFieldPreference: Default value of the widget is now set and saved when first rendered
  • Added possibility to modify saved text in TextFieldPreference by returning custom string in the onChange Method

[3.0.0] - 06.05.2019

  • Added TextField preference
  • PreferenceTitle: Added Option to override left padding
  • PreferenceDialogLink: Added onPop callback
  • Fixed Prefix not applying when caching

[2.0.0] - 30.01.2019

  • Upgraded shared_preferences to 0.5.2

[1.3.0] - 26.01.2019

  • Fixed Issue with PrefService prefix not applying

[1.2.0] - 20.01.2019

  • Added PreferenceDialog and PreferenceDialogLink
  • Added cache for PrefService to cache values and only apply them when submitting a dialog or confirming a change
  • Added StringList Getter and Setter to PrefService
  • Fixed some issues

[1.1.0] - 17.01.2019

  • Fixed Issue with default RadioPreference being not first

[1.0.8] - 05.01.2019

  • Fixed Issue with PreferenceHider

[1.0.7] - 05.01.2019

  • Fixed Issue with RadioPreference widgets on subpage

[1.0.5] - 05.01.2019

  • DropdownPreference Displayed Values can now be different from saved values
  • PreferencePageLink Page Title can now be different from Link-Label

[1.0.3] - 01.01.2019

  • You can now init PrefService again with a different prefix

[1.0.0] - 31.12.2018

  • Initial release.


preferences_example #

An example project for the preferences package

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  preferences: ^5.0.1

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:preferences/preferences.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Oct 20, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
shared_preferences ^0.5.2 0.5.3+5
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies