Jesway / flutter_translate

Flutter Translate is a fully featured localization / internationalization (i18n) library for Flutter.
MIT License
401 stars 118 forks source link

Flutter Drive not working with flutter_translate #53

Closed AlexBacich closed 3 years ago

AlexBacich commented 4 years ago

Problem: when you test your app with Flutter Drive - app will stay on White screen while trying to init the app.

To be more specific, this call is never executes: final delegate = await LocalizationDelegate.create(fallbackLocale: 'en_US', supportedLocales: ['en_US']);

Root cause of the issue is inside locale_file_service.dart - Future getLocaleContent(String file) method.

This code hangs:

return rootBundle.loadString(file);

This code will work:

static Future<String> getLocaleContent(String file) async
    {
        final ByteData data = await rootBundle.load(file);
        if (data == null) return null;
        return utf8.decode(data.buffer.asUint8List());
    }

Underlying reason for that (if qurious to read) is here: https://github.com/flutter/flutter/issues/24703

bratan commented 4 years ago

Hi, thanks for reporting this issue but as far as I can see this is an issue with flutter_driver and not flutter_translate?

AlexBacich commented 4 years ago

Yes, this I flutter_driver issue, however it hasn't been resolved for years. So to use flutter_translate together with flutter_driver it's possible to add workaround to flutter_translate.

AlexBacich commented 4 years ago

@bratan , will you make this change sooner or later? I would prefer using your library from your repository rather than from fork. Or I can prepare PR if you want.

Yayo-Arellano commented 3 years ago

We have the same issue when running widgets tests, this code will timeout -> final delegate = await LocalizationDelegate.create(fallbackLocale: 'en_US', supportedLocales: ['en_US']);

sourcerebels commented 3 years ago

Having same issue when running widget tests. Please, can you provide an example? Thank you

AlexBacich commented 3 years ago

@bratan , will you make the change?

AlexBacich commented 3 years ago

I have created PR with fix: https://github.com/bratan/flutter_translate/pull/57