fluttercandies / extended_nested_scroll_view

extended nested scroll view to fix following issues. 1.pinned sliver header issue 2.inner scrollables in tabview sync issue 3.pull to refresh is not work. 4.do without ScrollController in NestedScrollView's body
MIT License
592 stars 119 forks source link

并不能完全解决多Tab滚动联动问题 #40

Closed CaiJingLong closed 3 years ago

CaiJingLong commented 4 years ago

只有当完全滚动至第二个TabView后, 才能"解除"多Tab的滚动联动问题

具体可以看附件内录制的视频

Kapture 2020-07-10 at 18.53.08.mp4.zip

插件版本号 1.0.1

flutter: 1.17.3

代码:

```dart import 'package:flutter/material.dart' hide NestedScrollView; import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, visualDensity: VisualDensity.adaptivePlatformDensity, ), home: MyHomePage(title: 'Flutter Demo Home Page'), ); } } class MyHomePage extends StatefulWidget { MyHomePage({Key key, this.title}) : super(key: key); final String title; @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State with SingleTickerProviderStateMixin { TabController tc; @override void initState() { super.initState(); tc = TabController(length: 4, vsync: this); tc.addListener(() { index = tc.index; }); } int index; @override void dispose() { tc.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return DefaultTabController( length: 4, child: Scaffold( body: NestedScrollView( headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { return [ SliverAppBar( pinned: true, floating: true, forceElevated: innerBoxIsScrolled, expandedHeight: 210.0, flexibleSpace: FlexibleSpaceBar( title: Text('你好'), background: Container( child: Text('我是内容'), ), ), ), ]; }, innerScrollPositionKeyBuilder: () { return Key(index.toString()); }, body: TabBarView( controller: tc, children: [ _buildList(tc, 0), _buildList(tc, 1), _buildList(tc, 2), _buildList(tc, 3), ], ), ), ), ); } _buildList(TabController tc, int index) { return Content(index: index); } } class Content extends StatefulWidget { final int index; const Content({ Key key, this.index, }) : super(key: key); @override ContentState createState() => ContentState(); } class ContentState extends State with AutomaticKeepAliveClientMixin { Key key; @override void initState() { key = Key(widget.index.toString()); super.initState(); } @override Widget build(BuildContext context) { super.build(context); return NotificationListener( onNotification: (notification) { return true; }, child: NestedScrollViewInnerScrollPositionKeyWidget( key, ListView.builder( itemBuilder: (context, index) { return ListTile( title: Text(index.toString()), ); }, ), ), ); } @override bool get wantKeepAlive => true; } ```
zmtzawqlp commented 4 years ago

1.17.0 需要再研究

zplblue commented 3 years ago

所以有对后续的版本提供支持吗?

clong1995 commented 3 years ago

同样遇到了这个问题