颤振-在嵌套ScrollView中滚动/滑动TabBar时出现问题
我实现了颤振-在嵌套ScrollView中滚动/滑动TabBar时出现问题,scroll,flutter,dart,tabbar,nestedscrollview,Scroll,Flutter,Dart,Tabbar,Nestedscrollview,我实现了TabBar,其中TabbarView是动态的,除了NestedScrollView。当我想尝试滑动选项卡时,选项卡视图上的位置没有响应。即使我已将isScrollable设置为true 我的代码 @override Widget build(BuildContext context) { return ScopedModelDescendant<MainModel>( builder: (context, child, model) {
TabBar
,其中TabbarView
是动态的,除了NestedScrollView
。当我想尝试滑动选项卡时,选项卡视图
上的位置没有响应。即使我已将isScrollable设置为true
我的代码
@override
Widget build(BuildContext context) {
return ScopedModelDescendant<MainModel>(
builder: (context, child, model) {
return Scaffold(
// backgroundColor: Colors.red,
body: NestedScrollView(
headerSliverBuilder:
(BuildContext context, bool innerBoxIsScrolled) {
return [
SliverAppBar(
pinned: false,
backgroundColor: Colors.white,
flexibleSpace: FlexibleSpaceBar(
collapseMode: CollapseMode.pin,
background: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SizedBox(height: 5),
_buildBackBtn(context),
SizedBox(height: 20),
_buildCarouselLabel(),
SizedBox(height: 15),
Container(
margin: model.isLoadingKnowledge ||
model.carouselList
.where((carousel) =>
carousel.relationships
.category.attr.name ==
_selectedTab.attributes.name)
.toList()
.length ==
0
? EdgeInsets.only(top: 60)
: EdgeInsets.zero,
alignment: Alignment.center,
child: model.isLoadingKnowledge
? Center(child: CircularProgressIndicator())
: model.carouselList
.where((carousel) =>
carousel.relationships
.category.attr.name ==
_selectedTab.attributes.name)
.toList()
.length ==
0
? Center(
child: Text(
"There is no carousel on ${_selectedTab.attributes.label}"))
: KnowledgeImageSlider(_selectedTab)),
SizedBox(height: 15),
],
),
),
expandedHeight: 380.0,
bottom: TabBar(
labelColor: Colors.grey[700],
unselectedLabelColor: Colors.grey[400],
controller: _tabController,
indicatorColor: Color(0xff3FBCD7),
indicatorSize: TabBarIndicatorSize.tab,
indicatorWeight: 3.0,
isScrollable: true,
labelStyle: TextStyle(
fontSize: 16,
height: 2.2,
fontWeight: FontWeight.w500,
color: Colors.white),
// indicator: ShapeDecoration(
// // color: Colors.white,
// shape: const StadiumBorder(
// side: BorderSide(
// color: Colors.white,
// width: 2.0,
// ),
// ) +
// const StadiumBorder(
// side: BorderSide(
// color: Colors.transparent,
// width: 8.0,
// ),
// ),
// ),
tabs: model.knowledgeCategoryList
.map((cat) => Tab(text: cat.attributes?.label))
.toList(),
),
)
];
},
body: model.isLoadingKnowledge
? Center(child: CircularProgressIndicator())
: ListView.builder(
itemCount: model.knowledgeList
.where((article) =>
article.relationships.category.attr.label ==
_selectedTab.attributes.label ??
"Picks")
.toList()
.length,
itemBuilder: (context, i) {
var article = model.knowledgeList
.where((article) =>
article.relationships.category.attr.label ==
_selectedTab.attributes?.label ??
"PICKS")
.toList()[i];
return ArticleItemCard(article);
},
)),
);
},
);
}
@覆盖
小部件构建(构建上下文){
返回范围modeldescendant(
生成器:(上下文、子对象、模型){
返回脚手架(
//背景颜色:Colors.red,
正文:嵌套滚动视图(
班主任:
(BuildContext上下文,boolInnerBoxIsCrowled){
返回[
滑杆(
错,,
背景颜色:Colors.white,
flexibleSpace:FlexibleSpaceBar(
collapseMode:collapseMode.pin,
背景:专栏(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
尺寸箱(高度:5),
_buildBackBtn(上下文),
尺寸箱(高度:20),
_buildCarouselLabel(),
尺寸箱(高度:15),
容器(
页边距:model.isLoadingKnowledge||
模型旋转木马
。其中((旋转木马)=>
旋转木马
.category.attr.name==
_selectedTab.attributes.name)
托利斯先生()
.长度==
0
?仅限边缘设置(顶部:60)
:EdgeInsets.zero,
对齐:对齐.center,
子项:model.isLoadingKnowledge
?中心(子项:循环压缩机指示器())
:model.carouselList
。其中((旋转木马)=>
旋转木马
.category.attr.name==
_selectedTab.attributes.name)
托利斯先生()
.长度==
0
?中心(
子:文本(
“${u selectedTab.attributes.label}”上没有旋转木马)
:KnowledgeImageSlider(_selectedTab)),
尺寸箱(高度:15),
],
),
),
扩展高度:380.0,
底部:选项卡栏(
labelColor:颜色。灰色[700],
未选择的标签颜色:颜色。灰色[400],
控制器:\ tab控制器,
指示颜色:颜色(0xff3FBCD7),
指标化:TabBarIndicatorSize.tab,
指示器重量:3.0,
isScrollable:是的,
标签样式:文本样式(
尺寸:16,
身高:2.2,
fontWeight:fontWeight.w500,
颜色:颜色。白色),
//指标:形状装饰(
////颜色:Colors.white,
//形状:康斯特·斯塔迪翁博德(
//边线(
//颜色:颜色,白色,
//宽度:2.0,
// ),
// ) +
//康斯特斯塔迪翁博德酒店(
//边线(
//颜色:颜色。透明,
//宽度:8.0,
// ),
// ),
// ),
选项卡:model.knowledgeCategoryList
.map((cat)=>选项卡(文本:cat.attributes?.label))
.toList(),
),
)
];
},
正文:model.isLoadingKnowledge
?中心(子项:循环压缩机指示器())
:ListView.builder(
itemCount:model.knowledgeList
.其中((文章)=>
article.relationships.category.attr.label==
_已选择Tab.attributes.label??
“挑选”)
托利斯先生()
.长度,
itemBuilder:(上下文,i){
var article=model.knowledgeList
.其中((文章)=>
article.relationships.category.attr.label==
_已选择选项卡。属性?标签??
“挑选”)
.toList()[i];
退货物品卡片(物品);
},
)),
);
},
);
}
结果:
如何使其像平常一样滚动/滑动选项卡
如有任何答复,将不胜感激。