flutter Switch组件

2021-04-29  本文已影响0人  银弹星空

构造方法

const Switch({
    Key key,
    @required this.value,
    @required this.onChanged,
    this.activeColor,//选中时圆圈的颜色
    this.activeTrackColor,//选中时底部横条的颜色

    this.inactiveThumbColor,//未选中时圆圈的颜色
    this.inactiveTrackColor,//未选中时底部横条的颜色

    this.activeThumbImage,//选中时圆圈的图片
    this.inactiveThumbImage,//未选中时圆圈的图片

    this.materialTapTargetSize,//点击区域尺寸,padded:向四周扩展48px区域;shrinkWrap:控件区域
    this.dragStartBehavior = DragStartBehavior.start,
    })

用法

  _centerMenuRow() {
    return Container(
      height: ScreenUtil().setHeight(150),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Column(
            mainAxisSize: MainAxisSize.min,
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Switch(
                  activeThumbImage:
                      AssetImage("images/create_audio_switch_on_icon.png"),
                  inactiveThumbImage:
                      AssetImage("images/create_audio_switch_off_icon.png"),
                  activeTrackColor: Color.fromARGB(255, 209, 104, 68),
                  inactiveTrackColor: Color.fromARGB(255, 102, 102, 102),
                  value: isGoNoise ?? false,
                  onChanged: (value) {
                    setState(() {
                      isGoNoise = value;
                    });
                  }),
              Text('去噪'),
            ],
          ),
          Column(
            mainAxisSize: MainAxisSize.min,
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Switch(
                  activeThumbImage:
                      AssetImage("images/create_audio_switch_on_icon.png"),
                  inactiveThumbImage:
                      AssetImage("images/create_audio_switch_off_icon.png"),
                  activeTrackColor: Color.fromARGB(255, 209, 104, 68),
                  inactiveTrackColor: Color.fromARGB(255, 102, 102, 102),
                  value: isDoubleSound ?? false,
                  onChanged: (value) {
                    setState(() {
                      isDoubleSound = value;
                    });
                  }),
              Text('双声道'),
            ],
          ),
        ],
      ),
    );
  }
上一篇 下一篇

猜你喜欢

热点阅读