Flutter 颤振|右对齐不工作
尝试将容器与文本视图子容器右对齐时,它有一个位于另一列中的行父对象,尝试了堆栈溢出的大量解决方案,但无效 代码Flutter 颤振|右对齐不工作,flutter,flutter-layout,Flutter,Flutter Layout,尝试将容器与文本视图子容器右对齐时,它有一个位于另一列中的行父对象,尝试了堆栈溢出的大量解决方案,但无效 代码 ///Transactions Heading new Column( children: <Widget>[ new Row( children: <Widget>[ new Container( align
///Transactions Heading
new Column(
children: <Widget>[
new Row(
children: <Widget>[
new Container(
alignment: Alignment.centerLeft,
margin: new EdgeInsets.only(top: 20.0, left: 10.0),
child: new Text(
"Transactions",
style: new TextStyle(
color: primaryTextColor,
fontSize: 25.0,
fontWeight: FontWeight.w700,
letterSpacing: 0.1,
),
),
),
new Container(
margin: new EdgeInsets.only(top: 25.0),
child: new Text(
currentGoalTransactions.length.toString() + " items",
style: new TextStyle(
color: darkHeadingsTextColor, fontSize: 15.0),
),
),
],
),
]);
///事务标题
新专栏(
儿童:[
新行(
儿童:[
新容器(
对齐:alignment.centerLeft,
边距:仅限新边集(顶部:20.0,左侧:10.0),
儿童:新文本(
“交易”,
样式:新文本样式(
颜色:primaryTextColor,
字体大小:25.0,
fontWeight:fontWeight.w700,
字母间距:0.1,
),
),
),
新容器(
边距:仅限新边集(顶部:25.0),
儿童:新文本(
currentGoalTransactions.length.toString()+“项”,
样式:新文本样式(
颜色:暗灰色,字体大小:15.0),
),
),
],
),
]);
要将两项文本向右对齐
使用
行
小部件中的mainAxisAlignment
属性
new Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
...
)
屏幕截图:
您也可以像这样尝试
Wrap
:
Wrap(
spacing: 50, // spacing between each of the widgets below
children: <Widget>[
Text("One"),
Text("Two"),
Text("Three"),
],
)
Wrap(
间距:50,//下面每个小部件之间的间距
儿童:[
正文(“一”),
正文(“二”),
正文(“三”),
],
)
使用间隔符
,该间隔符将获得剩余空间,并将平均分配小部件
Row(
children: <Widget>[
Text("Text 1", style: TextStyle(fontSize: 20),),
Spacer(),
Text("Text 2", style: TextStyle(fontSize: 20),),
Spacer(),
Text("Text 3", style: TextStyle(fontSize: 20),),
],
),
行(
儿童:[
文本(“文本1”,样式:文本样式(字体大小:20),),
垫片(),
文本(“文本2”,样式:文本样式(字体大小:20),),
垫片(),
文本(“文本3”,样式:文本样式(字体大小:20),),
],
),
输出:
你能分享一下你真正想要的图片吗?谢谢!!这个代码有帮助。