I am using below ExpansionTileCard widget for the ListView.Builder, I am able to generate the list using this, but I am not able add the functionality if the user presses the item in the list and then to perform a FlutterToast Action, I tried to find the solution with the flutter package but no success yet
Please guide me how to do that.
child: ExpansionTileCard(
leading: CircleAvatar(child: Image.network(widget.Picurl)),
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text("text1"),
Text('text2'),
],
),
subtitle: Column(
children: <Widget>[
Row(
children: <Widget>[
Text("Text1"),
SizedBox(width: 5,),
Text("Text2")
],
),
],
),
children: <Widget>[
Divider(
thickness: 1.0,
height: 1.0,
),
Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16.0,
vertical: 8.0,
),
child: Text(
widget.postcontent,
style: Theme.of(context)
.textTheme
.body1
.copyWith(fontSize: 16),
),
),
),
ButtonBar(
alignment: MainAxisAlignment.spaceAround,
buttonHeight: 52.0,
buttonMinWidth: 90.0,
children: <Widget>[
FlatButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(4.0)),
onPressed: () {
},
child: Column(
children: <Widget>[
Icon(Icons.star),
Padding(
padding: const EdgeInsets.symmetric(vertical: 2.0),
),
Text('Button1'),
],
),
),
FlatButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(4.0)),
onPressed: () {
},
child: Column(
children: <Widget>[
Icon(Icons.open_in_browser),
Padding(
padding: const EdgeInsets.symmetric(vertical: 2.0),
),
Text('Button2'),
],
),
),
],
),
],
),
Try wrapping with a GestureDetector.
Just put the widget you want to register tap or pressed gestures inside a GestureDetector
widget and select the appropriate callback for needed gesture events
GestureDetector(
onTap: () {
// your code here
},
child: ExpansionTileCard(
........
),
),
For more details and gesture options: https://api.flutter.dev/flutter/widgets/GestureDetector-class.html
If you want the ripple effect when the widget is being tapped, you should wrap the widget inside InkWell
Here is how -
InkWell(
onTap: () {
// your code here
},
child: ExpansionTileCard(
........
),
),
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.