Created
September 16, 2019 17:04
-
-
Save justinmc/0f88d7e24add6e265a9bba2820f532b8 to your computer and use it in GitHub Desktop.
An example of using iOS 13's draggable scrollbar with a CustomScrollView
This file contains 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/cupertino.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
static List<Widget> _getList(int length) { | |
final List<Widget> list = List<Widget>(length); | |
for (int i = 0; i < length; i++) { | |
list[i] = _getListItem(i); | |
} | |
return list; | |
} | |
static Widget _getListItem(int i) { | |
return Text('list item $i'); | |
} | |
@override | |
Widget build(BuildContext context) { | |
final ScrollController scrollController = ScrollController(); | |
return CupertinoApp( | |
title: 'Flutter Demo', | |
home: CupertinoPageScaffold( | |
child: Column( | |
children: <Widget>[ | |
Container( | |
height: 600, | |
child: PrimaryScrollController( | |
controller: scrollController, | |
child: CupertinoScrollbar( | |
controller: scrollController, | |
child: CustomScrollView( | |
slivers: <Widget>[ | |
SliverFixedExtentList( | |
itemExtent: 50.0, | |
delegate: SliverChildListDelegate(_getList(100)), | |
), | |
], | |
), | |
), | |
), | |
), | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment