1. 使用GestureDetector组件添加点击事件:

GestureDetector( onTap: () { // 点击事件处理逻辑 }, child: Container( // 容器内容 ), )

  1. 使用InkWell组件添加点击事件:

InkWell( onTap: () { // 点击事件处理逻辑 }, child: Container( // 容器内容 ), )

  1. 使用FlatButton组件添加点击事件:

FlatButton( onPressed: () { // 点击事件处理逻辑 }, child: Text('点击'), )

  1. 使用RaisedButton组件添加点击事件:

RaisedButton( onPressed: () { // 点击事件处理逻辑 }, child: Text('点击'), )

  1. 使用IconButton组件添加点击事件:

IconButton( icon: Icon(Icons.add), onPressed: () { // 点击事件处理逻辑 }, )

  1. 使用InkResponse组件添加点击事件:

InkResponse( onTap: () { // 点击事件处理逻辑 }, child: Container( // 容器内容 ), )

  1. 使用RawMaterialButton组件添加点击事件:

RawMaterialButton( onPressed: () { // 点击事件处理逻辑 }, child: Text('点击'), )

  1. 使用MaterialButton组件添加点击事件:

MaterialButton( onPressed: () { // 点击事件处理逻辑 }, child: Text('点击'),

flutter 动态添加点击事件的所有方式

原文地址: https://www.cveoy.top/t/topic/c8rQ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录