Created
January 2, 2020 19:18
-
-
Save Piinks/5a733d302b93f7f4a9f782c8b645ab6b to your computer and use it in GitHub Desktop.
NestedScrollView Solution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: Scaffold( | |
appBar: AppBar(title: Text('Demo')), | |
body: NestedScrollView( | |
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { | |
// These are the slivers that show up in the "outer" scroll view. | |
return <Widget>[ | |
// SliverToBoxAdapter, etc. | |
SliverFixedExtentList( | |
itemExtent: 48.0, | |
delegate:SliverChildBuilderDelegate( | |
(BuildContext context, int index) => ListTile(title: Text('Item $index')), | |
childCount: 30, | |
), | |
), | |
]; | |
}, | |
// These are the boxes that show up in the "inner" scroll view. | |
body: ListView.builder( | |
padding: const EdgeInsets.all(8), | |
itemCount: 60, | |
itemBuilder: (BuildContext context, int index) => Container( | |
height: 50, | |
child: Center(child: Text('Entry $index')), | |
), | |
), | |
), | |
) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment