I want to do widget testing for a Stack. Here is the sample code
final List<Widget> children = [];
final stack = Stack(children: children);
await tester.pumpWidget(Container(child: stack));
...
final stackFinder = find.byWidget(stack);
expect(stackFinder, findsOneWidget);
// children should be in Stack
final childrenFinder = find.descendant(
of: stackFinder,
matching: find.byType(children.runtimeType),
);
expect(childrenFinder, findsWidgets);
but get error:
Expected: at least one matching node in the widget tree
Actual: ?:<zero widgets with type "List<Widget>" that has ancestor(s) with type "Stack"
I try to change matching to matching: find.byType([].runtimeType),
or matching: find.byType(List<Widget>),
but it doesn't work too.
Do you know how to fix it?
Aucun commentaire:
Enregistrer un commentaire