import 'package:flutter_secure_storage/flutter_secure_storage.dart'; const _storage = FlutterSecureStorage(); /// Manages login details class LoginManager { /// Checks if user has saved login details static Future get hasSavedLogin async { return (await _storage.containsKey(key: "sub_user")) && (await _storage.containsKey(key: "sub_pass")) && (await _storage.containsKey(key: "sub_url")); } /// Stores log in details into secure storage static Future saveDetails(String user, String pass, String url) async { await _storage.write(key: "sub_user", value: user); await _storage.write(key: "sub_pass", value: pass); await _storage.write(key: "sub_url", value: url); } /// Returns log in details from secure storage static Future?> getDetails() async { final user = await _storage.read(key: "sub_user"); final pass = await _storage.read(key: "sub_pass"); final url = await _storage.read(key: "sub_url"); if (user == null || pass == null || url == null) return null; return {"user": user, "pass": pass, "url": url}; } }