Skip to content

Loaded scripts issue? #21993

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

Closed
haoguo opened this issue Sep 18, 2018 · 2 comments
Closed

Loaded scripts issue? #21993

haoguo opened this issue Sep 18, 2018 · 2 comments

Comments

@haoguo
Copy link

haoguo commented Sep 18, 2018

Hi all,
I found something strange on my application.
In my entry point file (main.dart) I have class A like

class A extends StatelessWidget {
  static final GlobalKey _globalKey = GlobayKey(debugLabel: 'blahblah');
  
  @override
  Widget build(BuildContext context) {
     return Navigator(key: _globalKey.......something else);
  }
}

And in my another file b.dart I have import the main.dart. But found the _globalKey has been initialized again and it's not the same with the rendered one.
Then I moved the code above to a new single file and import it in main.dart and b.dart. There are only one _globalKey at this time. So I can use it to do things I want.

I guess maybe the entry point file maybe not recorded in the loaded scripts so the vm load it again? Hope someone else can help me about this.

@zoechi
Copy link
Contributor

zoechi commented Sep 25, 2018

I have import the main.dart

Don't import that from from other files.
Instead move the code to another file and import it into lib/main.dart and other files if needed.

Also don't use relative imports in lib/main.dart

Closing as dup of dart-lang/sdk#33076

@zoechi zoechi closed this as completed Sep 25, 2018
@github-actions
Copy link

github-actions bot commented Sep 1, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants