Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Scrollbar track offset does not account for padding #106834

Closed
@Piinks

Description

@Piinks

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.

Screen Shot 2022-06-29 at 6 38 18 PM

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

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work lista: qualityA truly polished experiencef: scrollingViewports, list views, slivers, etc.r: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions