Skip to content

fix: register material_ui's own MaterialLocalizations delegates - #1164

Closed
chlctt wants to merge 1 commit into
TomBursch:mainfrom
chlctt:fix/material-ui-locale-delegates
Closed

chlctt wants to merge 1 commit into
TomBursch:mainfrom
chlctt:fix/material-ui-locale-delegates

Conversation

@chlctt

@chlctt chlctt commented Sep 29, 2026

Copy link
Copy Markdown

Fixes #1163.

One-liner: also register material_ui's own GlobalMaterialLocalizations.delegates in app.dart, alongside the generated AppLocalizations.localizationsDelegates. material_ui (used everywhere instead of flutter/material) ships its own MaterialLocalizations/CupertinoLocalizations/WidgetsLocalizations, separate from flutter_localizations', and only the latter was wired up.

No import changes needed since material_ui.dart is already imported unaliased in app.dart, so GlobalMaterialLocalizations there resolves to its class.

Tested German (and English, unaffected) in debug and release builds, Chrome/Firefox/Edge. flutter analyze clean, existing test suite passes.

TextField (from `material_ui`, used throughout this app instead of
`flutter/material`) crashes with "Null check operator used on a null
value" in `_TextFieldState._getEffectiveDecoration` for any non-English
locale, on the very first screen with a text field (onboarding, login).

`material_ui` ships its own MaterialLocalizations implementation,
separate from flutter_localizations'. `AppLocalizations.localizationsDelegates`
(the gen-l10n boilerplate) only registers flutter_localizations' delegates,
so material_ui's TextField can never find a MaterialLocalizations for a
locale other than the framework-eager-loaded English one. Debug builds
surface this plainly ("A MaterialLocalizations0 delegate that supports
the de locale was not found"); release/profile builds only show the
generic null-check crash since assertions are stripped.

Fix: also register material_ui's own `GlobalMaterialLocalizations.delegates`.

Found while testing item assignment (this commit's change is unrelated
to and predates that feature) - reproduces identically on unmodified
upstream main (7d50835), independent of GPU rendering, browser engine,
build mode and service-worker caching (all ruled out first). Root cause
confirmed via a source-mapped debug build.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@chlctt

chlctt commented Sep 29, 2026

Copy link
Copy Markdown
Author

Closing - #1161 fixes this exact issue (same root cause, same fix: register material_ui's own GlobalMaterialLocalizations.delegates), opened a day before mine and with a regression test. Sorry for the duplicate, wasn't aware of it when I filed #1163.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TextField crashes on first screen for any non-English locale ("Null check operator used on a null value")

1 participant