flutter - 应用栏对齐
问题描述
我希望在欢迎返回文本旁边对齐用户的名称。有什么方法可以在一行代码中完成吗?这是我现在所拥有的。
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 开始是可选的。
推荐阅读
- scala - Spark 暗示不在范围内解析
- python - 使用 celery 执行动态任务
- java - 为什么我必须第二次在 while 中写入 line = reader.readLine() ?我以为我已经在上面定义了
- python-3.x - 如何转储 http“内容类型:应用程序/json;” 在 FastAPI 中
- kubernetes - Kubernetes/Airflow Celery worker 任务因 SigKill 9 错误而失败,但没有解释(猜测 OOME?)
- cypress - 赛普拉斯 5.0 - 无法找到已安装的浏览器
- r - 在列表中查找补数
- python - 使用 nltk 从文本文档中构建带有标签的自定义语料库
- c# - c#控制台应用程序游戏中的两个光标
- reactjs - React 中可重用的 MaterialUi 对话框