### Install NestedScrollViewPlus Source: https://github.com/idootop/nested_scroll_view_plus/blob/main/README.md This command installs the nested_scroll_view_plus package using Flutter's package manager. Ensure you have Flutter installed and configured in your environment. ```shell flutter pub add nested_scroll_view_plus ``` -------------------------------- ### NestedScrollViewPlus with Loading Indicator (Dart) Source: https://github.com/idootop/nested_scroll_view_plus/blob/main/README.md This example shows how to implement a loading indicator, specifically a CupertinoSliverRefreshControl, at the top of the header slivers in NestedScrollViewPlus. The onRefresh callback can be used to fetch new data. ```dart NestedScrollViewPlus( overscrollBehavior: OverscrollBehavior.outer, headerSliverBuilder: (context, innerScrolled) => [ // Place the refresh indicator at the top of the header slivers CupertinoSliverRefreshControl( onRefresh: () async { // fetching data }, ), // Add your custom AppBar or other header sliver widgets here. ], // ... ) ``` -------------------------------- ### Initialize Flutter Web App with Service Worker Source: https://github.com/idootop/nested_scroll_view_plus/blob/main/example/web/index.html This script initializes the Flutter web application. It downloads the main Dart.js file and configures a service worker for caching and offline capabilities. The `loadEntrypoint` function is responsible for setting up the engine and running the application. ```javascript const serviceWorkerVersion = null; window.addEventListener('load', function(ev) { // Download main.dart.js _flutter.loader.loadEntrypoint({ serviceWorker: { serviceWorkerVersion: serviceWorkerVersion, }, onEntrypointLoaded: function(engineInitializer) { engineInitializer.initializeEngine().then(function(appRunner) { appRunner.runApp(); }); } }); }); ``` -------------------------------- ### Basic NestedScrollViewPlus Usage in Dart Source: https://github.com/idootop/nested_scroll_view_plus/blob/main/README.md This example demonstrates the basic integration of NestedScrollViewPlus. It involves replacing the standard NestedScrollView with NestedScrollViewPlus and setting the physics of the CustomScrollView to AlwaysScrollableScrollPhysics for proper overscroll behavior. ```dart import 'package:nested_scroll_view_plus/nested_scroll_view_plus.dart'; // Step 1: Replace `NestedScrollView` with `NestedScrollViewPlus` NestedScrollViewPlus( headerSliverBuilder: (context, innerScrolled) => [ // ... insert your header sliver widgets here ], body: CustomScrollView( // Step 2: [🚨IMPORTANT] Set the physics of `CustomScrollView` to `AlwaysScrollableScrollPhysics` physics: const BouncingScrollPhysics( parent: AlwaysScrollableScrollPhysics(), ), slivers: [ // ... insert your body sliver widgets here ], ), ); ``` -------------------------------- ### NestedScrollViewPlus Overscroll Behavior Configuration Source: https://context7.com/idootop/nested_scroll_view_plus/llms.txt Illustrates how to configure the `overscrollBehavior` property of NestedScrollViewPlus. It shows examples for `OverscrollBehavior.outer` for header pull-to-refresh and `OverscrollBehavior.inner` for body overscroll effects. ```dart import 'package:nested_scroll_view_plus/nested_scroll_view_plus.dart'; // Outer overscroll (default) - allows pull-to-refresh on header NestedScrollViewPlus( overscrollBehavior: OverscrollBehavior.outer, headerSliverBuilder: (context, innerScrolled) => [ CupertinoSliverRefreshControl( onRefresh: () async { await fetchData(); }, ), SliverAppBar( pinned: true, expandedHeight: 150.0, title: Text('Pull to Refresh'), ), ], body: CustomScrollView( physics: const BouncingScrollPhysics( parent: AlwaysScrollableScrollPhysics(), ), slivers: [ SliverList( delegate: SliverChildBuilderDelegate( (context, index) => ListTile(title: Text('Item $index')), childCount: 30, ), ), ], ), ) // Inner overscroll - overscroll effects on body content NestedScrollViewPlus( overscrollBehavior: OverscrollBehavior.inner, headerSliverBuilder: (context, innerScrolled) => [ SliverAppBar( pinned: true, expandedHeight: 150.0, title: Text('Inner Overscroll'), ), ], body: CustomScrollView( physics: const BouncingScrollPhysics( parent: AlwaysScrollableScrollPhysics(), ), slivers: [ SliverList( delegate: SliverChildBuilderDelegate( (context, index) => ListTile(title: Text('Item $index')), childCount: 30, ), ), ], ), ) ``` -------------------------------- ### Accessing Scroll Controllers in NestedScrollViewPlus (Dart) Source: https://github.com/idootop/nested_scroll_view_plus/blob/main/README.md This example demonstrates how to access the inner and outer scroll controllers of NestedScrollViewPlus using a GlobalKey. It involves creating a GlobalKey, assigning it to the NestedScrollViewPlus widget, and then using the key in initState to access the controllers and add listeners. ```dart class _ExampleState extends State { // 1. Create a GlobalKey final GlobalKey myKey = GlobalKey(); @override Widget build(BuildContext context) { return NestedScrollViewPlus( // 2. Set the key to NestedScrollViewStatePlus key: myKey, // ..., ); } @override void initState() { super.initState(); WidgetsBinding.instance.addPostFrameCallback((timeStamp) { // 3. Access the inner or outer scroll controller using GlobalKey myKey.currentState!.innerController.addListener(_handleInnerScroll); myKey.currentState!.outerController.addListener(_handleOuterScroll); }); } void _handleInnerScroll() { final innerController = myKey.currentState!.innerController; if (innerController.positions.length == 1) { print('Scrolling inner nested scrollview: ${innerController.offset}'); } } void _handleOuterScroll() { final outerController = myKey.currentState!.outerController; if (outerController.positions.length == 1) { print('Scrolling outer nested scrollview: ${outerController.offset}'); } } } ``` -------------------------------- ### Install Custom Nested Scroll View for Older Flutter Versions (Shell) Source: https://github.com/idootop/nested_scroll_view_plus/blob/main/README.md This code snippet shows how to add the custom_nested_scroll_view package to your Flutter project's dependencies. It utilizes Git dependencies, allowing you to specify a particular branch ('ref') that aligns with your local Flutter version. Ensure you select the correct branch to avoid compatibility issues. ```yaml dependencies: custom_nested_scroll_view: git: url: https://github.com/idootop/custom_nested_scroll_view.git # Choose the branch based on your local Flutter version ref: flutter-3.7 ``` -------------------------------- ### Preserving Scroll Positions with PageStorageKey (Dart) Source: https://github.com/idootop/nested_scroll_view_plus/blob/main/README.md This example shows how to preserve the scroll positions of inner CustomScrollViews within NestedScrollViewPlus. By assigning a unique PageStorageKey to the CustomScrollView, Flutter's PageStorage mechanism automatically handles storing and restoring the scroll position. ```dart CustomScrollView( key: PageStorageKey('your-unique-key'), slivers: [ // ..., ], ), ``` -------------------------------- ### Basic NestedScrollViewPlus Widget Implementation Source: https://context7.com/idootop/nested_scroll_view_plus/llms.txt Demonstrates the fundamental usage of NestedScrollViewPlus, integrating a SliverAppBar with a TabBarView. It highlights the importance of setting `AlwaysScrollableScrollPhysics` for inner scroll views to ensure proper scrolling behavior. ```dart import 'package:nested_scroll_view_plus/nested_scroll_view_plus.dart'; // Basic usage with SliverAppBar and TabBarView NestedScrollViewPlus( headerSliverBuilder: (context, innerScrolled) => [ SliverAppBar( pinned: true, expandedHeight: 200.0, flexibleSpace: FlexibleSpaceBar( title: Text('My App'), background: Image.network( 'https://example.com/header.jpg', fit: BoxFit.cover, ), ), bottom: TabBar( tabs: [Tab(text: 'Tab 1'), Tab(text: 'Tab 2')], ), ), ], body: TabBarView( children: [ CustomScrollView( // IMPORTANT: Set physics to AlwaysScrollableScrollPhysics physics: const BouncingScrollPhysics( parent: AlwaysScrollableScrollPhysics(), ), slivers: [ SliverList( delegate: SliverChildBuilderDelegate( (context, index) => ListTile(title: Text('Item $index')), childCount: 50, ), ), ], ), CustomScrollView( physics: const BouncingScrollPhysics( parent: AlwaysScrollableScrollPhysics(), ), slivers: [ SliverGrid( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, ), delegate: SliverChildBuilderDelegate( (context, index) => Card(child: Center(child: Text('Grid $index'))), childCount: 30, ), ), ], ), ], ), ) ``` -------------------------------- ### Integrate Pull-to-Refresh with CupertinoSliverRefreshControl in Flutter Source: https://context7.com/idootop/nested_scroll_view_plus/llms.txt Demonstrates how to add pull-to-refresh functionality to a NestedScrollViewPlus by placing CupertinoSliverRefreshControl at the top of the header slivers. This requires enabling outer overscroll behavior. ```dart import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:nested_scroll_view_plus/nested_scroll_view_plus.dart'; class PullToRefreshExample extends StatefulWidget { const PullToRefreshExample({super.key}); @override State createState() => _PullToRefreshExampleState(); } class _PullToRefreshExampleState extends State { List items = List.generate(20, (i) => 'Item ${i + 1}'); bool isLoading = false; Future _onRefresh() async { setState(() => isLoading = true); // Simulate network request await Future.delayed(const Duration(seconds: 2)); setState(() { items = List.generate(20, (i) => 'Refreshed Item ${i + 1}'); isLoading = false; }); } @override Widget build(BuildContext context) { return Scaffold( body: NestedScrollViewPlus( // Enable outer overscroll for pull-to-refresh overscrollBehavior: OverscrollBehavior.outer, headerSliverBuilder: (context, innerScrolled) => [ // Place refresh control at the top of header slivers CupertinoSliverRefreshControl( onRefresh: _onRefresh, builder: ( context, refreshState, pulledExtent, refreshTriggerPullDistance, refreshIndicatorExtent, ) { return Center( child: CupertinoActivityIndicator( radius: pulledExtent / 4, ), ); }, ), SliverAppBar( pinned: true, expandedHeight: 150.0, title: Text('Pull to Refresh'), flexibleSpace: FlexibleSpaceBar( background: Container( color: Colors.blue, child: Center( child: isLoading ? CircularProgressIndicator(color: Colors.white) : Icon(Icons.refresh, size: 48, color: Colors.white), ), ), ), ), ], body: CustomScrollView( physics: const BouncingScrollPhysics( parent: AlwaysScrollableScrollPhysics(), ), slivers: [ SliverList( delegate: SliverChildBuilderDelegate( (context, index) => ListTile( leading: CircleAvatar(child: Text('${index + 1}')), title: Text(items[index]), subtitle: Text('Subtitle for ${items[index]}'), ), childCount: items.length, ), ), ], ), ), ); } } ``` -------------------------------- ### Access NestedScrollViewPlus Scroll Controllers in Dart Source: https://context7.com/idootop/nested_scroll_view_plus/llms.txt This Dart code snippet demonstrates how to access the inner and outer scroll controllers of a NestedScrollViewPlus widget using a GlobalKey. It sets up listeners to print scroll offset and max extent information for both controllers and includes a function to programmatically scroll the outer controller to the top. ```dart import 'package:flutter/material.dart'; import 'package:nested_scroll_view_plus/nested_scroll_view_plus.dart'; class ScrollControllerExample extends StatefulWidget { const ScrollControllerExample({super.key}); @override State createState() => _ScrollControllerExampleState(); } class _ScrollControllerExampleState extends State { // Create a GlobalKey to access the NestedScrollViewStatePlus final GlobalKey _nestedScrollKey = GlobalKey(); @override void initState() { super.initState(); WidgetsBinding.instance.addPostFrameCallback((_) { // Access inner scroll controller _nestedScrollKey.currentState?.innerController.addListener(() { final innerController = _nestedScrollKey.currentState!.innerController; if (innerController.positions.length == 1) { print('Inner scroll offset: ${innerController.offset}'); print('Inner max extent: ${innerController.position.maxScrollExtent}'); } }); // Access outer scroll controller _nestedScrollKey.currentState?.outerController.addListener(() { final outerController = _nestedScrollKey.currentState!.outerController; if (outerController.positions.length == 1) { print('Outer scroll offset: ${outerController.offset}'); print('Outer max extent: ${outerController.position.maxScrollExtent}'); } }); }); } void _scrollToTop() { _nestedScrollKey.currentState?.outerController.animateTo( 0, duration: const Duration(milliseconds: 300), curve: Curves.easeOut, ); } @override Widget build(BuildContext context) { return Scaffold( body: NestedScrollViewPlus( key: _nestedScrollKey, headerSliverBuilder: (context, innerScrolled) => [ SliverAppBar( pinned: true, expandedHeight: 200.0, title: Text('Scroll Controller Demo'), ), ], body: CustomScrollView( physics: const BouncingScrollPhysics( parent: AlwaysScrollableScrollPhysics(), ), slivers: [ SliverList( delegate: SliverChildBuilderDelegate( (context, index) => ListTile(title: Text('Item $index')), childCount: 50, ), ), ], ), ), floatingActionButton: FloatingActionButton( onPressed: _scrollToTop, child: Icon(Icons.arrow_upward), ), ); } } ``` -------------------------------- ### Control Pinned Header Slivers with pushPinnedHeaderSlivers in Flutter Source: https://context7.com/idootop/nested_scroll_view_plus/llms.txt Illustrates how to use the pushPinnedHeaderSlivers property in NestedScrollViewPlus to control whether pinned header slivers are pushed off screen during scrolling. This is useful for creating unique visual effects with pinned app bars. ```dart import 'package:flutter/material.dart'; import 'package:nested_scroll_view_plus/nested_scroll_view_plus.dart'; // With pushPinnedHeaderSlivers enabled NestedScrollViewPlus( pushPinnedHeaderSlivers: true, headerSliverBuilder: (context, innerScrolled) => [ SliverAppBar( pinned: true, expandedHeight: 200.0, title: Text('Pushed Header'), flexibleSpace: FlexibleSpaceBar( stretchModes: [ StretchMode.zoomBackground, StretchMode.blurBackground, ], background: Image.network( 'https://example.com/background.jpg', fit: BoxFit.cover, ), ), ), ], body: CustomScrollView( physics: const BouncingScrollPhysics( parent: AlwaysScrollableScrollPhysics(), ), slivers: [ SliverList( delegate: SliverChildBuilderDelegate( (context, index) => ListTile(title: Text('Item $index')), childCount: 50, ), ), ], ), ) ``` -------------------------------- ### Preserve Scroll Positions in Flutter Tabs with PageStorageKey Source: https://context7.com/idootop/nested_scroll_view_plus/llms.txt This Flutter code snippet demonstrates how to preserve the scroll positions of inner CustomScrollViews within a NestedScrollViewPlus when using TabBarView. Each CustomScrollView is assigned a unique PageStorageKey, which allows Flutter to store and restore its scroll state when the user navigates between tabs or when the widget tree is rebuilt. This ensures a smooth user experience by preventing the scroll position from resetting. ```dart import 'package:flutter/material.dart'; import 'package:nested_scroll_view_plus/nested_scroll_view_plus.dart'; class TabScrollPreservation extends StatelessWidget { const TabScrollPreservation({super.key}); @override Widget build(BuildContext context) { return DefaultTabController( length: 3, child: Scaffold( body: NestedScrollViewPlus( headerSliverBuilder: (context, innerScrolled) => [ SliverAppBar( pinned: true, expandedHeight: 180.0, flexibleSpace: FlexibleSpaceBar(title: Text('Tab Demo')), bottom: TabBar( tabs: [ Tab(text: 'Recent'), Tab(text: 'Popular'), Tab(text: 'Favorites'), ], ), ), ], body: TabBarView( children: [ // Each tab uses PageStorageKey to preserve scroll position CustomScrollView( key: PageStorageKey('recent-tab'), physics: const BouncingScrollPhysics( parent: AlwaysScrollableScrollPhysics(), ), slivers: [ SliverList( delegate: SliverChildBuilderDelegate( (context, index) => ListTile( title: Text('Recent Item $index'), ), childCount: 30, ), ), ], ), CustomScrollView( key: PageStorageKey('popular-tab'), physics: const BouncingScrollPhysics( parent: AlwaysScrollableScrollPhysics(), ), slivers: [ SliverList( delegate: SliverChildBuilderDelegate( (context, index) => ListTile( title: Text('Popular Item $index'), ), childCount: 30, ), ), ], ), CustomScrollView( key: PageStorageKey('favorites-tab'), physics: const BouncingScrollPhysics( parent: AlwaysScrollableScrollPhysics(), ), slivers: [ SliverList( delegate: SliverChildBuilderDelegate( (context, index) => ListTile( title: Text('Favorite Item $index'), ), childCount: 30, ), ), ], ), ], ), ), ), ); } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.