rpo_shered_preference will help you to store any type of data in the form of key-value pair to your localstorage

Platform Support

AndroidiOSMacOSWebLinuxWindows
✔️✔️✔️✔️✔️✔️

Getting started

Run this command

flutter pub add pro_shered_preference

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  pro_shered_preference: ^0.0.7

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

Import it

Now in your Dart code, you can use:

import 'package:pro_shered_preference/pro_shered_preference.dart';

Usage

Save single string to device shared preference.

bool result = await sheredPrefHelper.setString("name", "Gautam Sheta");

Here name is a key and Gautam Sheta is a value. If data stored successfully then it will œreturn true

Save multiple string to device shared preference at once.

bool result = await sheredPrefHelper.setMultiString({
          "name": "Gautam Sheta",
          "email": "email@gmail.com",
          "address": "India",
        });

Here name,email & address are a keys and Gautam Sheta, email@gmail.com & India are a values. If all data stored successfully then it will œreturn true

Get single string from device shared preference.

String result = await sheredPrefHelper.getString("name");

name is a key and it will return value according to key, If value not found then it will throw KeyNotFoundException exception and if data type is not string then throw WrongDatatypeException exception.

Get multiple string from device shared preference at once.

Map<String, String> result33 = await sheredPrefHelper.getMultiString([
          "name",
          "email",
          "address",
        ]);

name,email & address are a keys and it will return values according to keys, If any of thev value not found then it will throw KeyNotFoundException exception and if data type is not string then throw WrongDatatypeException exception.

MethodsDescription
setStringFor save the single string value
setIntFor save the single integrate value
setDoubleFor save the single double vlaue
setBoolFor save the single boolean value
setStringListFor save the single string type of list
setIntListFor save the single integrate type of list
setDoubleListFor save the single double type of list
setBoolListFor save the single boolean type of list
setDynamicListFor save the single dynamic type of list
setMapFor save the single <String, dynamic> map
setFor save the any type of single key-value pair
setMultiStringFor save the multiple string at once
setMultiIntFor save the multiple integrate at once
setMultiDoubleFor save the multiple double at once
setMultiBoolFor save the multiple boolean at once
setMultiStringListFor save the multiple string type of list at once
setMultiIntListFor save the multiple integrate type of list at once
setMultiDoubleListFor save the multiple double type of list at once
setMultiBoolListFor save the multiple boolean type of list at once
setMultiDynamicListFor save the multiple dynamic type of list at once
setMultiMapFor save the multiple <String, dynamic> map at once
setMultiFor save the multiple dynamic value at once
getStringGet single string from storage
getIntGet single integrate value from storage
getDoubleGet single double value from storage
getBoolGet single boolean value from storage
getStringListGet single string type of list from storage
getIntListGet single integrate type of list from storage
getDoubleListGet single double type of list from storage
getBoolListGet single boolean type of list from storage
getDynamicListGet single dynamic type of list from storage
getMapGet <String, dynamic> type of map from storage
getGet any type of dynamic data from storage
getMultiStringGet multiple string at once from storage
getMultiIntGet multiple integrate at once from storage
getMultiDoubleGet multiple double at once from storage
getMultiBoolGet multiple boolean at once from storage
getMultiStringListGet multiple string type of list at once from storage
getMultiIntListGet multiple integrate type of list at once from storage
getMultiDoubleListGet multiple double type of list at once from storage
getMultiBoolListGet multiple boolean type of list at once from storage
getMultiDynamicListGet multiple dynamic type of list at once from storage
getMultiMapGet multiple <String, dynamic> type of map at once from storage
getMultiGet any type of multiple value at once from storage

Note

once you use pro_shered_preference package, Do not use any kind of similar package for get or store prefrence value. othervise it will throw an error

Developer

Avatar Gautam Sheta

Libraries

pref_exception
pro_shered_preference
Strings