Skip to content
Boring Doc
BreakingHigh impactOfficial migration guidesince 1.20.0landed 1.20.0-1.0.pre

TextField requires MaterialLocalizations

Framework · Official source

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)

dart+3−7
Before
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 }
After
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(),
          ),
        ),
      ),
    );
  }
}
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?
TextField requires MaterialLocalizations · Boring Doc