It's work for me :)
```dart
Future<AppLocalizations> getLocalizationsUnderTests(
WidgetTester t,
) async {
late AppLocalizations result;
await t.pumpWidget(
MaterialApp(
localizationsDelegates: const <LocalizationsDelegate>[
GlobalCupertinoLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
AppLocalizations.delegate,
],
supportedLocales: AppLocalizations.supportedLocales,
locale: const Locale('en'),
home: Material(
child: Builder(
builder: (BuildContext context) {
result = AppLocalizations.of(context);
debugPrint('[DEBUG]: locale: $result');
// The builder function must return a widget.
return const Placeholder();
},
),
),
),
);
await t.pumpAndSettle();
return result;
}
```
It's modifiable of https://stackoverflow.com/questions/52463714/how-to-test-localized-widgets-in-flutter/73248298#73248298
U need to add after return `await t.pumpAndSettle();`
Full code:
```dart
Future<AppLocalizations> getLocalizationsUnderTests(
WidgetTester t,
) async {
late AppLocalizations result;
await t.pumpWidget(
MaterialApp(
localizationsDelegates: const <LocalizationsDelegate>[
GlobalCupertinoLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
AppLocalizations.delegate,
],
supportedLocales: AppLocalizations.supportedLocales,
locale: const Locale('en'),
home: Material(
child: Builder(
builder: (BuildContext context) {
result = AppLocalizations.of(context);
debugPrint('[DEBUG]: locale: $result');
// The builder function must return a widget.
return const Placeholder();
},
),
),
),
);
await t.pumpAndSettle();
return result;
}
```