Skip to content

Remove string literal keys from Flutter #171249

@justinmc

Description

@justinmc

Including a Key with a String literal (e.g. Key(dismissible')) in the framework carries the risk of colliding with a user's Key with the same value in their application code. For this reason, we should see if we can remove this pattern from the codebase.

With a quick grep in the codebase I see at least three targets for removal:

packages/flutter/lib/src/material/date_picker.dart
2127:    const Key sliverAfterKey = Key('sliverAfterKey');

packages/flutter/lib/src/material/stepper.dart
901:              key: Key('line$i'),

packages/flutter/lib/src/material/snack_bar.dart
826:        key: const Key('dismissible'),

Can we replace these string literal keys with something else?

Follow-up to #170952.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: proposalA detailed proposal for a change to Flutterf: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.refactorImproving readability/efficiency without behavioral changesteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy