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

UI is partially re-created after calling setNewLanguage. #27

Closed
TaranenkoDenis opened this issue Nov 5, 2021 · 0 comments
Closed

UI is partially re-created after calling setNewLanguage. #27

TaranenkoDenis opened this issue Nov 5, 2021 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@TaranenkoDenis
Copy link

TaranenkoDenis commented Nov 5, 2021

We again ran into the problem that after calling method setNewLanguage(context, newLanguage: newLang, restart: true) part of the UI is updated with new translates, but part is not, including the previous screen in the back stack. If I open a new screen, then it is displayed with a new translation. We managed to fix the problem some time ago, but now it has reappeared.

A rough sketch of the creation of LocalizedApp:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  final locale = Preferences().language;
  await translator.init(
    language: locale,
    languagesList: ['en', 'ru'],
    assetsDirectory: 'assets/i18n/',
  );

  runZonedGuarded(
    () => runApp(
      LocalizedApp(
        child: DependenciesWidget( // Providers
          environment: environment,
          child: ConfiguratorWidget( // BlocListeners without using UI staff
              child: BlocListener<LocalizationBloc, LocalizationState>(
                listener: (context, state) {
                  final localeCode = state.language.localizationPackageValue;
                  var newLang = localeCode.length > 2
                      ? localeCode.substring(0, 2)
                      : localeCode;
                  translator.setNewLanguage(
                    context,
                    newLanguage: newLang,
                    restart: true,
                  );
                },
                child: MaterialAppWrapperWidget(),
              ),
          ),
        ),
      ),
    ),
    FirebaseCrashlytics.instance.recordError,
  );
}
  • flutter doctor
    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel stable, 2.0.5, on macOS 11.6 20G165 darwin-x64, locale
    en-GB)
    [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    [✓] Xcode - develop for iOS and macOS
    [✓] Chrome - develop for the web
    [!] Android Studio (version 2020.3)
    ✗ Unable to find bundled Java version.
    [✓] Connected device (2 available)
@msayed-net msayed-net self-assigned this Nov 14, 2021
@msayed-net msayed-net added the bug Something isn't working label Nov 14, 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