Skip to content

A Flutter plugin that adds type safety when working with SharedPreferences.

License

Notifications You must be signed in to change notification settings

HubbleCommand/preftils_fl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Flutter plugin that adds type safety when working with SharedPreferences.

The pure Android version can be found here.

pub package

Features

Adds type safety to avoid runtime crashes when working with the amazing shared_preferences package.

Usage

Create your Preference objects:

const intPreference = Preference<int>("integer", 3);

Set it's value:

intPreference.set(7);
//If you already have an instance of SharedPreferences, you should pass it:
intPreference.set(7, prefs: await SharedPreferences.getInstance());

And read it:

int currentPreferenceValue = await intPreference.get();

If you already have an instance of SharedPreference, you can synchronously read values:

SharedPreferences prefs = await SharedPreferences.getInstance();
int currentPreferenceValue = intPreference.getSync(prefs);

Additional information

This is the Flutter version of my Android Preftils package. You can read more about the reason behind this package here.

About

A Flutter plugin that adds type safety when working with SharedPreferences.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages