Skip to content

Commit e2f103a

Browse files
committed
fix: empty accounts
1 parent 841a5d1 commit e2f103a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/models/auth.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ class AuthModel with ChangeNotifier {
6565
// static final inAppReview = InAppReview.instance;
6666
var hasRequestedReview = false;
6767

68-
List<Account>? _accounts;
68+
List<Account> _accounts = [];
6969
int? activeAccountIndex;
7070
late StreamSubscription<Uri?> _sub;
7171
bool loading = false;
7272

7373
List<Account>? get accounts => _accounts;
7474
Account? get activeAccount {
75-
if (activeAccountIndex == null || _accounts == null) return null;
76-
return _accounts![activeAccountIndex!];
75+
if (activeAccountIndex == null || _accounts.isEmpty) return null;
76+
return _accounts[activeAccountIndex!];
7777
}
7878

7979
String get token => activeAccount!.token;
@@ -89,7 +89,7 @@ class AuthModel with ChangeNotifier {
8989
if (activeAccountIndex == index) {
9090
activeAccountIndex = null;
9191
}
92-
_accounts!.removeAt(index);
92+
_accounts.removeAt(index);
9393
// Save
9494
final prefs = await SharedPreferences.getInstance();
9595
await prefs.setString(StorageKeys.accounts, json.encode(_accounts));

0 commit comments

Comments
 (0)