Shared Preferences Theory

 import "";


/// What is the use of SharedPreferences in Flutter?
// SharedPreferences in Flutter are kept in XML format. It is also compatible with iOS
// and Android. Assume you want to store a small value (likely a flag) that you want to
// be able to access later when a user opens the application.

/// SharedPreferences is a simple key-value pair storage mechanism in Flutter,
// commonly used for persisting small amounts of data in a Flutter application. It's
// particularly useful for storing settings, user preferences, or any other small pieces of
// data that need to be persisted across app sessions.

/// Here are some key points about SharedPreferences in Flutter:
/// ● Storage: SharedPreferences stores data in key-value pairs. Each pair consists
// of a unique key and the corresponding value.

/// ● Data Persistence: Data stored using SharedPreferences persists even if the
// application is closed or the device is restarted. It provides a way to store
// persistent data without using a database.
/// ● Scope: SharedPreferences is scoped to the application. This means that the
// stored data is accessible only within the context of the application where it
// was saved.
/// ● Data Types: SharedPreferences supports storing primitive data types such as
// integers, booleans, strings, and floats.
/// ● Asynchronous: Operations like reading from and writing to
// SharedPreferences are asynchronous, which means they do not block the
// main thread and are non-blocking.
/// ● Platform-specific Implementation: Under the hood, SharedPreferences
// utilises platform-specific implementations (e.g., SharedPreferences on
// Android, UserDefaults on iOS) to store and retrieve data.
/// ● Lightweight: SharedPreferences is lightweight and suitable for storing small
// amounts of data. It's not designed for storing large datasets.
/// ● Usage: Common use cases include storing user preferences, app settings,
// authentication tokens, or any other lightweight application state that needs to
// be persisted.

/// What are the advantages of SharedPreferences in Android?
// Here are some advantages of using shared preferences for data storage in
// Android applications:
/// ● Easy to Use. Shared preferences are easy to use and require minimal setup.
/// ● Lightweight. Shared preferences are lightweight and don't require any
// additional dependencies or libraries.
/// ● Persistence
/// ● Security.
/// How much data can I store in SharedPreferences?
// SharedPreferences are not intended to store a lot of data, there is no limit per se
// (since it is an xml file), but for larger sets of data, I would suggest using Room (or
// SQLite for the older projects).

Comments

Popular posts from this blog

Pagination with Bloc Pattern in Flutter

Pagination First Practical in Flutter

ExpansionPanel with ExpansionPanelList with Complete Collapse Operation in Flutter