Skip to content

Add SliverAnimatedGrid and AnimatedGrid - #112982

Merged
auto-submit[bot] merged 11 commits into
flutter:masterfrom
gspencergoog:animated_grid
Oct 7, 2022
Merged

Add SliverAnimatedGrid and AnimatedGrid#112982
auto-submit[bot] merged 11 commits into
flutter:masterfrom
gspencergoog:animated_grid

Conversation

@gspencergoog

@gspencergoog gspencergoog commented Oct 5, 2022

Copy link
Copy Markdown
Contributor

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 p: material_ui material_ui package in flutter/packages f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. c: contributor-productivity Team-specific productivity, code health, technical debt. labels Oct 5, 2022
@gspencergoog
gspencergoog marked this pull request as ready for review October 5, 2022 22:20
@gspencergoog
gspencergoog requested a review from Piinks October 5, 2022 22:20
Comment thread bin/internal/engine.version Outdated
Comment thread packages/flutter/lib/src/gestures/converter.dart Outdated
@Piinks Piinks added the c: new feature Nothing broken; request for a new capability label Oct 7, 2022
Comment thread packages/flutter/lib/src/material/theme_data.dart
Comment thread packages/flutter/lib/src/material/theme_data.dart
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread packages/flutter/lib/src/widgets/animated_grid.dart
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
Copy Markdown
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
Copy Markdown
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.

Comment thread packages/flutter/lib/src/widgets/animated_grid.dart Outdated
Comment thread packages/flutter/lib/src/widgets/animated_grid.dart
Comment thread packages/flutter/lib/src/widgets/animated_grid.dart
Comment thread packages/flutter/lib/src/widgets/animated_grid.dart
@gspencergoog gspencergoog added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 7, 2022
@auto-submit

auto-submit Bot commented Oct 7, 2022

Copy link
Copy Markdown
Contributor

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

auto-submit Bot commented Oct 7, 2022

Copy link
Copy Markdown
Contributor

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

@Piinks Piinks left a comment

Copy link
Copy Markdown
Contributor

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

auto-submit Bot commented Oct 7, 2022

Copy link
Copy Markdown
Contributor

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
Copy Markdown

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: contributor-productivity Team-specific productivity, code health, technical debt. 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: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing AnimatedGrid widget

3 participants