Questions tagged [widget-test-flutter]

100 questions
13
votes
5 answers

error `pumpAndSettle timed out` MAYBE due to riverpod

I'm stuck with a widget test and I could use some help to reproduce the behavior please run the code sample below import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'home_page.dart'; void main() =>…
Francesco Iapicca
  • 2,618
  • 5
  • 40
  • 85
11
votes
5 answers

How can I find `FlatButton.icon` in a Flutter tests?

In my app I create a button using FlatButton.icon (Flutter docs). Now I'm trying to find the button during testing. I've tried find.byType(MaterialButton); // -> zero widgets find.byType(FlatButton); // -> zero widget The strange thing is that I…
0p3r4t0r
  • 623
  • 5
  • 13
8
votes
3 answers

Tap() in widget test showing warning in flutter

await widgetTester.tap(find.byType(ElevatedButton)); shows warning : Maybe the widget is actually off-screen, or another widget is obscuring it, or the widget cannot receive pointer events.
Arun Kenjila
  • 129
  • 1
  • 9
6
votes
2 answers

How to check widget is visible when testing

In my case, when I using ExpansionPanelList, I need to check widget inside panel is visible. If not visible, tester.tap(find.text('More Info')) will throw exception: Warning: A call to tap() with finder "exactly one widget with text "More Info"…
呂學洲
  • 1,123
  • 8
  • 19
6
votes
2 answers

Finding a widget inside of a CustomScrollView in Flutter test

I have encountered an error when trying to test my Flutter App. I have a custom widget that is at the bottom (out of the first viewport) of a CustomScrollView widget. In my test, I want to verify that it is actually there. I have already tried to…
6
votes
2 answers

Why pumpAndSettle timed out when assigning Future function like this

In my State class I have declared a future: Future _testFuture; and assign it in the initState like this: super.initState(); _testFuture = Future(() async { await Future.value(1); //can be any computation }); and use it in the…
Calvin Gonsalves
  • 1,738
  • 11
  • 15
6
votes
1 answer

How do I run Flutter widget tests with shadows enabled?

I'd like to render some of my Flutter golden files with shadows. How can I accomplish that? Shadows are disabled by default: https://github.com/flutter/flutter/blob/master/packages/flutter_test/lib/src/binding.dart#L942
SuperDeclarative
  • 1,609
  • 4
  • 18
  • 32
6
votes
3 answers

Flutter widget test fails for InkWell tap

I have a widget test like this, I can find the widget with actionKey, but the tapping test fails and tapped value is false after tester.tap(...), what is wrong with my test? testWidgets('some test', (WidgetTester tester) async { final UniqueKey…
Hamed
  • 5,867
  • 4
  • 32
  • 56
5
votes
2 answers

Flutter Widget testing with HttpClient

I am trying to write a widget test for a screen, not the main app. It's my first time writing a widget test and I couldn't find a proper solution for the issue. I don't know how to write a proper test for this one. I tried to write a simple widget…
Gurjit Singh
  • 131
  • 2
  • 10
5
votes
1 answer

How to implement widget tests by using MockBloc?

I'm trying to implement a Widget Test in order to test a login form. This test depends on a bloc which I'm mocking by using MockBloc. However, it throws the following error: ══╡ EXCEPTION CAUGHT BY FLUTTER TEST…
5
votes
2 answers

Flutter Widget Test wait for animation

I have a widget test similar to: testWidgets('Widget test', (WidgetTester tester) async { provideMockedNetworkImages(() async { final widget = MyWidget(); await WidgetTestFunctions.pumpWidgetTest( tester, widget, ); …
notarealgreal
  • 734
  • 16
  • 29
5
votes
1 answer

Flutter: readAsBytes/readAsString in widget tests

I am trying to test a StatefulWidget with the following onPressed function. floatingActionButton: FloatingActionButton( child: Icon(Icons.camera_alt), onPressed: () async { try { final filename =…
baby.zard
  • 194
  • 1
  • 10
5
votes
1 answer

How check if text its obscured on InputField

Im trying to test if password its obscured, this is how far I go, but seems like flutter can read a text even if it is obscured. testWidgets('password must be hidden', (WidgetTester tester) async { await…
4
votes
1 answer

Flutter Widget Test passes on device but not without one

I have a widget that displays a list of data from an api and I'm trying to write tests for it's various states starting with it's empty state. Currently my test pumps the widget in question, the widget makes a network call which I'm mocking and then…
martinseal1987
  • 1,862
  • 8
  • 44
  • 77
4
votes
0 answers

Accessing GetXController in a Flutter widget test

I am in the process of implementing a widget test for a login screen. In the app, the login screen offers the user a switch control to set preferences for biometrics if they are available on the device. We are researching GetX and need to test this…
Pheepster
  • 6,045
  • 6
  • 41
  • 75
1
2 3 4 5 6 7