This results in a pubspec.yml with the following entries:

Then import the flutter_localizations library and specify
localizationsDelegates and supportedLocales for
your MaterialApp or CupertinoApp:

After introducing the flutter_localizations package
and adding the code above, the Material and Cupertino
packages should now be correctly localized in
one of the 78 supported locales. Widgets should be
adapted to the localized messages, along with
correct left-to-right and right-to-left layout.

Try switching the target platform’s locale to
Spanish (es) and notice that the messages should
be localized.

Apps based on WidgetsApp are similar except that the
GlobalMaterialLocalizations.delegate isn’t needed.

The full Locale.fromSubtags constructor is preferred
as it supports scriptCode, though the Locale default
constructor is still fully valid.