[英]I want to create a flutter app with a listview
I need to create an app that looks like this Flutter design . 我需要创建一个看起来像这个Flutter设计的应用程序。
I'm struggling to place the text where I want. 我正在努力将文字放在我想要的地方。 This is my code so far
到目前为止这是我的代码
body: Padding(
padding: const EdgeInsets.all(0.1),
child: new Container(
child: new Center(
child: new ListView(
children: <Widget>[
new Card(//card 1
child: new Container(
color: Colors.grey,
padding: new EdgeInsets.only(
left: 160.0, top: 0.01, right: 160.0, bottom: 0.01),
child: new Column(
children: <Widget>[
new Text('My Profile')
],
),
),
),
],
),
)
),
)
Your large padding of 160
made it seem like the text was centered on my device. 160
大填充使得文本看起来像是在我的设备上。 You can always align the text to the left inside Column
s by setting crossAxisAlignment
to CrossAxisAlignment.start
. 你总是可以对齐文本向左内侧
Column
通过设定S1 crossAxisAlignment
到CrossAxisAlignment.start
。
This code should produce some output that is similar to your drawing (I also removed some unnecessary Center
s, Container
s and Padding
s): 这段代码应该产生一些类似于你的绘图的输出(我还删除了一些不必要的
Center
, Container
和Padding
):
Scaffold(
appBar: AppBar(),
body: ListView(
padding: const EdgeInsets.all(0.1),
children: <Widget>[
Card(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
padding: const EdgeInsets.symmetric(horizontal: 16),
width: double.infinity,
color: Colors.grey,
child: Text('My Profile'),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: Text('My text\nMy text\nMy text\nMy text'),
),
],
),
),
],
),
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.