Flutter build fails with: No named parameter with the name 'displayLarge'
Error: No named parameter with the name 'displayLarge'.Short answer
The package was written for a newer Flutter than the one installed. Since the 2021 Material text style names (displayLarge, headlineMedium, bodySmall and so on) are used inside the package, an older SDK has no such TextTheme parameter. Upgrade Flutter to the version the package asks for, or pin the package to an older release.
Fix it fast
1Find out which cause you have
Print the Flutter version you actually build with, and compare it with the minimum that the package release lists in its changelog.
flutter --version flutter pub deps | grep google_fonts2Match what you see, then jump to its fix
- 1
The error points inside a hosted package under .pub-cache, not into your own lib/ folderThe Flutter SDK is older than the package release needsFix - 2
The project is locked to an older Flutter version (a team or CI constraint) and the package was just upgradedYou cannot upgrade Flutter yet, so the package has to go backFix
- 1
What does the error look like?
Error: No named parameter with the name 'displayLarge'.
Cause 1 of 2
The Flutter SDK is older than the package release needs
1Check
Each google_fonts release states its minimum Flutter version in the changelog on pub.dev (for example 6.2.1 needs Flutter 3.19.2). Read the changelog entry for the version in your pubspec.lock and compare it with the output of flutter --version.
flutter --version
grep -A3 "google_fonts:" pubspec.lock2Fix
Upgrade the SDK on your current channel. Then fetch packages again.
flutter upgrade
flutter pub get3Verify
The analyzer no longer reports the missing parameter and the app builds.
flutter analyze
flutter runConfirmed by pub.dev
Cause 2 of 2
You cannot upgrade Flutter yet, so the package has to go back
1Check
The changelog shows that release 2.3.0 switched the package to the 2021 text style names, and that each later release raises the Flutter minimum. A release before 2.3.0 does not use the new names.
grep -n "google_fonts" pubspec.yaml2Fix
Constrain the package to a release that your Flutter version can compile, then resolve again.
# pubspec.yaml
dependencies:
google_fonts: ">=1.1.0 <2.3.0"3Verify
Dependency resolution succeeds and the build gets past the kernel snapshot step.
flutter pub get
flutter build apk --debugConfirmed by pub.dev
How do I stop it coming back?
- Read the changelog entry for the Flutter minimum before you bump a package across several releases.
- Pin the Flutter version for the team and for CI, so every machine compiles the same SDK.
- Commit pubspec.lock for apps so a fresh checkout resolves the same package versions.
- Use the 2021 text style names (displayLarge, bodyMedium) in your own TextTheme code.
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