Flutter 滑动条-滑动条列表一直滚动到顶部
我目前正在使用SliverAppBar,滚动sliverList时遇到问题 在上面的图片中,我的选项卡栏一直延伸到通知栏。当sliverAppBar崩溃时,我希望我的Tabbar粘在AppBar的底部 这是我正在尝试的代码Flutter 滑动条-滑动条列表一直滚动到顶部,flutter,dart,flutter-layout,flutter-sliver,flutter-appbar,Flutter,Dart,Flutter Layout,Flutter Sliver,Flutter Appbar,我目前正在使用SliverAppBar,滚动sliverList时遇到问题 在上面的图片中,我的选项卡栏一直延伸到通知栏。当sliverAppBar崩溃时,我希望我的Tabbar粘在AppBar的底部 这是我正在尝试的代码 return Scaffold( body: CustomScrollView( slivers: <Widget>[ SliverAppBar( //backgroundColor: Colors.transp
return Scaffold(
body: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
//backgroundColor: Colors.transparent,
actions: <Widget>[
IconButton(icon: Icon(Icons.favorite), onPressed: () {}),
IconButton(icon: Icon(Icons.share), onPressed: () {})
],
floating: false,
pinned: true,
expandedHeight: getHeight(context),
flexibleSpace: FlexibleSpaceBar(
title: Text("text"),
background: Container(
height: double.infinity,
width: double.infinity,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(currentImage),
fit: BoxFit.cover)),
),
),
),
SliverList(
delegate: SliverChildListDelegate(bottomListView),
),
],
)
,
);
返回脚手架(
正文:自定义滚动视图(
条子:[
滑杆(
//背景颜色:颜色。透明,
行动:[
图标按钮(icon:icon(Icons.favorite),按下:(){}),
图标按钮(icon:icon(Icons.share),onPressed:(){})
],
浮动:假,
对,,
expandedHeight:getHeight(上下文),
flexibleSpace:FlexibleSpaceBar(
标题:文本(“文本”),
背景:集装箱(
高度:双无限,
宽度:double.infinity,
装饰:盒子装饰(
图像:装饰图像(
图像:资产评估(当前图像),
安装:BoxFit.盖),
),
),
),
银表(
委托:SliverChildListDelegate(bottomListView),
),
],
)
,
);
这可能是一个bug:
所以你可以使用它,它解决了这个问题。只需使用SliverAppBar的底部参数并将TabBar传递给它。在FlexibleSpaceBar中,添加标题添加以从选项卡栏添加填充。如果需要更改选项卡栏的颜色,可以进行检查
请注意FlexibleSpaceBar中的标题和AppBar中的动作图标,因为长标题将导致最小化AppBar中的重叠
child:CustomScrollView(
条子:[
滑杆(
//背景颜色:颜色。透明,
行动:[
图标按钮(icon:icon(Icons.favorite),按下:(){}),
图标按钮(icon:icon(Icons.share),onPressed:(){})
],
浮动:假,
对,,
expandedHeight:getHeight(上下文),
flexibleSpace:FlexibleSpaceBar(
标题:文本(“文本”),
//从选项卡栏添加填充
标题添加:仅限边集(底部:64,左侧:60),
背景:集装箱(
高度:双无限,
宽度:double.infinity,
装饰:盒子装饰(
图像:装饰图像(
图像:资产评估(当前图像),
安装:BoxFit.盖),
),
),
//将TabBar添加到SliverAppBar的底部
底部:选项卡栏(
选项卡:[
对于(变量i=0;i<3;i++)
标签(
文本:“测试$i”,
),
]
),
),
银表(
委托:SliverChildListDelegate(bottomListView),
),
],
),
是否希望TabBar始终位于appbar下?@igorkharkhordin是的……我用容器包装了TabBarVIew,并将其涂成白色。所以,我不必改变整个应用程序的原色。这是另一种方式。。。但是,它很有效,谢谢。。。