Sample questions
Fl Flutter Persistence StorageDifficulty 1
What kind of data is SharedPreferences designed to store?
- aSmall primitive values as simple key-value pairs✓
- bArbitrary binary blobs of any size, indexed by key.
- cRelational tables with foreign key constraints between them.
- dLarge media files such as images and videos.
Explanation:SharedPreferences wraps a platform-level key-value store meant for small settings-like data — primitives and string lists — not large or structured data; that is what a proper database or file storage is for.
Fl Flutter Persistence StorageDifficulty 1
Why does reading a value with SharedPreferences.getInstance() require an await?
- aBecause obtaining the preferences instance itself is asynchronous✓
- bBecause Dart forbids synchronous function calls entirely.
- cBecause it triggers a network request to a remote config server.
- dBecause the value is encrypted and needs an async decryption step every time.
Explanation:SharedPreferences.getInstance() loads the underlying preferences store asynchronously the first time it's accessed, so it returns a Future; once obtained, individual getters like getString are synchronous.
Fl Flutter Persistence StorageDifficulty 2
A developer tries to store a custom User object directly with prefs.setString('user', user) without converting it. What happens?
- aIt works fine; SharedPreferences automatically serializes any Dart object.
- bIt silently stores an empty string instead.
- cIt stores the object's memory address as a string.
- dIt throws, because
setString requires an actual String✓
Explanation:SharedPreferences only accepts its supported primitive types; a custom object must be explicitly serialized (commonly to a JSON string) before being stored and deserialized after being read back.
Fl Flutter Persistence StorageDifficulty 1
What is sqflite primarily used for in a Flutter app?
- aExecuting SQL queries against a local database✓
- bMaking authenticated HTTP requests to a REST API.
- cManaging widget-level state across rebuilds.
- dRendering platform-native UI widgets.
Explanation:sqflite is a plugin that gives Dart code access to a local SQLite database on the device, letting the app run SQL queries directly.
Fl Flutter Persistence StorageDifficulty 2
In sqflite, when the database version increases and onUpgrade is provided to openDatabase, what is onUpgrade responsible for?
- aRunning the migration statements for the new schema version✓
- bAutomatically detecting and applying schema changes with zero code.
- cDeleting and recreating the database file from scratch every time.
- dOnly updating the app's UI to reflect the new version number.
Explanation:onUpgrade is called with the old and new version numbers when an existing database needs to move to a newer schema version; the developer writes the actual migration SQL (or logic) inside it.
Fl Flutter Persistence StorageDifficulty 1
What is Hive in the Flutter ecosystem?
- aA lightweight, key-value NoSQL database written in pure Dart✓
- bA relational SQL database engine bundled with Flutter itself.
- cA tool exclusively for managing app permissions.
- dA remote cloud database service requiring an internet connection.
Explanation:Hive is a fast, pure-Dart NoSQL key-value store designed for local persistence, with no native SQL engine involved.