Santos-Enoque / flutter-web-dashboard-template

270 stars 203 forks source link

Issue with GlobalKey on flutter SDK >= 2.12.0 #4

Open hmanprod opened 3 years ago

hmanprod commented 3 years ago

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 1 year ago

@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