Dan*_*Dan 7 mobile dart flutter
如何使用buttonstyle中的形状,MaterialStateProperty<OutlinedBorder>形状
这对我不起作用
Wil*_*bio 12
这是一个示例,您可以执行此操作来更改 ElevatedButton 的形状:
ElevatedButton.icon(
onPressed: () {
_showCustomerDialog();
},
icon: Icon(Icons.person_sharp, color: Colors.black),
label: Text('Customer 1', style: TextStyle(color: Colors.black)),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Color(0xFF10FB06)),
shape: MaterialStateProperty.all(RoundedRectangleBorder( borderRadius: BorderRadius.circular(40) ))
),
),
Run Code Online (Sandbox Code Playgroud)
这些是可以应用的形状类别:
它们都是 OutlinedBorder 的实现,OutlinedBorder 是一个抽象类,因此它们都可以将特定形状应用于按钮,根据需要使用其中之一。
更多信息:https ://api.flutter.dev/flutter/painting/OutlinedBorder-class.html