← All courses

Persistence & Deployment

🗓 May 31, 2026 ⏱ 2 min read

Choosing where to store data

  • shared_preferences — small key-value data (settings, flags, a token).
  • Files (path_provider) — documents or cached JSON.
  • SQLite (sqflite) / Drift / Isar — large, structured, queryable data.
  • flutter_secure_storage — encrypted storage for secrets like tokens.

shared_preferences

final prefs = await SharedPreferences.getInstance();
await prefs.setBool('darkMode', true);
final dark = prefs.getBool('darkMode') ?? false;

Perfect for simple preferences. Don’t use it for large or sensitive data.

A local database

For lists of records you query and update (notes, tasks, an offline cache), use a database. sqflite is the classic SQLite plugin; Isar and Drift are modern, type-safe options that are easier to use and very fast.

Building a release app

Before shipping, set your app name, icon (the flutter_launcher_icons package helps), and version in pubspec.yaml. Then build:

# Android — an App Bundle for the Play Store
flutter build appbundle

# iOS — build, then archive in Xcode
flutter build ios

Signing & publishing

  • Android — create a signing keystore (keep it safe forever), configure it, build the .aab, and upload it in the Google Play Console.
  • iOS — you need a Mac and an Apple Developer account; open the build in Xcode, archive, and upload to App Store Connect.

Reducing app size and bugs

Release builds are already compiled and optimised (tree-shaking removes unused code). Test on real devices, run flutter analyze to catch issues, and use flutter test for automated tests.

Web and desktop

The same project can target the web (flutter build web) and desktop (flutter build windows/macos/linux) — one of Flutter’s biggest advantages.

Common mistakes

  • Storing tokens/passwords in shared_preferences instead of secure storage.
  • Losing the Android keystore (you can never update the app without it).
  • Forgetting to bump the version before each store upload.
Summary: Use shared_preferences for settings, a database (sqflite/Isar/Drift) for structured data, and secure storage for secrets. Ship with flutter build appbundle/ios, sign correctly (guard your keystore), and remember the same code can target web and desktop.