Flutter build fails: Method not found 'FallThroughError'
Error: Method not found: 'FallThroughError'.Short answer
FallThroughError was removed from the Dart core libraries in Dart 3. The build now fails wherever code still names it. That is almost always an old package, such as an outdated Firebase plugin. Upgrade the dependencies. If the file is your own, finish each non-empty switch case with break, return, continue or throw.
Fix it fast
1Find out which cause you have
Read the path in the error. A path under .pub-cache means a dependency; a path under lib/ means your own code.
flutter pub outdated flutter build apk --debug 2>&1 | grep -B2 -A2 FallThroughError2Match what you see, then jump to its fix
What does the error look like?
Error: Method not found: 'FallThroughError'.throw FallThroughError();
Cause 1 of 2
A dependency written for Dart 2 still throws FallThroughError
1Check
List which packages have a newer version that your constraints keep out.
flutter pub outdated2Fix
Upgrade the dependencies, and if that is not enough, allow major version upgrades, which also rewrites the constraints in pubspec.yaml.
flutter pub upgrade
flutter pub upgrade --major-versions3Verify
The build passes the compile step and the error is gone.
flutter analyze
flutter build apk --debugConfirmed by dart.dev
Cause 2 of 2
Your own code throws it from a switch
1Check
Find the throw. Dart 3 removed the class, and a non-empty case must end in a jump.
grep -rn "FallThroughError" lib/2Fix
Delete the throw and end the case with break, continue, return or throw. Empty cases may fall into the next one to share a body.
switch (command) {
case 'start':
run();
break;
case 'a':
case 'b':
handleAB();
return;
}3Verify
The analyzer has no error and the behaviour per case is unchanged.
dart analyzeConfirmed by dart.dev
How do I stop it coming back?
- Run flutter pub outdated before a Flutter or Dart upgrade.
- Replace unmaintained packages that have no Dart 3 release.
- Keep Flutter and the Firebase plugins on supported, current versions.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- Qist BazaarA buy-now-pay-later marketplace built from a blank repo, now past 100K downloads on Google Play.
- SessionBirdAn omnichannel engagement suite in Flutter: campaigns, chatbot, tickets, analytics and live calling.
Related fixes
Mobile apps
AudioCache has no play method after updating audioplayers
The method 'play' isn't defined for the type 'AudioCache'.
Since audioplayers 1.0, AudioCache only turns asset files into local files and caches them.
2 causes, each with a fixMobile apps
Flutter Bloc throws that emit was called after the event handler completed
emit was called after an event handler completed normally.
Each on<Event> handler gets its own Emitter, and it stops working the moment the handler's returned Future completes.
2 causes, each with a fixMobile apps
analysis_options.yaml: the URI it includes can't be found
include_file_not_found
The analyzer reports include_file_not_found when the file named after include: in analysis_options.yaml does not resolve.
2 causes, each with a fixMobile apps
Dart error: the body might complete normally and return null for a non-nullable type
body_might_complete_normally
Dart found a path through your function or callback that reaches the closing brace without a return.
3 causes, each with a fixMobile apps
Dart throws ConcurrentModificationError while looping over a list
ConcurrentModificationError
Dart throws this when a collection changes size while something iterates it.
2 causes, each with a fixMobile apps
Dart cannot turn a compact timestamp like 20201101153000 into a DateTime
FormatException: Invalid date format
DateTime.parse accepts a subset of ISO 8601, and a time part must be introduced by T or a space.
2 causes, each with a fix