Instances of `TextField` must have a `MaterialLocalizations` present in the widget tree. Trying to instantiate a `TextField` without the proper localizations results in an assertion such as the following:
Original behavior
If the `TextField` descends from a `MaterialApp`, the `DefaultMaterialLocalizations` is already instantiated and won't require any changes to your existing code.
New behavior
Not stated in the source.
- Who is affected
- Applications and packages relying on the previous behaviour or signature. Code that uses TextField, MaterialLocalizations, MaterialApp and related APIs.
- 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.
Before and after (from the official guide)
| 1 | import 'package:material_ui/material_ui.dart'; | |
| 2 | ||
| 3 | void main() => runApp(Foo()); | |
| 4 | ||
| 5 | class Foo extends StatelessWidget { | |
| 6 | @override | |
| 7 | Widget build(BuildContext context) { | |
| 8 | − | return MediaQuery( |
| 9 | − | data: const MediaQueryData(), |
| 10 | − | child: Directionality( |
| 11 | − | textDirection: TextDirection.ltr, |
| 12 | − | child: Material( |
| 13 | − | child: TextField(), |
| 14 | − | ), |
| 15 | ), | |
| 16 | ); | |
| 17 | } | |
| 18 | } |
| 1 | import 'package:material_ui/material_ui.dart'; | |
| 2 | ||
| 3 | void main() => runApp(Foo()); | |
| 4 | ||
| 5 | class Foo extends StatelessWidget { | |
| 6 | @override | |
| 7 | Widget build(BuildContext context) { | |
| 8 | + | return MaterialApp( |
| 9 | + | home: Material( |
| 10 | + | child: TextField(), |
| 11 | ), | |
| 12 | ); | |
| 13 | } | |
| 14 | } |
Raw before / after
import 'package:material_ui/material_ui.dart';
void main() => runApp(Foo());
class Foo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MediaQuery(
data: const MediaQueryData(),
child: Directionality(
textDirection: TextDirection.ltr,
child: Material(
child: TextField(),
),
),
);
}
}import 'package:material_ui/material_ui.dart';
void main() => runApp(Foo());
class Foo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Material(
child: TextField(),
),
);
}
}Official migration guide (excerpt, © The Flutter Authors, CC BY 3.0)
If you see an assertion error, make sure that
locale information is available to the TextField,
either through an ancestor MaterialApp
(that automatically provides Localizations), or
by creating your own Localizations widget.
Code before migration:
import 'package:material_ui/material_ui.dart';
void main() => runApp(Foo());
class Foo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MediaQuery(
data: const MediaQueryData(),
child: Directionality(
textDirection: TextDirection.ltr,
child: Material(
child: TextField(),
),
),
);
}
}Code after migration (Providing localizations using the MaterialApp):
import 'package:material_ui/material_ui.dart';
void main() => runApp(Foo());
class Foo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Material(
child: TextField(),
),
);
}
}Code after migration (Providing localizations via the Localizations widget):
import 'package:material_ui/material_ui.dart';
void main() => runApp(Foo());
class Foo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Localizations(
locale: const Locale('en', 'US'),
delegates: const <LocalizationsDelegate<dynamic>>[
DefaultWidgetsLocalizations.delegate,
DefaultMaterialLocalizations.delegate,
],
child: MediaQuery(
data: const MediaQueryData(),
child: Directionality(
textDirection: TextDirection.ltr,
child: Material(
child: TextField(),
),
),
),
);
}
}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.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.
- Official migration guide
- Localizations
- PR 58831: Assert debugCheckHasMaterialLocalizations on TextField
- 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_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.