Skip to content

Quick assist for converting a switch statement in which each case just assigns to a variable #51836

Closed
@srawlins

Description

@srawlins

It'd be great to offer to convert this to a Dart 3.0 switch expression.

For example:

String f(Color color) {
  String result;
  switch (color) {
    case Color.blue:
      result = 'blue';
      break;
    case Color.red:
      throw 'Unsupported';
  }
  return result;
}

could be converted to:

String f(Color color) {
  String result;
  result = switch (color) {
    case Color.blue => 'blue',
    case Color.red => throw 'Unsupported'
  }
  return result;
}

CC @bwilkerson @pq @mit-mit @stereotype441

Metadata

Metadata

Assignees

No one assigned

    Labels

    devexp-quick-fixIssues with analysis server (quick) fixeslegacy-area-analyzerUse area-devexp instead.type-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions