Skip to content

Instantly share code, notes, and snippets.

@joramkimata
Created March 19, 2020 11:42
Show Gist options
  • Save joramkimata/4220f34d401de832494e161d15c34175 to your computer and use it in GitHub Desktop.
Save joramkimata/4220f34d401de832494e161d15c34175 to your computer and use it in GitHub Desktop.
Draggable Scrollbar App
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