[英]Flutter ElevatedButton shape - rectangle
This should be the easiest one ever.这应该是有史以来最简单的一个。
I am coming back to flutter after years away as I am forced to update my old app.多年后我又回到了 flutter,因为我被迫更新我的旧应用程序。 Everything has changed!
一切都改变了!
I am trying to make an ElevatedButton that is square.我正在尝试制作一个方形的 ElevatedButton。 The default has slightly rounded edges that looks weird when I am making a button the width of the screen.
当我将按钮设置为屏幕宽度时,默认设置的边缘略微圆润,看起来很奇怪。
All I want to know is how I can make this button a square.我只想知道如何让这个按钮变成一个正方形。 That's it!
而已! No tricks!
没有技巧!
ElevatedButton has: ElevatedButton 具有:
ElevatedButton.styleFrom(
shape: ???,
),
But I can't find any information anywhere online what my options are for shape.但是我在网上的任何地方都找不到任何关于我的形状选择的信息。 Only a few examples on how to make it round or beveled or literally every other shape you can think of except for a simple rectangle:D
只有几个例子说明了如何使它变成圆形或斜面,或者你能想到的所有其他形状,除了一个简单的矩形:D
Try below code:试试下面的代码:
ElevatedButton
,ButtonStyle
, BorderRadius
ElevatedButton
,ButtonStyle
, BorderRadius
ElevatedButton(
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
//borderRadius: BorderRadius.zero, //Rectangular border
),
),
onPressed: () {},
child: const Text(
'Submit',
),
),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.