Skip to content

Instantly share code, notes, and snippets.

@Piinks
Created January 2, 2020 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Piinks/5a733d302b93f7f4a9f782c8b645ab6b to your computer and use it in GitHub Desktop.
Save Piinks/5a733d302b93f7f4a9f782c8b645ab6b to your computer and use it in GitHub Desktop.
NestedScrollView Solution
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