how can i get the widget count
final SerializableFinder finder = find.byType('MyWidget');
await driver.tap(finder);
but MyWidget may be more than one,
that will throw exception
You will need to use some attribute that allows you to find the widget you need. For example, add a Key
to each of these widgets, so it's easier to find the one you need:
...MyWidget(key: Key('myWidget1'))...
So, find it by key:
find.byKey(Key('myWidget1'))
If you want to find the widget count, you can use this:
final finder = find.byType(MyWidget, skipOffstage: false); // Without quotes!
final count = tester.widgetList<MyWidget>(finder).length;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With