Skip to content
Boring Doc
BreakingHigh impactOfficial migration guidesince 1.17.0landed 1.15.4windowslinux

Adding 'linux' and 'windows' to TargetPlatform enum

Framework · Official source

Two new values were added to the `TargetPlatform` enum that could require additional cases in switch statements that switch on a `TargetPlatform` and don't include a `default:` case.

Original behavior

Prior to this change, the `TargetPlatform` enum only contained four values, and was defined like this:

New behavior

The `TargetPlatform` enum is now defined as:

Who is affected
Applications and packages relying on the previous behaviour or signature. Code that uses TargetPlatform.
Practical impact
Behaviour or API differences that can break builds or change runtime behaviour.
What action should I take?
Follow the official migration guide below, update affected call sites, run `dart fix --apply` where a fix is available, then run your tests.
APIs mentioned:TargetPlatform

Before and after (from the official guide)

dart+6−0
Before
1 void dance(TargetPlatform platform) {
2 switch (platform) {
3 case TargetPlatform.android:
4 // Do Android dance.
5 break;
6 case TargetPlatform.fuchsia:
7 // Do Fuchsia dance.
8 break;
9 case TargetPlatform.iOS:
10 // Do iOS dance.
11 break;
 
 
 
12 case TargetPlatform.macOS:
13 // Do macOS dance.
14 break;
 
 
 
15 }
16 }
After
1 void dance(TargetPlatform platform) {
2 switch (platform) {
3 case TargetPlatform.android:
4 // Do Android dance.
5 break;
6 case TargetPlatform.fuchsia:
7 // Do Fuchsia dance.
8 break;
9 case TargetPlatform.iOS:
10 // Do iOS dance.
11 break;
12+ case TargetPlatform.linux: // new case
13+ // Do Linux dance.
14+ break;
15 case TargetPlatform.macOS:
16 // Do macOS dance.
17 break;
18+ case TargetPlatform.windows: // new case
19+ // Do Windows dance.
20+ break;
21 }
22 }
Raw before / after
void dance(TargetPlatform platform) {
  switch (platform) {
    case TargetPlatform.android:
      // Do Android dance.
      break;
    case TargetPlatform.fuchsia:
      // Do Fuchsia dance.
      break;
    case TargetPlatform.iOS:
      // Do iOS dance.
      break;
    case TargetPlatform.macOS:
      // Do macOS dance.
      break;
  }
}
void dance(TargetPlatform platform) {
  switch (platform) {
    case TargetPlatform.android:
      // Do Android dance.
      break;
    case TargetPlatform.fuchsia:
      // Do Fuchsia dance.
      break;
    case TargetPlatform.iOS:
      // Do iOS dance.
      break;
    case TargetPlatform.linux: // new case
      // Do Linux dance.
      break;
    case TargetPlatform.macOS:
      // Do macOS dance.
      break;
    case TargetPlatform.windows: // new case
      // Do Windows dance.
      break;
  }
}
Official migration guide (excerpt, © The Flutter Authors, CC BY 3.0)

In order to migrate to the new enum, and avoid the analyzer's missing_enum_constant_in_switch error, which looks like:

warning: Missing case clause for 'linux'. (missing_enum_constant_in_switch at [package] path/to/file.dart:111)

or:

warning: Missing case clause for 'windows'. (missing_enum_constant_in_switch at [package] path/to/file.dart:111)

Modify your code as follows:

Code before migration:

void dance(TargetPlatform platform) {
  switch (platform) {
    case TargetPlatform.android:
      // Do Android dance.
      break;
    case TargetPlatform.fuchsia:
      // Do Fuchsia dance.
      break;
    case TargetPlatform.iOS:
      // Do iOS dance.
      break;
    case TargetPlatform.macOS:
      // Do macOS dance.
      break;
  }
}

Code after migration:

void dance(TargetPlatform platform) {
  switch (platform) {
    case TargetPlatform.android:
      // Do Android dance.
      break;
    case TargetPlatform.fuchsia:
      // Do Fuchsia dance.
      break;
    case TargetPlatform.iOS:
      // Do iOS dance.
      break;
    case TargetPlatform.linux: // new case
      // Do Linux dance.
      break;
    case TargetPlatform.macOS:
      // Do macOS dance.
      break;
    case TargetPlatform.windows: // new case
      // Do Windows dance.
      break;
  }
}

Having default: cases in such switch statements isn't recommended, because then the analyzer can't help you find all the cases that need to be handled.

Also, any tests like the one referenced above that set the debugDefaultTargetPlatformOverride are no longer needed for Linux and Windows applications.

Migration assistantAI-generated · grounded in cited sources
AI explanations are not configured
Set AI_PROVIDER (for example to openai-compatible with a local Ollama or LM Studio endpoint) to enable grounded explanations. Everything else on this page works without an AI provider.
Official migration guide·Verified classification (95%)

Listed in the official breaking-changes index (docs.flutter.dev/release/breaking-changes).

An official announcement or migration guide documents an intended behaviour or API change. A verified source change (git diff) shows code changed but does not by itself prove a public API is breaking. AI interpretations are labelled and never used to classify a change.

Source commit
b3045439b7c0
Source last updated
Oct 21, 2026
Last synchronized
Oct 21, 2026
Publication status
published
Publication history
  • Oct 21, 2026, 8:31 PM: new → published (ingestion) — Backed by an official breaking-change/migration guide.
AI explanationAI-generated · grounded in cited sources
AI explanations are not configured
Set AI_PROVIDER (for example to openai-compatible with a local Ollama or LM Studio endpoint) to enable grounded explanations. Everything else on this page works without an AI provider.
Was this useful?