diff --git a/lib/main.dart b/lib/main.dart index 3d3b3f7f..0b8536f3 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,9 +1,8 @@ -import 'dart:async'; - import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_app_lock/flutter_app_lock.dart'; +import 'package:matrix/matrix.dart'; import 'package:universal_html/html.dart' as html; import 'package:fluffychat/utils/client_manager.dart'; @@ -17,12 +16,8 @@ void main() async { // To make sure that the parts of flutter needed are started up already, we need to ensure that the // widget bindings are initialized already. WidgetsFlutterBinding.ensureInitialized(); - FlutterError.onError = - (FlutterErrorDetails details) => Zone.current.handleUncaughtError( - details.exception, - details.stack ?? StackTrace.current, - ); + Logs().nativeColors = !PlatformInfos.isIOS; final clients = await ClientManager.getClients(); if (PlatformInfos.isMobile) { diff --git a/lib/pages/chat_list/chat_list.dart b/lib/pages/chat_list/chat_list.dart index 9037c9cf..61d7cbab 100644 --- a/lib/pages/chat_list/chat_list.dart +++ b/lib/pages/chat_list/chat_list.dart @@ -268,7 +268,9 @@ class ChatListController extends State void editSpace(BuildContext context, String spaceId) async { await Matrix.of(context).client.getRoomById(spaceId)!.postLoad(); - VRouter.of(context).toSegments(['spaces', spaceId]); + if (mounted) { + VRouter.of(context).toSegments(['spaces', spaceId]); + } } // Needs to match GroupsSpacesEntry for 'separate group' checking. @@ -512,6 +514,7 @@ class ChatListController extends State }, ); if (result.error == null) { + if (!mounted) return; ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text(L10n.of(context)!.chatHasBeenAddedToThisSpace), @@ -545,14 +548,16 @@ class ChatListController extends State if (client.encryption?.keyManager.enabled == true) { if (await client.encryption?.keyManager.isCached() == false || await client.encryption?.crossSigning.isCached() == false || - client.isUnknownSession) { + client.isUnknownSession && !mounted) { await BootstrapDialog(client: client).show(context); } } } - setState(() { - waitForFirstSync = true; - }); + if (mounted) { + setState(() { + waitForFirstSync = true; + }); + } return; } @@ -592,6 +597,7 @@ class ChatListController extends State } void editBundlesForAccount(String? userId, String? activeBundle) async { + final l10n = L10n.of(context)!; final client = Matrix.of(context) .widget .clients[Matrix.of(context).getClientIndexByMatrixId(userId!)]; @@ -615,10 +621,8 @@ class ChatListController extends State case EditBundleAction.addToBundle: final bundle = await showTextInputDialog( context: context, - title: L10n.of(context)!.bundleName, - textFields: [ - DialogTextField(hintText: L10n.of(context)!.bundleName) - ]); + title: l10n.bundleName, + textFields: [DialogTextField(hintText: l10n.bundleName)]); if (bundle == null || bundle.isEmpty || bundle.single.isEmpty) return; await showFutureLoadingDialog( context: context,