Flutter 如何在颤振中消除图像中心

Flutter 如何在颤振中消除图像中心,flutter,flutter-layout,Flutter,Flutter Layout,面对颤振中的一些困难,因为我对颤振还不熟悉,如何为颤振的imageView设置centerInParent?图像不居中,我使用了对齐,但仍然无法工作。如何构建像这张照片一样的图像和文本 appBar: PreferredSize( preferredSize: Size.fromHeight(45.0), child: AppBar( leading: Row( children: [ Container(

面对颤振中的一些困难,因为我对颤振还不熟悉,如何为颤振的imageView设置centerInParent?图像不居中,我使用了对齐,但仍然无法工作。如何构建像这张照片一样的图像和文本

  appBar: PreferredSize(
      preferredSize: Size.fromHeight(45.0),
      child: AppBar(
        leading: Row(
          children: [
            Container(
              child: GestureDetector(
                  onTap: () {/* open left menu */},
                  child: Image.asset("assets/images/ic_title_menu.png", width: 18.0, height: 18.0,)),
              padding: EdgeInsets.fromLTRB(14.0, 14.0, 14.0, 14.0),
            ),
          ],
        ),
        title: Container(
          child: GestureDetector(
            onTap: () {/* open search */},
            child: Image.asset("assets/images/ic_title_search.png", width: 18.0, height: 18.0,)),
        ),
        actions: <Widget>[
          Center(
            child: Container(
              child: Stack(children: <Widget>[
                Align(
                  alignment: Alignment.center,
                  child: Image.network(""),)
              ],),
            ),
          )
        ],
        titleSpacing: 0.0,
        automaticallyImplyLeading: false,
      ),
    ),
appBar:PreferredSize(
首选尺寸:尺寸。从高度(45.0),
孩子:AppBar(
领先:世界其他地区(
儿童:[
容器(
儿童:手势检测器(
onTap:(){/*打开左侧菜单*/},
子项:Image.asset(“assets/images/ic_title_menu.png”,宽度:18.0,高度:18.0,),
填充:来自LTRB(14.0,14.0,14.0,14.0,14.0)的边缘设置,
),
],
),
标题:集装箱(
儿童:手势检测器(
onTap:(){/*打开搜索*/},
子项:Image.asset(“assets/images/ic_title_search.png”,宽度:18.0,高度:18.0,),
),
行动:[
居中(
子:容器(
子:堆栈(子:[
对齐(
对齐:对齐.center,
子项:Image.network(“”)
],),
),
)
],
标题间距:0.0,
自动嵌入:false,
),
),

应用程序栏有一个名为centerTitle的属性,它将在应用程序栏中心添加标题

 centerTitle: true,

我希望这是你想要的

import 'package:flutter/material.dart';

const Color kRed = Colors.red;

class Test extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        title: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: <Widget>[
            Row(
              children: <Widget>[
                Icon(
                  Icons.menu,
                  color: kRed,
                  size: 30,
                ),
                SizedBox(width: 10),
                Icon(
                  Icons.search,
                  color: kRed,
                  size: 30,
                )
              ],
            ),
            Text(
              'Test Text',
              style: TextStyle(color: kRed, fontSize: 30),
            ),
            Row(
              children: <Widget>[
                Column(
                  children: <Widget>[
                    Text(
                      'Test Text',
                      style: TextStyle(color: kRed, fontSize: 15),
                    ),
                    Text(
                      'Test Text',
                      style: TextStyle(color: kRed, fontSize: 15),
                    ),
                  ],
                ),
                SizedBox(width: 10),
                Icon(
                  Icons.person,
                  color: kRed,
                  size: 30,
                )
              ],
            )
          ],
        ),
      ),
    );
  }
}
导入“包装:颤振/材料.省道”;
const Color kRed=Colors.red;
类测试扩展了无状态小部件{
@凌驾
小部件构建(构建上下文){
返回脚手架(
appBar:appBar(
标题:对,
标题:世界其他地区(
mainAxisAlignment:mainAxisAlignment.spaceBetween,
儿童:[
划船(
儿童:[
图标(
图标菜单,
颜色:克雷德,
尺码:30,
),
尺寸箱(宽度:10),
图标(
Icons.search,
颜色:克雷德,
尺码:30,
)
],
),
正文(
“测试文本”,
样式:TextStyle(颜色:kRed,字体大小:30),
),
划船(
儿童:[
纵队(
儿童:[
正文(
“测试文本”,
样式:TextStyle(颜色:kRed,字体大小:15),
),
正文(
“测试文本”,
样式:TextStyle(颜色:kRed,字体大小:15),
),
],
),
尺寸箱(宽度:10),
图标(
一个人,
颜色:克雷德,
尺码:30,
)
],
)
],
),
),
);
}
}


用图像控件替换中间的文本窗口小部件。并调整颜色。

试试这个

 flexibleSpace: Container(
          margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
          child: Center(
              child: Image(
            image: AssetImage('assets/img/icon_1.png'),
 ))),

需要具有类似于顶部图像的布局title属性有一个特定的空间,如果要在前导添加更多内容,则只能在该空间内使用,在AppBar中创建一行是可行的。并且可以使用
padding:EdgeInsets.all(14.0)