【问题标题】:How can i make the icon change when it is clicked单击时如何更改图标
【发布时间】:2021-12-12 00:52:08
【问题描述】:

我希望在单击图像时更改并显示可见性小部件。

【问题讨论】:

  • 你能把你的code-sn-p包括进来吗?

标签: flutter dart user-interface


【解决方案1】:

关于你附加的图片,你可以简单地使用ExpansionTile获得效果。

如何根据点击更改图标

  • state 类中创建一个bool _isExpanded = false
  • 在展开更改时,使用setstate 更改值。 使用分配图标
Icon(_isExpanded?
          Icons.arrow_downward
          :Icons.arrow_upward,
          ),

【讨论】:

    【解决方案2】:
     int angle = 0; 
     RotatedBox(
              quarterTurns: angle,
              child: IconButton(
                icon: Icon(Icons.arrow_forward_ios),
                onPressed: () {
                  setState(() {
                    angle = 1;
                  });
                },
              ),
            ),
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-10-05
      • 1970-01-01
      • 2023-03-18
      • 2021-12-08
      • 2019-10-26
      • 1970-01-01
      • 2014-02-16
      • 2018-06-07
      相关资源
      最近更新 更多