Skip to content

Instantly share code, notes, and snippets.

@justinmc
Last active February 10, 2022 13:54
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/3c58cb125644b230fe66832b0ea541c2 to your computer and use it in GitHub Desktop.
Save justinmc/3c58cb125644b230fe66832b0ea541c2 to your computer and use it in GitHub Desktop.
Example of an iOS13-style draggable scrollbar in Flutter
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(
navigationBar: CupertinoNavigationBar(
middle: Text('Draggable Scrollbar Demo'),
),
child: Column(
children: <Widget>[
Container(
height: 300,
child: PrimaryScrollController(
controller: scrollController,
child: CupertinoScrollbar(
controller: scrollController,
child: ListView(
controller: scrollController,
children: _getList(120),
),
),
),
),
],
),
),
);
}
}
@Alamirew
Copy link

I like this app.

@Alamirew
Copy link

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment