Przeglądaj źródła

fix: call updateEmail after initState to avoid runtime exception

updateEmail uses getEnteColorScheme() which adds an inherited widget as dependency to the widget. Adding an inherited widget as dependency before init state is completed throws an exception
ashilkn 1 rok temu
rodzic
commit
04e45b7908
1 zmienionych plików z 3 dodań i 3 usunięć
  1. 3 3
      mobile/lib/ui/account/login_page.dart

+ 3 - 3
mobile/lib/ui/account/login_page.dart

@@ -29,18 +29,18 @@ class _LoginPageState extends State<LoginPage> {
   final Logger _logger = Logger('_LoginPageState');
 
   @override
-  void initState() {
+  void didChangeDependencies() {
+    super.didChangeDependencies();
     if ((_config.getEmail() ?? '').isNotEmpty) {
       updateEmail(_config.getEmail()!);
     } else if (kDebugMode) {
       updateEmail(const String.fromEnvironment("email"));
     }
-    super.initState();
   }
 
   @override
   Widget build(BuildContext context) {
-    final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
+    final isKeypadOpen = MediaQuery.viewInsetsOf(context).bottom > 100;
 
     FloatingActionButtonLocation? fabLocation() {
       if (isKeypadOpen) {