From 2795dedf835b4def4f77c2d791d5623f35948bfa Mon Sep 17 00:00:00 2001 From: Rongjian Zhang Date: Sat, 1 Feb 2020 18:14:42 +0800 Subject: [PATCH] improvement: keep duplicated accounts --- lib/models/auth.dart | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/lib/models/auth.dart b/lib/models/auth.dart index bb5541f..e7a52af 100644 --- a/lib/models/auth.dart +++ b/lib/models/auth.dart @@ -50,16 +50,7 @@ class AuthModel with ChangeNotifier { String get token => activeAccount.token; _addAccount(Account account) async { - // Remove previous if duplicated - List newAccounts = []; - for (var a in _accounts) { - if (!account.equals(a)) { - newAccounts.add(a); - } - } - newAccounts.add(account); - _accounts = newAccounts; - + _accounts = [...accounts, account]; // Save final prefs = await SharedPreferences.getInstance(); await prefs.setString(StorageKeys.accounts, json.encode(_accounts));