首页 > 解决方案 > 从 FlexibleSpace 标题中删除默认填充

问题描述

在此处输入图像描述

代码:

CustomScrollView(
  slivers: <Widget>[
    SliverAppBar(
      expandedHeight: 200.0,
      flexibleSpace: FlexibleSpaceBar(
        title: Container(color: Colors.red, child: Text("Flexible title")),
        background: Image.asset("assets/chocolate.jpg", fit: BoxFit.cover),
      ),
    ),
    SliverList(delegate: SliverChildListDelegate(_buildChildren())),
  ],
);

为什么标题中有默认填充。我曾经Container带来对比度,以便可以轻松看到边缘。即使我尝试使用centerTitle: false它也没有改变任何东西。

标签: dartflutter

解决方案


您现在可以titlePadding像这样使用该属性:

      flexibleSpace: FlexibleSpaceBar(
              title: Text('Home'),
              titlePadding: EdgeInsetsDirectional.only(
                start: 0.0,
                bottom: 16.0,
              ),
            ),

推荐阅读