【发布时间】:2021-08-21 21:11:17
【问题描述】:
我在 SliverAppBar 和该特定选项卡内有一个 TabBar,有一个容器,该容器进一步从左到右在其中滑动,但是当我在屏幕内向左或向右滑动时,它会更改选项卡。假设,我在标签 1 上,如果我在容器内滑动,它会转到另一个标签。我怎么能阻止它?如果用户只按下顶部的应用栏,我只想从一个选项卡切换到另一个选项卡,如果它在屏幕内滑动,那应该没有任何效果。我已经尝试过 NeverScrollPhysics,但它只会停止应用栏并且在屏幕内没有任何区别。
下面是标签的代码:-
SafeArea(
child: NestedScrollView(
controller: _scrollViewController,
headerSliverBuilder: (BuildContext context, bool boxIsScrolled){
return <Widget>[
SliverAppBar(
automaticallyImplyLeading: false,
backgroundColor: Colors.transparent,
floating: true,
pinned: false,
snap: true,
title: TabBar(
isScrollable: true,
controller: _tabController,
unselectedLabelColor: Colors.blueGrey,
unselectedLabelStyle: TextStyle(fontSize: 15,fontWeight: FontWeight.w700 ),
labelColor: white,
indicatorSize: TabBarIndicatorSize.label,
indicator: BoxDecoration(
borderRadius: BorderRadius.circular(50),
color: mRed),
tabs: [
Tab(
child: Container(
child: Text("TAB 1",),
),
),
Tab(
child: Container(
child: Text("TAB 2",),
),
),
)
and so on......
【问题讨论】:
标签: flutter dart flutter-layout flutter-animation