从FlexibleSpace标题中删除默认填充

4 dart flutter

在此输入图像描述

代码:

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())),
  ],
);
Run Code Online (Sandbox Code Playgroud)

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

use*_*437 7

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

      flexibleSpace: FlexibleSpaceBar(
              title: Text('Home'),
              titlePadding: EdgeInsetsDirectional.only(
                start: 0.0,
                bottom: 16.0,
              ),
            ),
Run Code Online (Sandbox Code Playgroud)