I am working on a Flutter project and want to implement a functionality where the scrollbar is hidden when the page loads and is only displayed when the user starts scrolling. I have tried a few approaches, but I'm encountering difficulties. Here is my current code:
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:rashi/widgets/spacer.dart';
class Account extends ConsumerWidget {
const Account({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
return Scaffold(
body: CustomScrollView(
slivers: <Widget>[
const SliverAppBar(
pinned: false,
snap: true,
floating: true,
title: Text('Account'),
),
SliverList(
delegate: SliverChildBuilderDelegate(
/// This is test generated list
(context, index) => ListTile(title: Text('Item #$index')),
// Builds 1000 ListTiles
childCount: 100,
),
),
],
),
);
}
}
If anyone has experience with implementing this type of scrollbar behavior in Flutter, I would greatly appreciate any guidance or solutions you can offer.
This is what I'm expecting: