您可以将 shape 参数添加到您的 TextButton
TextButton(
style: TextButton.styleFrom(
backgroundColor: Colors.yellow,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.zero))),
child: const Text("BUtton"),
onPressed: () {},
)
将此行代码添加到您的 TextButton()
style: TextButton.styleFrom(
shape: const BeveledRectangleBorder(borderRadius: BorderRadius.zero),
),
对 Danny Rufus 的答案进行一些改进,您可以使用
BorderRadius.zero
将所有角的边框半径设置为 0
TextButton(
style: TextButton.styleFrom(
backgroundColor: Colors.yellow,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.zero
)
),
child: const Text("Button"),
onPressed: () {},
)
或者您可以删除
borderRadius
参数,因为默认值为 BorderRadius.zero
,如 doc 所示
这样就可以直接使用
const RoundedRectangleBorder()