首页 > 解决方案 > 如何检查按钮当前是否在颤动中处于活动状态?

问题描述

如何检查按钮当前是否在颤动中处于活动状态?下面是我要创建的按钮的图像:

[ 下面是我要创建的按钮的图像:]

标签: androiduser-interfacefluttermobile-development

解决方案


Flutter 在 v1.9.1 中添加了切换按钮,它由一组按钮组成,回调返回哪个被选中

您可以查看链接:https ://api.flutter.dev/flutter/material/ToggleButtons-class.html

一个小例子

ToggleButtons(
  children: <Widget>[
    Icon(Icons.add),
    Icon(Icons.car),
    Icon(Icons.menu),
  ],
  onPressed: (int index) {
//returned the selected index user chose
  },
  isSelected: isSelected,// which is a List<bool> that to define the selected button
),

推荐阅读