preferences 5.0.2
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.
dependencies:
preferences: ^5.0.2
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_');
runApp(MyApp());
}
And then you can use the widgets
return Scaffold(
appBar: AppBar(
title: Text('Preferences Demo'),
),
body: PreferencePage([
PreferenceTitle('General'),
DropdownPreference(
'Start Page',
'start_page',
defaultVal: 'Timeline',
values: ['Posts', 'Timeline', 'Private Messages'],
),
PreferenceTitle('Personalization'),
RadioPreference(
'Light Theme',
'light',
'ui_theme',
isDefault: true,
),
RadioPreference(
'Dark Theme',
'dark',
'ui_theme',
),
]),
);
Look at the example for more information.
[5.0.2] - 05.11.2019
- Added
sharedPreferences.clear()
- Added
onTap
callback toPreferenceText
- Added
leading
toRadioPreference
- Updated to
shared_preferences
0.5.4+3
[5.0.1] - 04.10.2019
- You can now use
PrefService
withoutinit()
if you use caching.
[5.0.0] - 03.10.2019
- Added validation for
TextFieldPreference
- Added
obscureText
,hintText
,style
,keyboardType
,labelStyle
anddecoration
forTextFieldPreference
- Added
disabled
option for every widget - Added
leading
andsubtitle
forPreferenceText
[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:
dependencies:
preferences: ^5.0.2
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';
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
93
|
Health:
Code health derived from static analysis.
[more]
|
100
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
100
|
Overall:
Weighted score of the above.
[more]
|
96
|
We analyzed this package on Dec 13, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
- Dart: 2.7.0
- pana: 0.13.1+4
- Flutter: 1.12.13+hotfix.4
Health suggestions
Format lib/preference_service.dart
.
Run flutter format
to format lib/preference_service.dart
.
Format lib/preference_text.dart
.
Run flutter format
to format lib/preference_text.dart
.
Dependencies
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.4+3 | 0.5.6 | |
Transitive dependencies | |||
collection | 1.14.11 | 1.14.12 | |
flutter_web_plugins | 0.0.0 | ||
meta | 1.1.8 | ||
shared_preferences_macos | 0.0.1+3 | ||
shared_preferences_platform_interface | 1.0.1 | ||
shared_preferences_web | 0.1.2+2 | ||
sky_engine | 0.0.99 | ||
typed_data | 1.1.6 | ||
vector_math | 2.0.8 | ||
Dev dependencies | |||
flutter_test |