Skip to content

Loaded scripts issue? #21993

Closed
Closed
@haoguo

Description

@haoguo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions