From f4a329e8e13e4664c046fefce22c580890ee9a9a Mon Sep 17 00:00:00 2001 From: Gustavo Moreno <131178967+gustamor@users.noreply.github.com> Date: Wed, 8 May 2024 04:58:47 +0200 Subject: [PATCH] Update documentation for Version 5.9.0 (Tests) (#547) * Update documentation for Version 5.9.0 (Tests) This pull request updates the documentation to express the need for using pumpAndSettle() in widget tests to ensure compatibility and proper functioning in version 5.9.0. * Update documentation for Version 5.9.0 (Tests) This pull request updates the documentation to express the need for using pumpAndSettle() in widget tests to ensure compatibility and proper functioning in version 5.9.0. --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index 911ed08..2adca59 100644 --- a/README.md +++ b/README.md @@ -361,3 +361,28 @@ To use second method run: `flutter run --dart-define=method=2` ![effect](demo_en.png) ![tablet effect](demo_tablet_en.png) + + +### Update for Version 5.9.0 (Tests) +Reported as bug in [#515](https://github.com/OpenFlutter/flutter_screenutil/issues/515) + + +In version 5.9.0, to ensure compatibility and proper functioning of your tests, it is crucial to use the method `tester.pumpAndSettle()`; when conducting widget tests that depend on animations or a settling time to complete their state. + +In the previous version, this step was not strictly necessary. However, to maintain consistency in your tests and avoid unexpected errors, it's strongly recommended incorporating await tester.pumpAndSettle(); in your widget tests if you are using version 5.9.0 + +Example usage: +```dart +testWidgets('Should ensure widgets settle correctly', (WidgetTester tester) async { +await tester.pumpWidget( + const MaterialApp( + home: ScreenUtilInit( + child: MyApp(), + ), + ), +); +// Insertion of recommended method to prevent failures +await tester.pumpAndSettle(); +// Continue with your assertions and tests +}); +``` \ No newline at end of file