Skip to content

New annotations for enforcing types #60693

Open
@FMorschel

Description

@FMorschel

I recently had a discussion on Discord about ThemeData.cardTheme that was accepting an Object parameter in the current stable (because it originally accepted CardTheme), and with this issue and PR, CardThemeData was created. In the current master, the old CardTheme can only be used as a Widget (here is the migration guide as a reference).

I'm not sure we have some annotation that could help users in this process. Something like "In a future version, we will stop supporting this type here" to be added to a parameter.

So we could do:

void foo(
  @WillStopSupporting(double, '1.2.3')
  num value
) {
  //Some code
}

I could not find any similar issue, so I opened this one to gather more thoughts.

Something like this could also help (if the logic is reversed) if we want to do something like the above, but only accepting CardTheme and CardThemeData (without union types), so we could say "We only accept these types here" in a way that the user can handle without running the code and failing or going through the docs to find all possibilities.

For visibility @lrhn @srawlins @bwilkerson

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions