Repository navigation
Description
Currently both material_ui and cupertino_ui implement their own localization interfaces, and look up localizations by matching against those exact types:
material_ui:MaterialLocalizations,debugCheckHasMaterialLocalizationscupertino_ui:CupertinoLocalizations,debugCheckHasCupertinoLocalizations
However, if an app (see demo below) is configured to provide localizations with flutter_localizations, then cupertino_ui/material_ui are not able to reconcile the localizations, failing with the debugCheckHas[Cupertino/Material]Localizations assert in debug-mode, or a runtime error in profile/release mode.
flutter_localizations must wait for material_ui/cupertino_ui to be published before it can be updated to depend on material_ui and cupertino_ui instead of flutter/material and flutter/cupertino. A potential long-term solution here is to move flutter_localizations into flutter/packages along with the Material and Cupertino libraries.
For now, we are splitting test cases that depend on flutter_localization out of material_ui and cupertino_ui and moving them to https://github.com/flutter/flutter/tree/master/packages/flutter_localizations
demo app
import 'package:flutter_localizations/flutter_localizations.dart';
// import 'package:flutter/material.dart'; // WORKS
import 'package:material_ui/material_ui.dart'; // DOES NOT WORK
void main() {
runApp(const DemoApp());
}
class DemoApp extends StatelessWidget {
const DemoApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
locale: const Locale('es'), // Spanish
supportedLocales: const <Locale>[Locale('en'), Locale('es')],
localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
home: const HomeScreen(),
);
}
}
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('material_ui Localization Demo')),
body: Center(
child: ElevatedButton(
onPressed: () {
showTimePicker(context: context, initialTime: TimeOfDay.now());
},
child: const Text('Show Time Picker'),
),
),
);
}
}Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
justinmc commentedon Jun 30, 2026
Thanks for creating an issue for this!
[material_ui] Enable `time_picker_test` (#12061)
elliette commentedon Jul 1, 2026
Adding this as well so it doesn't get lost:
I was curious what re-exporting
Material/CupertinoLocalizationsin thematerial_ui/cupertino_uiwould look like in practice (see code diffs below).Unfortunately if we want to import
Material/CupertinoLocalizationsfromflutter_localizationsand re-export them inmaterial/cupertino_ui, we will also need to import all the classes used as type signatures inMaterial/CupertinoLocalizations, which include those defined in the design language packages (likeScriptCategory). This approach effectively breaks decoupling, since it introduces dependencies on the SDK's Material/Cupertino libraries inmaterial/cupertino_ui. However, doing so does unblock apps usingflutter_localizationsto migrate tomaterial/cupertino_ui.[material_ui, cupertino_ui] Localizations (#12119)
github-actions commentedon Jul 29, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.