应用栏对齐
Appbar alignment
我希望将用户名与欢迎返回文本对齐。有什么办法可以在一行代码中完成吗?这是我现在拥有的。
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
brightness: Brightness.light,
backgroundColor: Colors.white,
elevation: 0,
title: Text("Welcome Back", style: TextStyle(color: Color.fromRGBO(49, 39, 79, 1), fontWeight: FontWeight.bold,fontSize: 20),),
actions: <Widget>[
new Container(
child: Text(
name, style: TextStyle(color: Color.fromRGBO(49, 39, 79, 1), fontWeight: FontWeight.bold,fontSize: 20)
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: CircleAvatar(
backgroundImage: NetworkImage(
imageUrl,
),
),
),
]),
用于这种情况Row(...)
actions: <Widget>[
Row(
children: <Widget>[
Container(
child: Text(name, style: TextStyle(color: Color.fromRGBO(49, 39, 79, 1), fontWeight: FontWeight.bold,fontSize: 20))
),
Padding(padding: const EdgeInsets.all(8.0),
child: CircleAvatar(
backgroundImage: NetworkImage(imageUrl),
),
),
],
),
]
顺便说一句:您不需要 new
。这是因为 Dart 2.0 可选。
我希望将用户名与欢迎返回文本对齐。有什么办法可以在一行代码中完成吗?这是我现在拥有的。
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
brightness: Brightness.light,
backgroundColor: Colors.white,
elevation: 0,
title: Text("Welcome Back", style: TextStyle(color: Color.fromRGBO(49, 39, 79, 1), fontWeight: FontWeight.bold,fontSize: 20),),
actions: <Widget>[
new Container(
child: Text(
name, style: TextStyle(color: Color.fromRGBO(49, 39, 79, 1), fontWeight: FontWeight.bold,fontSize: 20)
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: CircleAvatar(
backgroundImage: NetworkImage(
imageUrl,
),
),
),
]),
用于这种情况Row(...)
actions: <Widget>[
Row(
children: <Widget>[
Container(
child: Text(name, style: TextStyle(color: Color.fromRGBO(49, 39, 79, 1), fontWeight: FontWeight.bold,fontSize: 20))
),
Padding(padding: const EdgeInsets.all(8.0),
child: CircleAvatar(
backgroundImage: NetworkImage(imageUrl),
),
),
],
),
]
顺便说一句:您不需要 new
。这是因为 Dart 2.0 可选。