Questions tagged [widget-test-flutter]
100 questions
1
vote
1 answer
How to get result of rootBundle.loadString(key) during flutter widget test?
I want to read a file from an asset during widget build with help of rootBundle but when I tried to call rootBundle.loadString('assets/myJsonAsset.json') like below :
testWidgets('load assets', (WidgetTester tester) async {
final result =…

Taleb
- 1,944
- 2
- 11
- 36
1
vote
0 answers
ProviderNotFoundException | widget test for a button, can not successfully test the button text
I am writing a widget test for a button widget, but the text part can not be tested successfully.
Here is the widget testing code:
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import…

Annie Box
- 31
- 3
1
vote
3 answers
'Null' is not a subtype of type 'Stream' in type cast cubit(Bloc) flutter
I have created a cubit testing project in flutter which is working fine, but when I am writing a UI test case with mockito for the same it is throwing the following error.
'Null' is not a subtype of type 'Stream' in typecast. If the real object is…

Anand Kumar Jha
- 614
- 9
- 23
1
vote
1 answer
Widget testing DropdownButton finds duplicate DropdownMenuItems
I'm trying to write widget tests for a DropdownButton in my app. I noticed that after tapping the button to open it the call to find.byType(DropdownMenuItem) is returning double the expected number of DropdownMenuItems.
import…

weirdvector
- 25
- 5
1
vote
0 answers
Flutter widget test exception not being handled properly
I do not believe this is a duplicate of this SO issue because the stated solution does not work in my case.
I am not able to properly catch / verify an Exception in my widgetTest and I am not sure why. Instead of handling the Exception, the test…

Jake Boomgaarden
- 3,394
- 1
- 17
- 31
1
vote
1 answer
Why widgets are not visible when running the widget test?
I'm simply trying to imetiate the introduction to widget testing in Flutter, but I'm keep seeing test failure on my basic code example that I implemented.
Here is the test:
void main() {
testWidgets(
"OrderDetailsItemWidget - all fields are…

Ahmad F
- 30,560
- 17
- 97
- 143
1
vote
1 answer
widgetTests console output: What does the number after the `~` refer to?
We're running widgetTests and I'm seeing output like
:
00:08 +76: /Users//sliver_app_bar_test.dart:
00:08 +77 ~1: /Users//sliver_app_bar_test.dart:
00:08 +78 ~2:…

buttonsrtoys
- 2,359
- 3
- 32
- 52
1
vote
1 answer
Flutter widget test Clipboard.setData future then never triggered
I am trying to test a clipboard function in my app. When I press a button it should copy my text to the clipboard. When I try to test this functionality with a widget test, the future returned doesn't get resolved. Is there a way to mock the…

Stan
- 629
- 7
- 18
1
vote
1 answer
How to test for a specific ProviderNotFoundException in widget test
I have some providers (e.g provider A,B,C) created above a certain widget and testing the ProviderNotFoundException in the case that a provider was removed from the widget tree.
Right now I'm testing the ProviderNotFoundException like…

Calvin Gonsalves
- 1,738
- 11
- 15
1
vote
1 answer
how do I test for a transition actually occuring
given a widget that "shakes" on Stream event
class Shaker extends StatefulWidget {
final Widget child;
final Stream stream;
final Duration duration;
final int loops;
const Shaker({
required this.child,
required this.stream,
…

Francesco Iapicca
- 2,618
- 5
- 40
- 85
1
vote
1 answer
Flutter Bloc Widget testing how to find.text under If statement in bloc pattern
I am trying to Widget test my WelcomeScreen(). WelcomeScreen has a BlocProvider and a BlocBuilder. After I load WelcomeBloc() it checks with an if statement inside the builder to check if the state is WelcomeLoadSuccessState.
How do I find something…

SilkeNL
- 398
- 1
- 5
- 22
1
vote
0 answers
how to creaate widget test for statefulwidget
I have 3 different files/screens (the main, the login and the sign up), where the login and sign up are statefulwidgtes. i would like to perform widget testing in the screens, however, it seems like I can't get the widgets under login and sign up,…

José Orlando
- 23
- 3
1
vote
2 answers
Flutter Integration testing failed for multiple test cases in a single file
I have a simple login page with email and password text field. A button to login and another to sign up. I tried to write integration testing for the Sign in page.
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
…

Asis
- 683
- 3
- 23
1
vote
0 answers
Widget test case is passing but i am getting error
I am getting error while testing my login file.
These test case are passing and i am getting green tick while testing it but getting this error message
void main() {
testWidgets('login page test', (WidgetTester tester) async {
await…

mohit yadav
- 166
- 4
1
vote
1 answer
Testing Tabbar border on TabBar widget Flutter
I have a CustomTabBar class which returns a TabBarWidget. So Basic Structure of the CustomTabBar widget is like:
class CustomTabBar extends StatelessWidget {
...
final bool isBottomIndicator;
...
@override
Widget build(BuildContext…

Asis
- 683
- 3
- 23