how to run function inside the classdart
class Animals
{
var animalList = ['dog','cat','cow'];
// function for printing the list of animals
void animalListPrinter(){
for(var animal in animalList){
print(animal);
}
}
}
3.83
6
class ShowingAnimalList extends StatelessWidget {
final Animals ani= new Animals();
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: ani.animalListPrinter(),
);
}
}
Thank you!
6
0
Are there any code examples left?
New code examples in category Other