I'mm testing a Textbutton in ListTile as trailing, but it throws an exception.
The finder "zero widgets with icon "IconData(U+0E1B9)" (ignoring offstage widgets)" (used in a call to "tap()") could not find any matching widgets.
This is my test:
var findIcon=find.byIcon(Icons.delete);
await tester.tap(findIcon);
await tester.pump();
And this is the UI:
return ListView.separated(
itemCount: value.newusers.length,
itemBuilder: (context, index) {
return Container(
height:80,
decoration: BoxDecoration(
color: Colors.indigo,
borderRadius:BorderRadius.all(Radius.circular(20))
),
child: Padding(
padding: EdgeInsets.all(10),
child: ListTile(
textColor: Colors.white,
title: Text(value.newusers[index].descriptioin!),
trailing:TextButton(
// key: Key('delete'),
onPressed: () {
setState(() {
value.removeData(index);
});
},
child: Icon(Icons.delete)),
leading: Text(value.newusers[index].title!),
),
I've also tried using descendant but it also throws the same an exception.
Here is the code with descendant:
final addButton=find.byType(ListTile);
final findButton=find.descendant(of: addButton,
matching:find.byType(TextButton));
await tester.tap(findButton);
await tester.pumpAndSettle();
for(int index=0;index<provider.newusers.length;index++){
expect(provider.removeData(index),findsNothing);
}