Questions tagged [widget-test-flutter]
100 questions
4
votes
1 answer
Hit the the enter/done/return button in Flutter integration test after enter a text
await tester.enterText(mySearchField, 'my search text');
await tester.showKeyboard(mySearchField);
await tester.sendKeyDownEvent(LogicalKeyboardKey.enter);
// do something to wait for 2 seconds
await tester.pumpAndSettle();
await…

Maurice Raguse
- 4,437
- 2
- 29
- 46
4
votes
1 answer
Flutter Widget Testing for BlocBuilder Widgets
I have a Widget which uses bloc builder to map the different state of widget.
class BodyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocBuilder(builder: (context,…

Asis
- 683
- 3
- 23
3
votes
1 answer
Flutter widget test on custom checkbox
I have a custom checkbox like this:
FeedbackCheckBox(
title: 'Test',
onChanged: (value) {
setState(
() {
isNeedComeBack = value;
},
);
},
)
and these are…

Cyrus the Great
- 5,145
- 5
- 68
- 149
3
votes
1 answer
How can I do this in Flutter Testing
I'm new to Flutter testing and was hoping If you could help me. I've a class called AddShimmer that looks like this ->
AddShimmer(
child: ListTile(
title: buildLoadingAnimation(context),
),
),
Now, I'm trying…

Divyam Dhadwal
- 395
- 3
- 19
3
votes
0 answers
Specify diff tolerance level for golden test files in flutter
The reason for doing this is explained in this issue
How do we set a diff tolerance levels for the golden test ? There is already PR merged for this. But I am not sure how I use those API in my tests.
Currently, I have got a golden test matcher like…

Burhanuddin Rashid
- 5,260
- 6
- 34
- 51
3
votes
3 answers
How to verify a widget is "offscreen"
bounty info: I'll accept your answer if:
isn't something along the line do this instead
the code sample is mostly unchanged
produce successful test, not just some quote from docs
doesn't need any extra package
[edit : 07/02/21] following…

Francesco Iapicca
- 2,618
- 5
- 40
- 85
2
votes
0 answers
Flutter Widget Test gives me this error: No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp()
I am new to writing widget test cases in Flutter and I found very less resources on Flutter testing, When I am trying to write test cases for a module which uses Firestore and it gives following error: No Firebase App '[DEFAULT]' has been created -…

Padmaja Rani
- 113
- 3
- 10
2
votes
2 answers
Flutter with `easy_localization` hangs the widget test forever
Widgets that internally use tr extension fail. Consider this example:
void main() {
testWidgets('no decks', (WidgetTester tester) async {
await tester.pumpWidget(const DeckList(decks: []));
await tester.pumpAndSettle();
// test code
…

Eray Erdin
- 2,633
- 1
- 32
- 66
2
votes
2 answers
Codemagic: how do I set up integration tests Android Emulator
Here is how the default configuration for tests looks like:
In Flutter Drive arguments we can see that there is a target defined
drive --target=test_driver/main.dart
Flutter documentation on integration tests doesn't mention creating this file.…

Diana
- 935
- 10
- 31
2
votes
2 answers
Flutter Test: Look for a widget inside of another widget
I am looking for the way to see that the widget I have found in the test, has certain text inside. In my case I want to look for the specific text not inside the complete RadioButtonGroup but inside of the found ElevatedButton --> firstButton. Is it…

Diana
- 935
- 10
- 31
2
votes
1 answer
i am using flutter widget testing for this project where i want to test whether the TextFormField validation is working but could not find the context
this is the test code `
testWidgets('invalid input for testtwo', (WidgetTester tester) async {
final test_two = find.byKey(ValueKey('test2'));
final fill_mark = find.byKey(ValueKey('fillmark'));
await tester.pumpWidget(PopUpMarklist(id:…

yoseph
- 21
- 3
2
votes
1 answer
How to test a LongPressDraggable in Flutter
I want to test a LongPressDraggable in Flutter.
The WidgetTester provide methods like longPress or several drag methods.
But there is no "longPressDrag" or something like this.
The first idea was to run a longPress and a drag. But after the…

FlyingOddo
- 55
- 6
2
votes
0 answers
Mock object not recognized as Mockito in Flutter widget test using GetIt
I am writing a widget test that verifies a logout button. When the logout function is triggered via a user button tap, some items in FlutterSecureStorage are cleared. I want to verify that a method was called in our Preferences class which is a…

Pheepster
- 6,045
- 6
- 41
- 75
2
votes
1 answer
Verifying navigation in Flutter widget tests
I am implementing a widget test in which a user logs in and is navigated to the next view upon successful authentication. I have checked out several posts, all which suggest setting up a mock of type NavigatorObserver then using it to verify the…

Pheepster
- 6,045
- 6
- 41
- 75
2
votes
1 answer
How to Widget Test a BoxDecoration in Flutter
I want to test the color change of a BoxDecoration but I don't know how to get the color...
Here is the code
testWidgets('CustomCheckbox Test', (WidgetTester tester) async{
await tester.pumpWidget(Sizer(
builder: (context, orientation,…

Zouglou
- 89
- 1
- 11