1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] How to test localized widgets in flutter?

Discussão em 'Mobile' iniciado por Stack, Outubro 4, 2024 às 04:22.

  1. Stack

    Stack Membro Participativo

    I added l10n to my flutter app as suggested in the flutter docs, it is suggested to get the localizations with a static method like this:

    static DemoLocalizations of(BuildContext context) {
    return Localizations.of<DemoLocalizations>(context, DemoLocalizations);
    }


    This works fine when running the app, but when I try to test my widgets, the returned value is always null.

    Is there any easy way to provide the localizations within the tests?

    For now I'm passing through the localizations via DI, but it is quite an overhead.

    Continue reading...

Compartilhe esta Página