Flutter synthetic-package Removed: How to Fix Your l10n.yaml (2026)
Quick answer: Newer Flutter versions deprecate and remove the synthetic package that used to host generated localizations (the package:flutter_gen/gen_l10n/app_localizations.dart import). To fix the breaking change, set synthetic-package: false in l10n.yaml, add an output-dir (e.g. lib/l10n), and update your imports to the real generated file path. You can build a correct config in seconds with the free l10n.yaml generator.
🔧 Generate a correct l10n.yaml instantly
✅ Sets synthetic-package: false for you |
✅ Adds the right output-dir |
| ✅ Presets for app, web & multi-locale | ✅ Copy or download l10n.yaml |
→ Open the l10n.yaml Generator
What changed, and why your build broke
For years, flutter gen-l10n wrote your AppLocalizations class into a hidden synthetic package named flutter_gen. You imported it like this:
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
This was convenient but fragile — IDEs couldn't always resolve it, it broke with some build setups, and it hid generated code you couldn't inspect. The Flutter team deprecated the synthetic package and is removing it. If you upgraded Flutter and now see errors like:
Target of URI doesn't exist: 'package:flutter_gen/gen_l10n/app_localizations.dart'
The synthetic package output feature is deprecated / has been removed.
…this migration is what you need.
The fix in 3 steps
Step 1 — Update l10n.yaml
Turn off the synthetic package and tell gen-l10n where to write the real file:
arb-dir: lib/l10n
output-dir: lib/l10n
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
synthetic-package: false
nullable-getter: false
Not sure which options you need? The l10n.yaml Generator builds this for you with sensible defaults and explains every line.
Step 2 — Keep generate: true in pubspec.yaml
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
intl: any
flutter:
generate: true
Step 3 — Fix your imports
Replace the old synthetic import with the real path (relative to your project). If you generated into lib/l10n:
// ❌ Old — synthetic package
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
// ✅ New — real generated file
import 'package:your_app/l10n/app_localizations.dart';
// or a relative import:
import 'l10n/app_localizations.dart';
Then regenerate:
flutter clean
flutter pub get
flutter gen-l10n
Your AppLocalizations class now lives in lib/l10n/app_localizations.dart where you can actually open it.
Before vs after
| Synthetic package (old) | Real output-dir (new) | |
|---|---|---|
l10n.yaml |
synthetic-package: true (default) |
synthetic-package: false + output-dir |
| Import | package:flutter_gen/gen_l10n/... |
package:your_app/l10n/... |
| File visible in repo? | No | Yes |
| IDE resolution | Sometimes flaky | Reliable |
| Future-proof | Removed | Supported |
Common pitfalls
- Forgot
output-dir— gen-l10n falls back toarb-dir, which is fine, but be explicit so imports are predictable. - Stale build — always run
flutter cleanafter the switch; old synthetic artifacts can linger. - Wrong package name in the import — it must match the
name:in yourpubspec.yaml. - Committing generated code or not — either is valid; just be consistent across the team.
Frequently asked questions
Why was synthetic-package removed in Flutter?
The synthetic flutter_gen package hid generated localization code and caused IDE resolution and build issues. Flutter now generates into a real directory you control, which is more reliable and inspectable. Set synthetic-package: false and an output-dir.
What do I replace the flutter_gen import with?
Import the real generated file. If you set output-dir: lib/l10n, use import 'package:your_app/l10n/app_localizations.dart'; (replace your_app with your pubspec name), or a relative import.
Do I still need flutter_localizations and intl?
Yes. Keep flutter_localizations (SDK) and intl in dependencies, and generate: true under the flutter: section so gen-l10n runs on each build.
How do I generate a correct l10n.yaml?
Use the l10n.yaml Generator — toggle the options you need and copy a ready-to-use config that already sets synthetic-package: false.
Stop fighting localization config
FlutterLocalisation manages your .arb files, AI-fills missing translations, syncs your whole team, and pushes updates over-the-air — so config changes like this don't derail your release. Start free →
Related tools & guides: