Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors in Delegate when using cs_CZ #14

Closed
vladaman opened this issue Jun 7, 2021 · 1 comment
Closed

Errors in Delegate when using cs_CZ #14

vladaman opened this issue Jun 7, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@vladaman
Copy link

vladaman commented Jun 7, 2021

The app crashes with following error. I used string.cs_CZ.i18n.json file and also LocaleSettings.setLocaleRaw("cs_CZ");

I/flutter ( 5843): ════════
I/flutter ( 5843): Warning: This application's locale, cs_CZ, is not supported by all of its
I/flutter ( 5843): localization delegates.
I/flutter ( 5843): > A MaterialLocalizations delegate that supports the cs_CZ locale was not found.
I/flutter ( 5843): See https://flutter.dev/tutorials/internationalization/ for more
I/flutter ( 5843): information about configuring an app's locale, supportedLocales,
I/flutter ( 5843): and localizationsDelegates parameters.
I/flutter ( 5843): ════════
I/flutter ( 5843): 

======== Exception caught by widgets library =======================================================
The following assertion was thrown building AppBar(dirty, dependencies: [_LocalizationsScope-[GlobalKey#0dcea]], state: _AppBarState#471e0):
No MaterialLocalizations found.

AppBar 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: AppBar
  dirty
  dependencies: [_LocalizationsScope-[GlobalKey#0dcea]]
  state: _AppBarState#471e0
The ancestors of this widget were: 
  : Scaffold
    dependencies: [_InheritedTheme, MediaQuery, _EffectiveTickerMode, _LocalizationsScope-[GlobalKey#0dcea], Directionality, UnmanagedRestorationScope, _ScaffoldMessengerScope]
    state: ScaffoldState#1a26c(tickers: tracking 2 tickers)
  : MyHomePage
    dependencies: [MediaQuery]
    state: _MyHomePageState#24804
  : MaterialApp
    state: _MaterialAppState#c0250
  : MyApp
  : _InheritedLocaleData
  : TranslationProvider-[LabeledGlobalKey<_TranslationProviderState>#7e437]
    state: _TranslationProviderState#794d5
  ...
The relevant error-causing widget was: 
@Tienisto
Copy link
Member

Tienisto commented Jun 7, 2021

Hi,

it seems that I forgot to mention that you need flutter_localizations dependency in order to use the delegates.
I will add this to the README.

# pubspec.yaml
dependencies:
  flutter_localizations:
    sdk: flutter
import 'package:flutter_localizations/flutter_localizations.dart';

MaterialApp(
  localizationsDelegates: const [
    GlobalMaterialLocalizations.delegate,
    GlobalWidgetsLocalizations.delegate,
    GlobalCupertinoLocalizations.delegate,
  ],
  supportedLocales: LocaleSettings.supportedLocales,
)

@Tienisto Tienisto added the bug Something isn't working label Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants