gpt4 book ai didi

flutter - Flutter FlatButton内部空间

转载 作者:行者123 更新时间:2023-12-03 03:35:07 27 4
gpt4 key购买 nike

在我的一个flutter应用程序中,有一个FlatButton,如下所示

FlatButton(
child: Text("Forgot ist ?",
style: TextStyle(color: Color.fromRGBO(107, 106, 106, 1),fontFamily: 'ActoBook'),
textAlign: TextAlign.left
),

materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
shape: RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(0.0),
side: BorderSide(color: Colors.transparent),
),
onPressed: (){
Navigator.pushReplacement(context, new MaterialPageRoute( builder: (context) => LoginPage()),);
},
)

如何使按钮的文本右对齐?当前,它以左右相等的空间居中。

目前显示像这样
+-----------------+
| Button Text |
+-----------------+

我正在尝试使其像
+-----------------+
| Button Text|
+-----------------+

最佳答案

可以正常运行,请检查一下。

FlatButton(
padding: EdgeInsets.zero,
color: Colors.blue,
// wrap the text in a container and give it a specified width
child: Container(
width: 100,
child: Text(
"Forgot ist ?",
style: TextStyle(
color: Color.fromRGBO(107, 106, 106, 1),
fontFamily: 'ActoBook',
),
// set the alignment of the text to TextAlign.end
textAlign: TextAlign.end,
),
),
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
shape: RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(0.0),
side: BorderSide(color: Colors.transparent),
),
onPressed: () {
Navigator.pushReplacement(context, new MaterialPageRoute( builder: (context) => LoginPage()),);
},
)),

上面的代码给出以下输出:
This is the output

关于flutter - Flutter FlatButton内部空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61557295/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com