Skip to content

Incorrect implementation of ScrollMetrics.extentInside getter  #31430

Closed

Description

@radzish

Steps to Reproduce

See following test:

import 'package:flutter/widgets.dart';
import 'package:test/test.dart';

void main() {
  test('Expect correct extent metrics when max scroll extent is less than viewport dimension', () {

    // Given
    ScrollMetrics metrics = FixedScrollMetrics(
      axisDirection: AxisDirection.down,
      // User scrolled 1 pixel
      pixels: 1,
      // Viewport is 100
      viewportDimension: 100,
      minScrollExtent: 0,
      // User can scroll max 10 pixels
      maxScrollExtent: 10,
    );

    // Extent before is 1, which is correct
    expect(metrics.extentBefore, 1);

    // Extent inside fails here.
    // According to documentation
    // extentInside should be viewport height
    // as extentBefore and extentAfter are non-zero
    // But it is 10, not 100
    expect(metrics.extentInside, 100);

    // Extent after is 9, which is correct
    expect(metrics.extentAfter, 9);
  });
}

On UI it will cause scroll thumb to be always half height of the viewport in cases when there is no too much to scroll.
In those cases scroll thumb should be close to viewport height.

[✓] Flutter (Channel stable, v1.2.1, on Linux, locale en_US.UTF-8)

Activity

  1. added this to the May 2019 milestone on Apr 25, 2019
  2. github-actions commented on Aug 29, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  3. locked as resolved and limited conversation to collaborators on Aug 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

frameworkflutter/packages/flutter repository. See also f: labels.

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions