Skip to content

Instantly share code, notes, and snippets.

@gabrielstellini
Created July 25, 2020 15:35
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 gabrielstellini/3b0c07d2953be5d5d46f576fc63b1f4d to your computer and use it in GitHub Desktop.
Save gabrielstellini/3b0c07d2953be5d5d46f576fc63b1f4d to your computer and use it in GitHub Desktop.
// Flutter
class CustomCard extends StatelessWidget {
CustomCard({@required this.index, @required
this.onPress});
final index;
final Function onPress;
@override
Widget build(BuildContext context) {
return Card(
child: Column(
children: <Widget>[
Text('Card $index'),
FlatButton(
child: const Text('Press'),
onPressed: this.onPress,
),
],
)
);
}
}
...
// Usage
CustomCard(
index: index,
onPress: () {
print('Card $index');
},
)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment