Usecase - In my app screen I need a scrollview(outer scrollview) with 3 card(fixed size) the last card contains Tabbarview inside of which I need a scroll view (inner scrollview).
For scrollviews I used Listview.builder.
For more clearance the tree structure is like this ( -> = has a): scroll view -> state object -> container -> column -> TabBarview -> scroll view.
Error - The problem of below code is when I reached to the top of the inner listview view the outer listview supposed to scroll but it is not scrolling.
In other word outter scrollview is not notified by the inner scrollview to move. They are unable to communicate.
I already tried : 1 Give common Scrollcontroller to both Listviews.
2 I also tried Listview.custom with slivers.
ScrollController scrollController =ScrollController();
class Share extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
key: PageStorageKey<String>('botttomTabbar1'),
color: BgColor,
child: ListView.custom(
padding: EdgeInsets.symmetric(
horizontal: 10,
vertical: 10,
),
controller: scrollController,
childrenDelegate: SliverChildBuilderDelegate(
(context,index){
return SharableLinks();
},childCount: 1
),
),
);
}
}
class SharableLinks extends StatefulWidget {
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return _SharableLinksSate();
}
}
class _SharableLinksSate extends State<SharableLinks>
with SingleTickerProviderStateMixin {
int _selectedIndex = 0;
List<PopularLinkData> data = List();
TabController _tabController;
@override
void initState() {
// TODO: implement initState
super.initState();
data.add(PopularLinkData(
descrption: 'Description.............',
heading: 'Headline goes here',
viewCount: 234,
));
_tabController = TabController(length: 2, vsync: this);
}
@override
void dispose() {
// TODO: implement dispose
_tabController.dispose();
super.dispose();
}
void _onItemTapped(int index) {
setState(() {
_selectedIndex = index;
});
}
Widget build(BuildContext context) {
// TODO: implement build
return Container(
margin: EdgeInsets.fromLTRB(0, 10, 0, 35),
height: 386,
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.rectangle,
borderRadius: BorderRadius.all(Radius.circular(10)),
boxShadow: <BoxShadow>[
BoxShadow(
color: Color(0xFFC6D0EB),
blurRadius: 8,
offset: Offset(0, 4)
)
],
),
child: Column(
children: <Widget>[
TabBar(
indicatorWeight: .0001,
labelPadding: EdgeInsets.all(0),
controller: _tabController,
tabs: <Tab>[
Tab(
child: ClipRRect(
borderRadius: BorderRadius.only(topLeft: Radius.circular(10)),
child: Container(
alignment: Alignment.center,
color: _selectedIndex == 0 ? Colors.white : Color(0xFFD8DDEB),
child: Text(
'Popular',
style: TextStyle(color: PrimaryTextColor,
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
),
),
),
Tab(
child: ClipRRect(
borderRadius: BorderRadius.only(topRight: Radius.circular(10)),
child: Container(
height: double.infinity,
width: double.infinity,
alignment: Alignment.center,
color: _selectedIndex == 1 ? Colors.white : Color(0xFFD8DDEB),
child: Text(
'Generate',
style: TextStyle(color: PrimaryTextColor,
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
),
),
),
],
onTap: _onItemTapped,
),
Expanded(
child: Container(
child: TabBarView(
key: PageStorageKey<String>('linksTabBar'),
physics: NeverScrollableScrollPhysics(),
controller: _tabController,
children: <Widget>[
,
ScrollConfiguration(
behavior: MyBehavior(),
child:
ListView.builder(
controller:scrollController,
padding: EdgeInsets.symmetric(horizontal: 15),
itemBuilder: (context, index) {
return _populerLinks(data[index]);
},
itemCount: data.length,
),
),
_generateLinks(),
],
),
),
),
],
),
);
}
}