Questions tagged [widget-test-flutter]

100 questions
2
votes
1 answer

How to tap all items of a list or a grid in a Flutter widget test?

In my Flutter widget tests I want to tap all (or first n) items in a list or grid view. I already came up with a solution and although it seems to work, it looks overly complicated to find the tap target again by key: for (final element in…
RobDil
  • 4,036
  • 43
  • 52
2
votes
1 answer

Widget Test Doesn't Fire DropdownButton onChanged

I have a widget test that taps an item in the DropdownButton. That should fire the onChanged callback but it doesn't. Here is the test code. The mock is Mockito. void main() { //Use a dummy instead of the fake. The fake does too much stuff …
Christian Findlay
  • 6,770
  • 5
  • 51
  • 103
2
votes
1 answer

Is it possible to screenshot a widgetTest?

I am new to Flutter and I feel like if I could see what the widgetTest is "rendering", as a debug method, things could be a bit easier. I don't fully understand at the moment the mechanics of the widgetTest, but I am wondering if it is possible to…
Fabio S.
  • 460
  • 7
  • 22
2
votes
1 answer

Simulate hover in flutter test

I am working on a flutter web project and I have a widget I would like to write tests about. This widget is using a MouseRegion which does some actions when it is hovered or not by the user. As an example: class MyWidget extends StatefulWidget { …
Valentin Vignal
  • 6,151
  • 2
  • 33
  • 73
2
votes
2 answers

How to make widget testing while using http.post

I'm trying to use widget test for my project and test works fine till reach the point I use an http request in the actual page and it ,I think, ignore the request final account = await http.post( 'http://10.0.2.2:5000/LogIn', …
2
votes
1 answer

Flutter mocking a ChangeNotifierProvider and setting provider values

Ok, bear with me as I am just beginning to learn widget testing. I have a MainAppBar widget that has an AuthProvider above it in the widget tree, which is necessary to do an auth check and subsequent logout if a user is in fact authenticated. This…
Matt Larsuma
  • 1,456
  • 4
  • 20
  • 52
2
votes
0 answers

Widget test not receiving taps

I'm trying to test the callback of a custom widget I have, it's really a simple save icon button but the test is failing as the widget isn't detecting the tap. The test: testWidgets( 'Save icon callback', (WidgetTester tester) async { …
Hadi
  • 119
  • 10
1
vote
1 answer

How to test an AnimatedIcon in Flutter

I want to do a test that allows me to verify if my widget is showing the AnimatedIcon that I provide, as well as to know if the animation is working (changing the icon in an animated way), the problem is that I can't find the way to do it. Is there…
devblock
  • 113
  • 7
1
vote
0 answers

Flutter test widgets, go to another screen failed

I'm writting my very first widget tests in dart. I have to check if clicking on a button bring us to the next screen. What am I doing wrong here? testWidgets('Tapping staring the meeting button leads to conference screen', (widgetTester) async { …
Yunnane
  • 85
  • 9
1
vote
1 answer

Undefined name Patrol in Flutter

Even though I added dependency correctly, it is unable to find the Patrol class inside the dependencies. The correct implementation is shown in this link: https://pub.dev/packages/patrol
1
vote
0 answers

EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK - WindowsException was thrown running a test: Error 0x00000000 - whilst running a widget test

This is the error message: The following WindowsException was thrown running a test: Error 0x00000000: The operation completed successfully. I am trying to pumpWidget using a ChangeNotifierProvider. await tester.pumpWidget( …
MDias
  • 41
  • 5
1
vote
0 answers

ButtonStyle shape value is null in widget test, despite working correctly in app

I have a button which has CircleBorder set as shape, it works correctly when the app runs, but the widget testing case I've implemented returns null. This is the built widget inside my build method: TextButton( style: (style ??…
adi
  • 417
  • 4
  • 25
1
vote
0 answers

flutter -How to test if a specific lottie animation is being rendered in widget test

Hi I have a LottieBuilder wichh loads an animation via json from assets. LottieBuilder.asset( 'assets/animations/no_wifi_animation.json', repeat: true), i want to a write a test to determine that the specific json animation…
R3HP
  • 470
  • 4
  • 13
1
vote
2 answers

flutter GenerateMocks is not generated mock class

I am trying to use @GenerateMocks on my test method, This is my dev dependancies: dev_dependencies: test: any flutter_test: sdk: flutter flutter_driver: sdk: flutter integration_test: sdk: flutter flutter_lints: ^1.0.4 …
1
vote
2 answers

Widget not rebuilding on notifyListeners during test

I'm trying to build a Widget test for a screen that's using the Provider framework. The app has 1 screen with 1 button, when I tap the button it will trigger a function to update the state. Once the state is updated a string with the key…
Rutger Huijsmans
  • 2,330
  • 2
  • 30
  • 67