Local Storage
SharedPreferences, flutter_secure_storage, path_provider, files, security best practices
1Which package should be used to store simple key-value pairs persistently in a Flutter application?
Which package should be used to store simple key-value pairs persistently in a Flutter application?
Resposta
SharedPreferences is the standard package for storing simple key-value data persistently in Flutter. It uses NSUserDefaults on iOS and SharedPreferences on Android. This package is ideal for user preferences, application settings, or small amounts of non-sensitive data.
2How to obtain a SharedPreferences instance in Flutter?
How to obtain a SharedPreferences instance in Flutter?
Resposta
SharedPreferences.getInstance() returns a Future that resolves to the single SharedPreferences instance. This asynchronous method loads preferences from native storage. It is recommended to call this method once and reuse the instance to avoid multiple loads.
3What data types can be stored with SharedPreferences?
What data types can be stored with SharedPreferences?
Resposta
SharedPreferences only supports primitive types: int, double, bool, String, and List<String>. To store complex objects, they must be serialized to JSON String and then deserialized when reading. This limitation is due to the underlying native implementation on iOS and Android.
Which method should be used to save a boolean value with SharedPreferences?
What does prefs.getString('key') return if the key does not exist in SharedPreferences?
+17 perguntas de entrevista
Outros temas de entrevista Flutter
Dart Basics
Dart Language Essentials
Flutter Fundamentals
Widget Lifecycle
Application Lifecycle
Layouts & Constraints
ListView & GridView
Navigation & Routing
Basic State Management
Provider Pattern
Networking & HTTP
JSON Serialization
Local Database
Forms & Validation
Animations
Firebase Integration
Unit Testing
Widget Testing
Build & Deployment
Package Management
Memory & Performance
Streams & RxDart
Advanced State Management
Flutter Design Patterns
Performance Optimization
Platform Channels
Custom Painting
Flutter Application Architecture
Domine Flutter para sua proxima entrevista
Acesse todas as perguntas, flashcards, testes tecnicos, exercicios de code review e simuladores de entrevista.
Comece gratis