From 0f7bad853c01d7a79145cd2cc06950679da40917 Mon Sep 17 00:00:00 2001 From: Sebastian Chilcott Date: Tue, 29 Sep 2026 09:21:23 +0200 Subject: [PATCH] fix: register material_ui's own MaterialLocalizations delegates 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 (7d508352), 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 --- kitchenowl/lib/app.dart | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kitchenowl/lib/app.dart b/kitchenowl/lib/app.dart index cb1a23d86..0c97a5321 100644 --- a/kitchenowl/lib/app.dart +++ b/kitchenowl/lib/app.dart @@ -219,8 +219,18 @@ class _AppState extends State with WidgetsBindingObserver { ), onGenerateTitle: (BuildContext context) => AppLocalizations.of(context)!.appTitle, + // `material_ui` (used throughout this app instead of + // `flutter/material`) ships its own MaterialLocalizations + // implementation, separate from flutter_localizations'. + // AppLocalizations.localizationsDelegates only registers + // the latter, so material_ui's TextField can't find a + // MaterialLocalizations for any non-English locale and + // crashes with "Null check operator used on a null value" + // in _TextFieldState._getEffectiveDecoration. Register + // material_ui's own delegates too. localizationsDelegates: AppLocalizations.localizationsDelegates + + GlobalMaterialLocalizations.delegates + [ LocaleNamesLocalizationsDelegate(), ],