Skip to content
pubscout

sp_util

2.0.3, released 6 years ago by an unverified publisher

Flutter shared_preferences plugin utility supporting default values and objects.

WASM-readyUnverified publisher
$ flutter pub add sp_util
Source repository

What it does

It wraps the shared_preferences plugin to make it easier to store and retrieve primitive data types, objects, and object lists. It provides helper methods for key management, defaults, and saving custom serializable objects.

AI-written summary of version 2.0.3, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You want a simpler utility wrapper around shared_preferences
  • You need to easily serialize and store custom objects or lists of objects into key-value storage

Skip it when

  • You require secure encrypted local storage
  • You need complex relational queries or high-performance local databases

Strengths

  • Simplifies working with shared_preferences
  • Supports saving and retrieving custom objects and object lists directly

Weaknesses

  • Relies on global static initialization which may require careful app startup flow
  • Shared preferences is not suitable for large or secure datasets

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
2

Must call await SpUtil.getInstance() before running the app.

void main() async {
  await SpUtil.getInstance();
  SpUtil.putString("username", "sky24");
  String userName = SpUtil.getString("username", defValue: "");
}

Alternatives

Packages that do the same job and could replace sp_util.

  • hive_ce

    Offers a faster NoSQL key-value storage alternative with built-in object adapters.

Works with

Packages commonly used together with sp_util: ones it builds on, ones built on it, and its own family.