Skip to content

Instantly share code, notes, and snippets.

@justinmc
Created September 16, 2019 17:04
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 justinmc/0f88d7e24add6e265a9bba2820f532b8 to your computer and use it in GitHub Desktop.
Save justinmc/0f88d7e24add6e265a9bba2820f532b8 to your computer and use it in GitHub Desktop.
An example of using iOS 13's draggable scrollbar with a CustomScrollView
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