What's the best way to save jwt tokens in flutter apps?

zeucxb picture zeucxb · Mar 7, 2019 · Viewed 17.3k times · Source

Not just where (eg: SQLite...) but also how (libs, best specific practices)?

Answer

Nicodemuz picture Nicodemuz · May 1, 2019

You probably don't want to store sensitive data in shared preferences. Instead you might want to look into a plugin like this: https://pub.dartlang.org/packages/flutter_secure_storage

import 'package:flutter_secure_storage/flutter_secure_storage.dart';

// Create storage
final storage = new FlutterSecureStorage();

// Write value 
await storage.write(key: 'jwt', value: token);