Index
1 2 3 4 5 6 7 |
FlutterError (No MaterialLocalizations found. SliverList widgets require MaterialLocalizations to be provided by a Localizations widget ancestor. The material library uses Localizations to generate messages, labels, and abbreviations. To introduce a MaterialLocalizations, either use a MaterialApp at the root of your application to include them automatically, or add a Localization widget with a MaterialLocalizations delegate. The specific widget that could not find a MaterialLocalizations ancestor was: |
1 2 3 4 5 6 7 8 9 |
const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const CupertinoApp( theme: CupertinoThemeData(brightness: Brightness.light), home: MyHomePage(title: 'Flutter Demo Home Page'), ); } } |
このコードを以下のように修正します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const CupertinoApp( theme: CupertinoThemeData(brightness: Brightness.light), home: MyHomePage(title: 'Flutter Demo Home Page'), //これを追加 localizationsDelegates: [ DefaultMaterialLocalizations.delegate, DefaultCupertinoLocalizations.delegate, DefaultWidgetsLocalizations.delegate, ], ); } } |