Skip to content

Instantly share code, notes, and snippets.

@bryar323
Forked from dhuma1981/scrollbar_demo.dart
Created April 22, 2020 10:02
Show Gist options
  • Save bryar323/fbdbd2ee68ea4271546b362d24bb127a to your computer and use it in GitHub Desktop.
Save bryar323/fbdbd2ee68ea4271546b362d24bb127a to your computer and use it in GitHub Desktop.
Show scrollbar in ListView
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
final ScrollController _scrollController = ScrollController();
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: Scrollbar(
isAlwaysShown: true,
controller: _scrollController,
child: ListView.builder(
controller: _scrollController,
itemCount: 100,
itemBuilder: (context, index) {
return Card(
child: ListTile(
title: Text("Item: ${index + 1}"),
));
}),
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment