Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@daiki1003
Last active March 16, 2022 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daiki1003/2fb4061f1906d82143dcdee7dd52678c to your computer and use it in GitHub Desktop.
Save daiki1003/2fb4061f1906d82143dcdee7dd52678c to your computer and use it in GitHub Desktop.
class MyGreatestWidget extends StatelessWidget {
const MyGreatestWidget({
Key? key,
required this.onPressed,
}) : super(key: key);
final ValueCallback<String> onPressed;
@override
Widget build(BuildContext context) {
final fruits = ['apple', 'banana', 'orange'];
return ListView(
children: fruits.map((fruit) {
return ListTile(
onTap: () => onPressed(fruit),
leading: const Icon(Icons.favorite_border),
title: Text(fruit),
);
}).toList(),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment