在我这边,底部边框仍然显示。和这个问题有关https://github.com/flutter/flutter/issues/16262
所以我必须将 Scaffold 的背景设置为与子小部件的背景相同才能解决此问题。
这似乎只发生在某些手机上。
https://github.com/flutter/flutter/issues/16262#issuecomment-379071933
如果您将 Scaffold 的主体包含在 SizedBox.expand 小部件中,则
body 总是会填满剩余的空间。然后,正如你所指出的,
指定脚手架的背景颜色,隐藏问题。
-> 有问题
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(
controller: _scrollController,
slivers: <Widget>[
SliverAppBar(
pinned: true,
snap: false,
floating: false,
elevation: 0.0, // Remove AppBar bottom border
leading: new Container(),
titleSpacing: 0,
expandedHeight: 100.0,
flexibleSpace: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
top = constraints.biggest.height;
return FlexibleSpaceBar(
centerTitle: true,
titlePadding: EdgeInsets.zero,
title: top >= 86
? null
: topToolBarWidget(),
background: sliverBackgroundWidget()
);
})),
SliverList(
delegate: SliverChildListDelegate(
[
PromotionSlider()
],
),
),
],
));
}
-> 通过添加背景修复
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: appPrimaryColor, // <---- add here
body: CustomScrollView(
controller: _scrollController,
slivers: <Widget>[
SliverAppBar(
pinned: true,
snap: false,
floating: false,
elevation: 0.0, // Remove AppBar bottom border
leading: new Container(),
titleSpacing: 0,
expandedHeight: 100.0,
flexibleSpace: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
top = constraints.biggest.height;
return FlexibleSpaceBar(
centerTitle: true,
titlePadding: EdgeInsets.zero,
title: top >= 86
? null
: topToolBarWidget(),
background: sliverBackgroundWidget()
);
})),
SliverList(
delegate: SliverChildListDelegate(
[
PromotionSlider()
],
),
),
],
));
}