ElevatedButton和小部件中没有这样的属性OutlinedButton来像常规RaisedButton.
ElevatedButton(
onPressed: null,
disabledColor: Colors.brown, // Error
}
Run Code Online (Sandbox Code Playgroud)
iDe*_*ode 14
onSurface如果您只想更改禁用的颜色,请使用属性(此属性在 中也可用OutlinedButton)。
ElevatedButton(
onPressed: null,
style: ElevatedButton.styleFrom(
onSurface: Colors.brown,
),
child: Text('ElevatedButton'),
)
Run Code Online (Sandbox Code Playgroud)
如需更多自定义,请使用ButtonStyle:
ElevatedButton(
onPressed: null,
style: ButtonStyle(
backgroundColor: MaterialStateProperty.resolveWith<Color>((states) {
if (states.contains(MaterialState.disabled)) {
return Colors.brown; // Disabled color
}
return Colors.blue; // Regular color
}),
),
child: Text('ElevatedButton'),
)
Run Code Online (Sandbox Code Playgroud)
ElevatedButton要将其应用于应用程序中的所有内容:
ElevatedButton(
onPressed: null,
style: ButtonStyle(
backgroundColor: MaterialStateProperty.resolveWith<Color>((states) {
if (states.contains(MaterialState.disabled)) {
return Colors.brown; // Disabled color
}
return Colors.blue; // Regular color
}),
),
child: Text('ElevatedButton'),
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4608 次 |
| 最近记录: |