Skip to content

ScrollBar moves slower than the mouse when dragging it to scroll #112072

@knopp

Description

@knopp

This one is bit different from #111968. It happens with current main in cases where SliverList items extents keep increasing.

Main reason for this is that ScrollBar._updateScrollPosition adjusts viewport position by using relative scroll offset. In pathological cases like this the error keeps increasing to the point where not even overdrag is enough to reach end.

I'm wondering why ScrollBar is written like that. Setting pixels to minExtent + (absoluteScrollPosition * (maxExtent - minExtent)) would alleviate this (absoluteScrollPosition being in range of 0.0-1.0). But I'm not sure how this would work with overdrag.

import 'package:flutter/material.dart';

void main() {
  runApp(const MaterialApp(
    title: 'Flutter Demo',
    home: MyHomePage(),
  ));
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: CustomScrollView(
        slivers: [
          SliverToBoxAdapter(
            child: Container(
              height: 2,
              color: Colors.red,
            ),
          ),
          SliverList(
            delegate: SliverChildBuilderDelegate(
              (context, index) => Padding(
                padding: const EdgeInsets.all(10),
                child: Container(
                  color: Colors.green,
                  height: index.toDouble(),
                ),
              ),
              childCount: 1000,
            ),
          ),
          SliverToBoxAdapter(
            child: Container(
              height: 2,
              color: Colors.red,
            ),
          ),
        ],
      ),
    );
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: desktopRunning on desktopf: scrollingViewports, list views, slivers, etc.found in release: 3.3Found to occur in 3.3found in release: 3.4Found to occur in 3.4frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: 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