Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 如何在使用颤振选择时通过更改颜色和大小来创建圆形按钮_Flutter_Dart - Fatal编程技术网

Flutter 如何在使用颤振选择时通过更改颜色和大小来创建圆形按钮

Flutter 如何在使用颤振选择时通过更改颜色和大小来创建圆形按钮,flutter,dart,Flutter,Dart,有没有办法创建一个圆形按钮,并在选中时更改大小和颜色 如下图所示 您可以尝试以下代码片段: class _MyStatefulWidgetState extends State<MyStatefulWidget> { bool _isSelectedLeftButton = true; bool _isSelectedRightButton = false; Widget build(BuildContext context) { return Row(

有没有办法创建一个圆形按钮,并在选中时更改大小和颜色

如下图所示


您可以尝试以下代码片段:

class _MyStatefulWidgetState extends State<MyStatefulWidget> {
  bool _isSelectedLeftButton = true;
  bool _isSelectedRightButton = false;
  
  Widget build(BuildContext context) {
    return Row(
      mainAxisSize: MainAxisSize.min,
      children: <Widget>[
        Ink(
          height: _isSelectedLeftButton ? 80.0 : 60.0,
          width: _isSelectedLeftButton ? 80.0 : 60.0,
          decoration: ShapeDecoration(
            color: _isSelectedLeftButton ? Colors.lightBlue : Colors.grey,
            shape: CircleBorder(),
          ),
          child: IconButton(
            icon: Icon(Icons.sim_card),
            color: Colors.white,
            iconSize: _isSelectedLeftButton ? 40.0 : 30.0,
            onPressed: () {
              setState((){
                _isSelectedLeftButton = true;
                _isSelectedRightButton = false;
              });
            },
          ),
        ),
        SizedBox(width: 20.0,),
        Ink(
          height: _isSelectedRightButton ? 80.0 : 60.0,
          width: _isSelectedRightButton ? 80.0 : 60.0,
          decoration: ShapeDecoration(
            color: _isSelectedRightButton ? Colors.lightBlue : Colors.grey,
            shape: CircleBorder(),
          ),
          child: IconButton(
            icon: Icon(Icons.sim_card),
            color: Colors.white,
            iconSize: _isSelectedRightButton ? 40.0 : 30.0,
            onPressed: () {
              setState((){
                _isSelectedLeftButton = false;
                _isSelectedRightButton = true;
              });
            },
          ),
        ),
      ],
    );
  }
}
class\u MyStatefulWidgetState扩展状态{
bool _isSelectedLeftButton=true;
bool\u isSelectedRightButton=false;
小部件构建(构建上下文){
返回行(
mainAxisSize:mainAxisSize.min,
儿童:[
墨水(
高度:_isSelectedLeftButton?80.0:60.0,
宽度:_isSelectedLeftButton?80.0:60.0,
装饰:造型装饰(
颜色:\ isSelectedLeftButton?颜色。浅蓝色:颜色。灰色,
形状:CircleBorder(),
),
孩子:我的钮扣(
图标:图标(图标。sim卡),
颜色:颜色,白色,
iconSize:_isSelectedLeftButton?40.0:30.0,
已按下:(){
设置状态(){
_isSelectedLeftButton=true;
_isSelectedRightButton=false;
});
},
),
),
尺寸标注框(宽度:20.0,),
墨水(
高度:_isSelectedRightButton?80.0:60.0,
宽度:_isSelectedRightButton?80.0:60.0,
装饰:造型装饰(
颜色:_isSelectedRightButton?颜色。浅蓝色:颜色。灰色,
形状:CircleBorder(),
),
孩子:我的钮扣(
图标:图标(图标。sim卡),
颜色:颜色,白色,
图标化:_isSelectedRightButton?40.0:30.0,
已按下:(){
设置状态(){
_isSelectedLeftButton=false;
_isSelectedRightButton=true;
});
},
),
),
],
);
}
}

非常感谢您的回答这是一个非常好的回答,但我在下面的链接中找到了您真正需要的东西,欢迎:)您能帮我回答另一个问题吗,但温家宝可以打开一个聊天窗口,如果可以,我很高兴:你仍然可以在平台上发布你的问题,这样每个人都可以给出自己的观点和答案:)当然我会这样做,我会发布我的另一个问题:)