Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[two_dimensional_scrollables] childPositionGetter in Tableview.builder #148141

Open
faisalansari0367 opened this issue May 10, 2024 · 1 comment · May be fixed by flutter/packages#6745
Open

[two_dimensional_scrollables] childPositionGetter in Tableview.builder #148141

faisalansari0367 opened this issue May 10, 2024 · 1 comment · May be fixed by flutter/packages#6745
Labels
c: new feature Nothing broken; request for a new capability c: proposal A detailed proposal for a change to Flutter f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. p: two_dimensional_scrollables Issues pertaining to the two_dimensional_scrollables package P3 Issues that are less important to the Flutter project package flutter/packages repository. See also p: labels. team-framework Owned by Framework team triaged-framework Triaged by Framework team

Comments

@faisalansari0367
Copy link
Contributor

faisalansari0367 commented May 10, 2024

Use case

RPReplay_Final1715363832.MP4

In the video, I demonstrated the need to make the spot price stick to both the top and bottom. Achieving this requires knowing the element's position in the viewport or having a built-in feature that allows elements to stick to the top or bottom.

I forked the package and included additional code to determine the element's position. However, integrating such functionality directly into the package would greatly facilitate the creation of complex UIs, making the development process more efficient and user-friendly.

Proposal

void _getChildPosition({
    required double rowOffset,
    required double standardRowHeight,
  }) {
    if (childPositionGetter == null) {
      return;
    }

    
    final double offset = rowOffset;

    final double percent;
    if ((viewportDimension.height / 2) > offset) {
      percent = offset / viewportDimension.height;
    } else {
      final bool isAtBottom = offset + standardRowHeight >= viewportDimension.height;
      percent = isAtBottom ? 1.0 : (rowOffset + standardRowHeight) / viewportDimension.height;
    }

    childPositionGetter?.call(TableVicinity(column: 0, row: childIndex!), percent);
  }

if we can have something similar in RenderTableViewport class in _layoutCells we can easily get the child position

@darshankawar darshankawar added in triage Presently being triaged by the triage team package flutter/packages repository. See also p: labels. c: proposal A detailed proposal for a change to Flutter p: two_dimensional_scrollables Issues pertaining to the two_dimensional_scrollables package team-framework Owned by Framework team and removed in triage Presently being triaged by the triage team labels May 13, 2024
@goderbauer goderbauer added P3 Issues that are less important to the Flutter project triaged-framework Triaged by Framework team labels May 14, 2024
@Piinks
Copy link
Contributor

Piinks commented May 16, 2024

This reminds me of

double childMainAxisPosition(covariant RenderObject child) {
, maybe rather than adding this in TableView, we should add it to the core 2D foundation?

@Piinks Piinks added c: new feature Nothing broken; request for a new capability framework flutter/packages/flutter repository. See also f: labels. f: scrolling Viewports, list views, slivers, etc. labels May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: new feature Nothing broken; request for a new capability c: proposal A detailed proposal for a change to Flutter f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. p: two_dimensional_scrollables Issues pertaining to the two_dimensional_scrollables package P3 Issues that are less important to the Flutter project package flutter/packages repository. See also p: labels. team-framework Owned by Framework team triaged-framework Triaged by Framework team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants