mirror of
https://github.com/nisrulz/flutter-examples.git
synced 2025-09-26 09:36:48 +08:00
Setup on click action on GridView items
This commit is contained in:
@ -1,20 +1,26 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class MyGridView {
|
class MyGridView {
|
||||||
Card getStructuredGridCell(name, image) {
|
GestureDetector getStructuredGridCell(name, image) {
|
||||||
return Card(
|
// Wrap the child under GestureDetector to setup a on click action
|
||||||
elevation: 1.5,
|
return GestureDetector(
|
||||||
child: Column(
|
onTap: () {
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
print("onTap called.");
|
||||||
mainAxisSize: MainAxisSize.min,
|
},
|
||||||
verticalDirection: VerticalDirection.down,
|
child: Card(
|
||||||
children: <Widget>[
|
elevation: 1.5,
|
||||||
Image(image: AssetImage('data_repo/img/' + image)),
|
child: Column(
|
||||||
Center(
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
child: Text(name),
|
mainAxisSize: MainAxisSize.min,
|
||||||
)
|
verticalDirection: VerticalDirection.down,
|
||||||
],
|
children: <Widget>[
|
||||||
));
|
Image(image: AssetImage('data_repo/img/' + image)),
|
||||||
|
Center(
|
||||||
|
child: Text(name),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
GridView build() {
|
GridView build() {
|
||||||
|
Reference in New Issue
Block a user