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

Add SliverAnimatedGrid and AnimatedGrid #112982

Merged
merged 11 commits into from Oct 7, 2022

Conversation

gspencergoog
Copy link
Contributor

@gspencergoog gspencergoog commented Oct 5, 2022

Description

This adds two widgets, analogous to SliverAnimatedList and AnimatedList which allow items that are added or removed from a SliverGrid to be animated on add and remove.

Added samples for each too.

grid2.mp4

Related Issues

Tests

  • Added tests for the new widgets.

@flutter-dashboard flutter-dashboard bot added d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos documentation f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. team Infra upgrades, team productivity, code health, technical debt. See also team: labels. labels Oct 5, 2022
@gspencergoog gspencergoog marked this pull request as ready for review October 5, 2022 22:20
bin/internal/engine.version Outdated Show resolved Hide resolved
packages/flutter/lib/src/gestures/converter.dart Outdated Show resolved Hide resolved
@Piinks Piinks added the c: new feature Nothing broken; request for a new capability label Oct 7, 2022
Comment on lines 15 to 19
/// Signature for the builder callback used by [AnimatedGrid].
typedef AnimatedGridItemBuilder = Widget Function(BuildContext context, int index, Animation<double> animation);

/// Signature for the builder callback used by [AnimatedGridState.removeItem].
typedef AnimatedGridRemovedItemBuilder = Widget Function(BuildContext context, Animation<double> animation);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the signatures are the same, do you think there is any benefit of creating one AnimatedItemBuilder and one AnimatedRemovedItemBuilder that both list and grid use?
We would probably have to add the new ones to AnimatedList, and deprecate the old ones... so if it feels like unnecessary churn we can have separate ones.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can explore this in the follow up refactor. I'll file an issue to track.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the meantime should I use AnimatedListItemBuilder here instead? That seems weird, though. I could just not use a typedef? Just trying to avoid introducing API surface that lasts only a until the next refactor, but I guess a typedef name is probably rarely actually used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to AnimatedItemBuilder, and we'll refactor AnimatedList later to take that instead.

packages/flutter/lib/src/widgets/animated_grid.dart Outdated Show resolved Hide resolved
Comment on lines +102 to +104
/// * [SliverGridDelegateWithFixedCrossAxisCount], which creates a layout with
/// a fixed number of tiles in the cross axis.
/// * [SliverGridDelegateWithMaxCrossAxisExtent], which creates a layout with
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Offline we chatted about adding convenience constructors like count and extent in order to spin up a delegate for the user. Can you add those?
Reference: #113107

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to wait to do this, since it became clear that this and AnimatedList might need some refactoring to take a child builder delegate instead of just a builder function.

packages/flutter/lib/src/widgets/animated_grid.dart Outdated Show resolved Hide resolved
@gspencergoog gspencergoog added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 7, 2022
@auto-submit
Copy link
Contributor

auto-submit bot commented Oct 7, 2022

auto label is removed for flutter/flutter, pr: 112982, due to - Please get at least one approved review if you are already a member or two member reviews if you are not a member before re-applying this label. Reviewers: If you left a comment approving, please use the "approve" review action instead.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 7, 2022
@auto-submit
Copy link
Contributor

auto-submit bot commented Oct 7, 2022

auto label is removed for flutter/flutter, pr: 112982, due to Validations Fail.

Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flutter_LGTM

@Piinks Piinks added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 7, 2022
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 7, 2022
@auto-submit
Copy link
Contributor

auto-submit bot commented Oct 7, 2022

auto label is removed for flutter/flutter, pr: 112982, due to - The status or check suite Linux docs_test has failed. Please fix the issues identified (or deflake) before re-applying this label.

@fmcarvalho
Copy link

Where can we find the preview release and date for AnimatedGrid?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App c: new feature Nothing broken; request for a new capability d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. team Infra upgrades, team productivity, code health, technical debt. See also team: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing AnimatedGrid widget
3 participants