Explorar el Código

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 hace 1 año
padre
commit
04e45b7908
Se han modificado 1 ficheros con 3 adiciones y 3 borrados
  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');
   final Logger _logger = Logger('_LoginPageState');
 
 
   @override
   @override
-  void initState() {
+  void didChangeDependencies() {
+    super.didChangeDependencies();
     if ((_config.getEmail() ?? '').isNotEmpty) {
     if ((_config.getEmail() ?? '').isNotEmpty) {
       updateEmail(_config.getEmail()!);
       updateEmail(_config.getEmail()!);
     } else if (kDebugMode) {
     } else if (kDebugMode) {
       updateEmail(const String.fromEnvironment("email"));
       updateEmail(const String.fromEnvironment("email"));
     }
     }
-    super.initState();
   }
   }
 
 
   @override
   @override
   Widget build(BuildContext context) {
   Widget build(BuildContext context) {
-    final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
+    final isKeypadOpen = MediaQuery.viewInsetsOf(context).bottom > 100;
 
 
     FloatingActionButtonLocation? fabLocation() {
     FloatingActionButtonLocation? fabLocation() {
       if (isKeypadOpen) {
       if (isKeypadOpen) {