Closed
Description
The track offset of the scrollbar is not calculated correctly. It only accounts for the main axis margin and does not include the main axis padding.
In the image you can see the green track up in the status bar area, and below it ends short of the viewport.
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
scrollBehavior: MaterialScrollBehavior().copyWith(scrollbars: false),
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.amber),
scrollbarTheme: ScrollbarThemeData(
thumbColor: MaterialStateProperty.all(Colors.amber),
trackColor: MaterialStateProperty.all(Colors.green),
thumbVisibility: MaterialStateProperty.all(true),
trackVisibility: MaterialStateProperty.all(true),
)
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Scrollbar(
child: Center(
child: CustomScrollView(
primary: true,
slivers: [
const SliverAppBar(
title: Text('Ta-Da'),
backgroundColor: Colors.blue,
),
SliverList(
delegate: SliverChildBuilderDelegate(
(c, i) => Container(height: 50, child: Center(child: Text('Item $i'))),
childCount: 50,
),
)
]
),
),
),
);
}
}
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 3.1.0-0.0.pre.1384, on macOS 12.4 21F79 darwin-x64, locale en)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0-rc2)
[✓] Xcode - develop for iOS and macOS (Xcode 13.3.1)
[✓] Chrome - develop for the web
[✓] Android Studio
[✓] Android Studio (version 2020.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2021.3.3)
[✓] VS Code (version 1.68.1)
[✓] Connected device (4 available)
[✓] HTTP Host Availability