[英]How to make text be on top in use (Flutter) in Android Studio
so I want to make a simple text in a flutter framework, but I don't know to make the text for going on the top of the text, this is the example of the image I want to be on top:所以我想在 flutter 框架中制作一个简单的文本,但我不知道将文本放在文本的顶部,这是我想要放在顶部的图像示例:
this is my DetailPage.dart:这是我的 DetailPage.dart:
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.redAccent,
title: Text(
'Detail ' + itemJudul,
style: TextStyle(color: Colors.white),
)),
body: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Center(child: Image.asset(itemImage)),
Text(
itemJudul,
style: TextStyle(color: Colors.redAccent, fontSize: 30.0),
),
Text(itemSub),
Text('Sisa Item =' + qty),
Container(
width: 200,
child: Text("Bahan Bahan",
textAlign: TextAlign.left,
style: new TextStyle(fontWeight: FontWeight.bold) // has impact
),
alignment: Alignment.centerLeft,
),
Container(
child: Text(
listbahanan,
textAlign: TextAlign.left,
),
alignment: Alignment.centerLeft,
),
Container(
child: Text(
listbahan2,
textAlign: TextAlign.right,
),
alignment: Alignment.center,
padding: EdgeInsets.all(5),
)
],
),
);
}
U can use two columns wrapped in a row.你可以使用包裹在一行中的两列。
Row(
children: [
Expanded(
child: Container(
child: Text(
listbahanan,
textAlign: TextAlign.left,
),
alignment: Alignment.centerLeft,
),
),
Expanded(
child: Container(
child: Text(
listbahan2,
textAlign: TextAlign.right,
),
alignment: Alignment.center,
padding: EdgeInsets.all(5),
)
],
),
You need to use Row
to align two lists side by side.您需要使用
Row
将两个列表并排对齐。 Also, I don't think it's a good idea to store a list as string, better use List
for storing and ListView
for displaying the list items.另外,我认为将列表存储为字符串不是一个好主意,最好使用
List
来存储和ListView
来显示列表项。
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.redAccent,
title: Text(
'Detail ' + itemJudul,
style: TextStyle(color: Colors.white),
)),
body: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Center(child: Image.asset(itemImage)),
Text(
itemJudul,
style: TextStyle(color: Colors.redAccent, fontSize: 30.0),
),
Text(itemSub),
Text('Sisa Item =' + qty),
Container(
width: 200,
child: Text("Bahan Bahan",
textAlign: TextAlign.left,
style: new TextStyle(fontWeight: FontWeight.bold) // has impact
),
alignment: Alignment.centerLeft,
),
Row( // this is new
children: <Widget>[
Flexible( // this is new
child: Text(
listbahanan,
textAlign: TextAlign.left,
),
),
Flexible( // this is new
child: Text(
listbahan2,
textAlign: TextAlign.right,
),
)
],
),
],
),
);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.