What does flutter_secure_storage use on iOS?
On iOS, flutter_secure_storage uses the Keychain, which is Apple's secure encrypted storage.
Store sensitive data like tokens and passwords securely
You can read this lesson publicly. Sign in to unlock exercises, quiz, and FX progress tracking.
Having trouble? AI is here to help
Ask context-aware questions about this lesson. Free plan: 5 questions/day. Upgrade to Premium for higher daily limits.
Use the AI button at the bottom of the screen
The flutter_secure_storage package uses each platform's built-in secure storage mechanism to protect sensitive data. On iOS it uses the Keychain, and on Android it uses EncryptedSharedPreferences. This means your data is encrypted at rest by the operating system itself. Use it for any sensitive information your app needs to persist, such as authentication tokens, refresh tokens, API keys, user passwords, or encryption keys. Unlike SharedPreferences which stores everything in plain text, secure storage ensures that even if someone gains access to the device files, they cannot read your stored secrets.
1// pubspec.yaml: flutter_secure_storage: ^9.0.02import 'package:flutter_secure_storage/flutter_secure_storage.dart';34final storage = const FlutterSecureStorage();56// ── Write secure data ──7await storage.write(key: 'auth_token', value: 'eyJhbGciOiJIUz...');8await storage.write(key: 'refresh_token', value: 'dGhpcyBpcyBh...');9await storage.write(key: 'pin', value: '1234');1011// ── Read secure data ──12final token = await storage.read(key: 'auth_token');13if (token != null) {14// User is authenticated15print('Token: $token');16}1718// ── Delete data ──19await storage.delete(key: 'auth_token');2021// ── Delete ALL secure data ──22await storage.deleteAll();2324// ── Check if key exists ──25final hasToken = await storage.containsKey(key: 'auth_token');2627// ── Read all keys ──28final allData = await storage.readAll();29allData.forEach((key, value) => print('$key: $value'));
SharedPreferences stores data in plain text. Always use flutter_secure_storage for tokens, passwords, API keys, and other sensitive data.
Secure storage is one part of auth security, not the whole system. Define lifecycle rules:
Strong lifecycle design prevents stale credentials and reduces account takeover risk on shared devices.
Store sensitive data like tokens and passwords securely. Backend integration connects app actions to real user data and secure business workflows.
Think in architecture, reliability, and team-level maintainability.
Define data model and access rules before writing convenience helper methods.
Security and data integrity issues can damage user trust faster than UI bugs.
Security rules are part of architecture, not optional deployment polish.
As your app grows, keep UI, state, and data responsibilities separate so each part stays testable and easier to modify.
On iOS, flutter_secure_storage uses the Keychain, which is Apple's secure encrypted storage.
The read() method takes a named parameter key and returns a Future<String?>: null if the key doesn't exist.
Secure storage is designed for sensitive data like auth tokens, passwords, and API keys.
Something seems incorrect, unclear, or missing? Let us know.
FlutterCraft editorial lessons are reviewed by experienced Flutter developers and updated to stay aligned with modern Flutter and Dart best practices.
Reference docs: Flutter Documentation, Dart Language Tour, and official package documentation where relevant.
Sign in to continue with exercises and quiz for this lesson.
Sign In to Continue