Created
March 19, 2020 11:42
-
-
Save joramkimata/4220f34d401de832494e161d15c34175 to your computer and use it in GitHub Desktop.
Draggable Scrollbar App
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:draggable_scrollbar/draggable_scrollbar.dart'; | |
import 'package:flutter/material.dart'; | |
main() => runApp(MyApp()); | |
class MyApp extends StatefulWidget { | |
@override | |
State<StatefulWidget> createState() { | |
return _MyApp(); | |
} | |
} | |
class _MyApp extends State<MyApp> { | |
ScrollController _controller = ScrollController(); | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: Scaffold( | |
appBar: AppBar( | |
title: Text("Draggable App"), | |
), | |
body: Container( | |
child: DraggableScrollbar.arrows( | |
labelTextBuilder: (double offset) => Text("${offset ~/ 100}"), | |
controller: _controller, | |
child: ListView.builder( | |
controller: _controller, | |
itemCount: 1000, | |
itemExtent: 100.0, | |
itemBuilder: (context, index) { | |
return Container( | |
padding: EdgeInsets.all(8.0), | |
child: Material( | |
elevation: 4.0, | |
borderRadius: BorderRadius.circular(4.0), | |
color: Colors.purple[index % 9 * 100], | |
child: Center( | |
child: Text(index.toString()), | |
), | |
), | |
); | |
}, | |
), | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment