Santos-Enoque/flutter-web-dashboard-template

Issue with GlobalKey on flutter SDK >= 2.12.0

Opened this issue · 1 comments

Hi

I can't use GlobalKey as you do on flutter SDK >= 2.12.0

For example i got the error below on NavigationController :

Error: Method 'pushNamed' cannot be called on 'NavigatorState?' because it ispotentially null.

I add also to change the topNavigationBar function to a StatelessWidget class extending PreferredSizeWidget and use Scaffold.of(context) instead of scaffoldKey to make it work.

I have no idea how to fix this error on NavigationController.

dmchmk commented

@Santos-Enoque hello! Any help here maybe? I've also faced similar issue:

lib/widgets/top_nav.dart:15:24: Error: Method 'openDrawer' cannot be called on 'ScaffoldState?' because it is potentially null.
 - 'ScaffoldState' is from 'package:flutter/src/material/scaffold.dart' ('../../flutter/packages/flutter/lib/src/material/scaffold.dart').
Try calling using ?. instead.
      key.currentState.openDrawer();
                       ^^^^^^^^^^

https://imgur.com/a/8V0fEjT