CopyPastor

Detecting plagiarism made easy.

Score: 1.8020544534517546; Reported for: String similarity, Exact paragraph match Open both answers

Possible Plagiarism

Reposted on 2023-10-10
by ziqq

Original Post

Original - Posted on 2023-10-10
by ziqq



            
Present in both answers; Present only in the new answer; Present only in the old answer;

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; } ```

        
Present in both answers; Present only in the new answer; Present only in the old answer;