美文网首页flutter
Flutter之Switch组件

Flutter之Switch组件

作者: 习惯了_就好 | 来源:发表于2019-04-23 16:19 被阅读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,
        })
     */
    
    /**
     * const SwitchListTile({
        Key key,
        @required this.value,
        @required this.onChanged,
        this.activeColor,
        this.activeTrackColor,
        this.inactiveThumbColor,
        this.inactiveTrackColor,
        this.activeThumbImage,
        this.inactiveThumbImage,
        this.title,
        this.subtitle,
        this.isThreeLine = false,//设置为true,高度变大
        this.dense,
        this.secondary,//左侧图标
        this.selected = false,
        })
     */
    
    body: Column(
              children: <Widget>[
                Switch(
                  value: isCheck,
                  onChanged: (isChecked) {
                    setState(() {
                      isCheck = isChecked;
                    });
                  },
    
                  activeColor: Colors.black,
                  activeTrackColor: Colors.blue,
    //
                  inactiveThumbColor: Colors.green,
                  inactiveTrackColor: Colors.orange,
    
    //              activeThumbImage: AssetImage("images/app.png"),
    //              inactiveThumbImage: AssetImage("images/app.png"),
    
                  materialTapTargetSize: MaterialTapTargetSize.padded,
                ),
                Container(
                  color: Colors.grey,
                  child: SwitchListTile(
                    value: isCheck1,
                    onChanged: (isChecked) {
                      setState(() {
                        isCheck1 = isChecked;
                      });
                    },
                    activeColor: Colors.red,
                    title: Text("标题"),
                    subtitle: Text("副标题副标题副标题副标题副标题副标题副标题副标题副标题"),
                    secondary: Icon(Icons.alarm),
                    selected: true,
                    activeThumbImage: AssetImage("images/app.png"),
                    inactiveThumbImage: AssetImage("images/app.png"),
                    isThreeLine: false,
                  ),
                ),
                Container(
                  margin: EdgeInsets.only(top: 5.0),
                  color: Colors.grey,
                  child: SwitchListTile(
                    value: isCheck1,
                    onChanged: (isChecked) {
                      setState(() {
                        isCheck1 = isChecked;
                      });
                    },
                    activeColor: Colors.red,
                    title: Text("标题"),
                    subtitle: Text("副标题副标题副"),
                    secondary: Icon(Icons.alarm),
                    selected: true,
                    activeThumbImage: AssetImage("images/app.png"),
                    inactiveThumbImage: AssetImage("images/app.png"),
                    isThreeLine: true,
                  ),
                )
              ],
            ),
    

    相关文章

      网友评论

        本文标题:Flutter之Switch组件

        本文链接:https://www.haomeiwen.com/subject/jftbgqtx.html