Skip to content

Unsafe GlobalKey subtypes #158876

@nate-thegrate

Description

@nate-thegrate
enum AppKeys implements GlobalKey {
  home,
  search,
  settings;

  GlobalKey get _key => GlobalObjectKey(this);

  @override
  BuildContext? get currentContext => _key.currentContext;

  @override
  State? get currentState => _key.currentState;

  @override
  Widget? get currentWidget => _key.currentWidget;
}

This crashes because the GlobalKey subtype is missing the private _currentElement getter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projecta: annoyanceRepeatedly frustrating issues with non-experimental functionalityframeworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions