Flutter Appbar标题灰色背景显示

标签 flutter flutter-layout

Flutter AppBar 自定义 View ,标题小部件在签名构建中覆盖灰色背景,调试构建工作正常。

title widget自定义 View 源码分享如下,请查收

_getAppbar(AppTheme themeData) {

return AppBar(
  titleSpacing: 0,
  centerTitle: false,
  leading: Container(
    //color: Colors.blue,
    margin: EdgeInsets.only(left: 15),
    child: CircleAvatar(
      radius: 30.0,
      child: SvgPicture.asset(
        "assets/svg/man.svg",
        width: 30,
        height: 30,
      ),
      //backgroundColor: Colors.red,
    ),
  ),
  title: Container(
    margin: EdgeInsets.only(left: 10),
    alignment: Alignment.centerLeft,
    color: Colors.transparent,
    child: Expanded(
        child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            mainAxisAlignment: MainAxisAlignment.start,
            children: <Widget>[
          Text(
            "Hi, Vikky",
            style: TextStyle(
                fontSize: 9,
                fontWeight: fontRegular,
                color: Color(themeData.headerNameColor)),
          ),
          Wrap(crossAxisAlignment: WrapCrossAlignment.center, children: [
            Icon(
              Icons.location_on,
              size: 12,
              color: Color(themeData.brandColor),
            ),
            Text(
              "Kuzhikkattu Moola",
              style: TextStyle(
                  fontSize: 12,
                  fontWeight: fontMedium,
                  color: Color(themeData.textColor)),
            )
          ]),
        ])),
  ),
  backgroundColor:Colors.transparent,
  elevation: 0,
);

} enter image description here

enter image description here

调试构建工作正常,仅在签名构建中发布。

最佳答案

此问题与不正确使用 ParentDataWidget 有关,与颜色无关。 这个问题似乎只出现在 Release模式而不是构建模式

Container(
    margin: EdgeInsets.only(left: 10),
    alignment: Alignment.centerLeft,
    color: Colors.transparent,
    child: Expanded( //Issue is here Incorrect use of Expanded Widget
        child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            mainAxisAlignment: MainAxisAlignment.start,
            children: <Widget>[
          Text(
            "Hi, Vikky",
            style: TextStyle(
                fontSize: 9,
                fontWeight: fontRegular,
                color: Color(themeData.headerNameColor)),
          ),
          Wrap(crossAxisAlignment: WrapCrossAlignment.center, children: [
            Icon(
              Icons.location_on,
              size: 12,
              color: Color(themeData.brandColor),
            ),
            Text(
              "Kuzhikkattu Moola",
              style: TextStyle(
                  fontSize: 12,
                  fontWeight: fontMedium,
                  color: Color(themeData.textColor)),
            )
          ]),
        ])),
  ),

尝试通过替换小部件 - Expanded 来管理您的 UI。 通过此链接:Incorrect use of Parent Data Widget

关于Flutter Appbar标题灰色背景显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66304502/

相关文章:

firebase - 方法 'sendEmailVerification' 没有为类型 'UserCredential' 定义。 Firebase flutter

flutter - 如何在 SliverList 周围包裹卡片?

android-studio - 如何在Flutter中使用容器内的扩展 block ?

android - 如何在 Flutter 中删除 Firebase 云消息传递 token

fonts - 如何在 Flutter 中居中对齐文本?

android - 如果一个文本行很长,如何使盒子中的弹性 flutter 以使每一行居中?

flutter - 向 TableRow 添加填充

flutter - 如何更改 Flutter 底部导航栏中的 SVG 图标?

flutter - ListTile 中的前导图像溢出

Flutter:如何弹出对话框以及当前页面?