首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Appbar对齐方式

Appbar对齐方式
EN

Stack Overflow用户
提问于 2020-02-14 05:42:22
回答 1查看 33关注 0票数 0

我正在寻找对齐的用户名旁边的欢迎回来文本。有没有什么方法可以在一行代码中做到这一点?这就是我现在所拥有的。

代码语言:javascript
复制
  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,
                ),
              ),
            ),
          ]),

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-02-14 06:34:02

在这种情况下使用Row(...)

代码语言:javascript
复制
  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是可选的。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60216901

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档