单击单击时如何禁用 onTap 功能。使用颤振。
这是我下面的代码,请帮我检查一下...
class VoteCalonUmumPage extends StatelessWidget {
const VoteCalonUmumPage({Key? key, required this.title}) : super(key: key);
final String title;
Widget _buildListItem(BuildContext context, DocumentSnapshot document) {
return ListTile(
tileColor: Color(0xff99c2ec),
title: Row(
children: [
Expanded(
child: Text(document['name'],
style: TextStyle(
color: Colors.black87,
fontSize: 20,
)),
),
Container(
decoration: const BoxDecoration(
color: Color(0xffecc399),
),
padding: const EdgeInsets.all(10.0),
child: Text(
document['votes'].toString(),
style: Theme.of(context).textTheme.headline4,
),
),
],
),
onTap: () {
FirebaseFirestore.instance.runTransaction((transaction) async {
DocumentSnapshot freshSnap =
await transaction.get(document.reference);
await transaction.update(freshSnap.reference, {
'votes': freshSnap['votes'] + 1,
});
});
},
);
}
}