代码:
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
也没有改变任何东西。
最佳答案
您现在可以像这样使用 titlePadding
属性:
flexibleSpace: FlexibleSpaceBar(
title: Text('Home'),
titlePadding: EdgeInsetsDirectional.only(
start: 0.0,
bottom: 16.0,
),
),
关于dart - 从 FlexibleSpace 标题中删除默认填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52964508/