Jesway / flutter_translate

Flutter Translate is a fully featured localization / internationalization (i18n) library for Flutter.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Flutter Drive not working with flutter_translate

AlexBacich opened this issue · comments

commented

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:
flutter/flutter#24703

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

commented

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.

commented

@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.

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

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

commented

@bratan , will you make the change?

commented

I have created PR with fix: #57