Questions tagged [widget-test-flutter]
100 questions
0
votes
1 answer
How to get current variant value in Flutter widget test
Let's imagine I have an enum to represent some colors;
enum MyColor { blue, red, green }
Not to duplicate test cases I can write a TestVariant like below;
class ColorVariant extends TestVariant {
@override
String describeValue(MyColor…

Enes Karaosman
- 1,889
- 20
- 27
0
votes
1 answer
LateInitializationError: Field '_instance@99075166' has not been initialized
It's my first time testing a flutter app. I tried to pump my HomeView with this test code:
void main() {
group('Home Test', () {
_pumpHome(WidgetTester tester) => tester.pumpWidget(
MaterialApp(
home: HomeView(),
…

Osama Asharf
- 51
- 5
0
votes
2 answers
Flutter Widget Testing: Can't Find Widget by Semantics Label in Test, Though it's Present in Dump
Testing a "DaysContainer". When a days is clicked on, it becomes selected. Works fine when I click test it, but having trouble writing a test for it. Here's my test:
testWidgets('Days are clickable ',
(WidgetTester tester) async {
…

Benjamin Lee
- 1,014
- 10
- 24
0
votes
1 answer
Flutter Test Widgets find.byType(TextField) Works, find.byWidget(TextField()) Doesn't work. Why?
I am just getting started with flutter widget testing and came upon this issue. I was wondering if this is expected behavior.
When trying to find my TextField with find.byType it succeeds but with find.byWidget it doesn't. Is this normal or am I…

SilkeNL
- 398
- 1
- 5
- 22
0
votes
1 answer
How to initialize ScreenUtil.init() in flutter test?
For the BMI app created in flutter, I am writing a test, so when I run the test I am getting this below error:
═╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═
The following assertion was thrown building home_screen(dirty, state:…

ghost deathrider
- 151
- 16
0
votes
1 answer
Flutter Riverpod WidgetTest not exceeding past loading state
UPDATE: Rewrote Test in a same way I test another consumer widget, which actually works, but it still doesn't work for my test and I can't get my head around why :(
Current approach:
void main() {
final List _mockExercises = [
…

MaxS
- 133
- 1
- 9
0
votes
1 answer
How to do a Flutter Test for a widget that accesses Provider.of(context)
I was wondering if someone could help me out, I am having trouble writing tests for my home page on my flutter project as it relies on a Provider.
home_page.dart
Future newsData = Provider.of>(context);
return…

Jason Caughers
- 3
- 2
0
votes
0 answers
How to match default properties with Flutter widget testing
I'm testing a custom progress bar widget.
I initialize the buffered parameter with a default value of Duration.zero:
class ProgressBar extends LeafRenderObjectWidget {
const ProgressBar({
Key key,
@required this.progress,
@required…

Suragch
- 484,302
- 314
- 1,365
- 1,393
0
votes
1 answer
Flutter widget test: setting padding with MediaQuery not applied
Since flutter's testing environment does not contain system status bar like the emulator, I would like to add padding at the top using MediaQuery.
Here's my testing code:
void main() {
testWidgets('MediaQuery padding test', (WidgetTester tester)…

Judy
- 99
- 1
- 2
- 8
-1
votes
1 answer
How to test a flutter button in test widget?
i read flutter's doc but i couldn't test button's action ,
i tried to do it this way, the button is children of PrivacyPolicyCard, and when clicked goes to the next page
testWidgets(
"TextButton Acept",
(WidgetTester tester) async {
await…

Aspc Starossa
- 19
- 3