Flutter: Undefined name 'AppLocalizations'. Try correcting the name to one that is defined, or defining the name

3.9k views Asked by At

Flutter Default Localizations isn't work when I use GetX Statemanagement. It show me a error like

Undefined name 'AppLocalizations'.
Try correcting the name to one that is defined, or defining the name.

enter image description here

How Can I fixed this ?

4

There are 4 answers

0
Bihim On

Please add these dependencies on pubspec.yaml

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter
  intl: ^0.17.0

More information here

0
Mehran Sahandi Far On

for me the problem solved by

This creates a pubspec.yml file with the following entries:

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter
  intl: any

then pub get

0
Shir Agha Zeyarmal On

Add it in dependency -> generate:true;

0
Jean-Pierre Schnyder On

I had this problem in a Flutter widget test code. The solution illustrated by the images below is applicable to the Flutter app code as well. Note that my Flutter app is conform to the MVVM architecture using Provider, the reason why MultiProvider is used. The code of the project is available on GitHub My AudioLearn prototype project. Note that the real project will be referenced in the readme file and will available as well since earning money is not what motivates me to develop this application.

Solution in widget test code 1

Solution in widget test code 2

Solution in widget test code 3

Solution in widget test code 4