Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with GlobalKey on flutter SDK >= 2.12.0 #4

Open
hmanprod opened this issue Jul 28, 2021 · 1 comment
Open

Issue with GlobalKey on flutter SDK >= 2.12.0 #4

hmanprod opened this issue Jul 28, 2021 · 1 comment

Comments

@hmanprod
Copy link

hmanprod commented Jul 28, 2021

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
Copy link

dmchmk commented Feb 14, 2023

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants