在我的帮助屏幕中,我有这个开关,其目的是不执行任何操作,只是按原样显示。
但我现在遇到的问题是,即使它没有做任何事情,用户也可以拖动开关,所以我试图弄清楚如何禁用它,以便没有人可以拖动开关按钮。
return Container(
child: Card(
color: Theme.of(context).primaryColor,
margin: EdgeInsets.only(bottom: 30, top: 10),
child: ListTile(
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text("Dark Theme",
style: TextStyle(color: Theme.of(context).accentColor)),
Switch(
value: true,
onChanged: (value) {},
activeColor: Theme.of(context).accentColor),
Text("Light Theme", style: TextStyle())
],
),
),
),
);
}
要禁用您的Switch
,编辑其onChanged
像这样的 null 方法
Switch(
onChanged: null,
value: true,
inactiveThumbColor: Colors.tealAccent,
inactiveTrackColor: Colors.tealAccent.withOpacity(0.5),
// ...
),
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)