我有 2 行文本,它是这样的。
这是代码。
Row(
children: [
Container(
width: 150.0,
child: Text(
"Agent Ship and Bunker",
style: TextStyle(
letterSpacing: 0.5,
color: Colors.black87,
fontFamily: "Sans",
// fontWeight: FontWeight.w600,
fontSize:
mediaQuery.devicePixelRatio +
12.0),
overflow: TextOverflow.fade,
),
),
Padding(
padding: const EdgeInsets.only(left: 10.0),
child: Text(
"100000 USD",
style: TextStyle(
letterSpacing: 0.5,
color: Colors.black54,
fontFamily: "Sans",
// fontWeight: FontWeight.w600,
fontSize:
mediaQuery.devicePixelRatio +
9.0),
),
),
],
),
以及如何使文本与这样的顶部平行对齐? :/
谢谢... :)
答案 0 :(得分:1)
为此,您必须将第一个 Text
包装到 Expanded
中,并且小部件 Row
必须具有属性 `crossAxisAlignment: CrossAxisAlignment.start。试试这个:
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Text("Agent Ship and Bunker", style: TextStyle(
letterSpacing: 0.5,
color: Colors.black87,
fontFamily: "Sans",
// fontWeight: FontWeight.w600,
fontSize: mediaQuery.devicePixelRatio + 12.0,),
overflow: TextOverflow.fade,),
),
Padding(
padding: const EdgeInsets.only(left: 10.0),
child: Text(
"100000 USD",
style: TextStyle(
letterSpacing: 0.5,
color: Colors.black54,
fontFamily: "Sans",
// fontWeight: FontWeight.w600,
fontSize:
mediaQuery.devicePixelRatio +
9.0),
),
),
],
)