Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Adds animateToItem to the CarouselController#162694

Merged
auto-submit[bot] merged 22 commits intoflutter:masterfrom
Mairramer:feat/add-animateToItem-into-carousel-controller
Mar 5, 2025
Merged

Adds animateToItem to the CarouselController#162694
auto-submit[bot] merged 22 commits intoflutter:masterfrom
Mairramer:feat/add-animateToItem-into-carousel-controller

Conversation

@Mairramer
Copy link
Contributor

@MairramerMairramer commentedFeb 4, 2025
edited
Loading

Closes#161368
This PR adds theanimateToItem method to theCarouselController, enabling smooth, index-based navigation for carousels with fixed or dynamically-sized items (viaflexWeights).

teste.mov

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel onDiscord.

alexmercerind reacted with heart emoji
@github-actionsgithub-actionsbot added frameworkflutter/packages/flutter repository. See also f: labels. f: material designflutter/packages/flutter/material repository. labelsFeb 4, 2025
@MairramerMairramer marked this pull request as draftFebruary 5, 2025 12:50
@flutter-dashboard
Copy link

This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again.

For more guidance, visitWriting a golden file test forpackage:flutter.

Reviewers: Read theTree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@MairramerMairramer marked this pull request as ready for reviewFebruary 5, 2025 12:55
Copy link
Contributor

@QuncCcccccQuncCccccc left a comment

Choose a reason for hiding this comment

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

Thanks so much for adding this new feature! Overall this looks great. Just left some thoughts below:)


double _getTargetOffset(_CarouselPosition position, int index, bool hasFlexWeights) {
if (!hasFlexWeights) {
return index * _carouselState!._itemExtent!;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we constrain the index to between [0, children.length - 1]?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Although it doesn't cause an error, it results in a large scroll before returning to the last valid position. So yes, we can constrain the index.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, we might want to assert that the index is in range.

Mairramer reacted with thumbs up emoji
final int totalWeight = weights.reduce((int a, int b) => a + b);
final double dimension = position.viewportDimension;

final bool isLastItem = index == carouselState.widget.children.length - 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

I actually think only controlling the last item is not enough. When consumeMaxWeight is false, the behavior animating to other items is still different than when consumeMaxWeight is true.

Screen.Recording.2025-02-13.at.2.58.44.PM.mov

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I made a small change to the logic, but I feel like I missed something.

@MairramerMairramerforce-pushed thefeat/add-animateToItem-into-carousel-controller branch from4c4e849 to3f923d1CompareFebruary 14, 2025 11:32
expect(realOffset(), controller.offset);
});

testWidgets('CarouselView animateToItem with flexWeights', (WidgetTester tester) async {
Copy link
Contributor

Choose a reason for hiding this comment

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

There should be several variants of this test, with different flex weights and numbers of children.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I just submitted several tests to cover various scenarios. If there is any missing, I will send it.

Copy link
Contributor

@PiinksPiinks left a comment

Choose a reason for hiding this comment

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

Hey@Mairramer thanks for sending another PR! Some questions I wonder on this, how does setting a shrinkOffset affect this? Does this work when itemSnapping is true?

Mairramer reacted with thumbs up emoji
@Mairramer
Copy link
ContributorAuthor

Mairramer commentedFeb 14, 2025
edited
Loading

Hey@Mairramer thanks for sending another PR! Some questions I wonder on this, how does setting a shrinkOffset affect this? Does this work when itemSnapping is true?

Yes, works with itemSnapping.
About shrinkOffset I may have to adjust it, but I believe we won't have a problem (I'm trying to imagine some use cases).

}

final bool hasFlexWeights = _carouselState!._flexWeights?.isNotEmpty ?? false;
index = index.clamp(0, _carouselState!.widget.children.length - 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

NICE! Thanks!

Mairramer reacted with thumbs up emoji
Copy link
Contributor

@QuncCcccccQuncCccccc left a comment

Choose a reason for hiding this comment

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

LGTM:) Thanks for adding the new feature!

Mairramer reacted with heart emoji
Copy link
Contributor

@PiinksPiinks left a comment

Choose a reason for hiding this comment

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

This also LGTM, thank you!

@PiinksPiinks added the autosubmitMerge PR when tree becomes green via auto submit App labelMar 5, 2025
@auto-submitauto-submitbot added this pull request to themerge queueMar 5, 2025
Merged via the queue intoflutter:master with commit40e4c5eMar 5, 2025
74 of 75 checks passed
@flutter-dashboardflutter-dashboardbot removed the autosubmitMerge PR when tree becomes green via auto submit App labelMar 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestMar 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestMar 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestMar 6, 2025
auto-submitbot pushed a commit to flutter/packages that referenced this pull requestMar 6, 2025
flutter/flutter@2578d97...321fbc02025-03-06 engine-flutter-autoroll@skia.org Roll Skia from fefecd49e03a to ccd8cc23aa94 (1 revision) (flutter/flutter#164712)2025-03-06 mdebbar@google.com [web] Detect scrollable semantics nodes more reliably (flutter/flutter#164491)2025-03-06 matt.kosarek@canonical.com [windows] wire the focus request and the focus events through the Windows platform (flutter/flutter#164296)2025-03-06 engine-flutter-autoroll@skia.org Roll Skia from 02897747c7d5 to fefecd49e03a (1 revision) (flutter/flutter#164701)2025-03-06 engine-flutter-autoroll@skia.org Roll Skia from e315b0ab7c84 to 02897747c7d5 (1 revision) (flutter/flutter#164677)2025-03-06 engine-flutter-autoroll@skia.org Roll Skia from 0c3880f94970 to e315b0ab7c84 (1 revision) (flutter/flutter#164669)2025-03-06 jonahwilliams@google.com [Impeller] use device private on non-iOS devices. (flutter/flutter#164601)2025-03-05 engine-flutter-autoroll@skia.org Roll Skia from 43294a662fd0 to 0c3880f94970 (1 revision) (flutter/flutter#164661)2025-03-05 codefu@google.com Add a workflow (only triggered from rest events) for hasing experiment (flutter/flutter#164657)2025-03-05 engine-flutter-autoroll@skia.org Roll Skia from 4cf9f0b77d41 to 43294a662fd0 (4 revisions) (flutter/flutter#164649)2025-03-05 50643541+Mairramer@users.noreply.github.com Adds animateToItem to the CarouselController (flutter/flutter#162694)2025-03-05 30870216+gaaclarke@users.noreply.github.com Cleanup content context (flutter/flutter#164229)2025-03-05 34465683+rkishan516@users.noreply.github.com Fix: Update CupertinoSheetRoute transition rounded corner (flutter/flutter#163700)2025-03-05 jonahwilliams@google.com [Impeller] fix macOS managed memory. (flutter/flutter#164635)2025-03-05 jacksongardner@google.com [skwasm] Clear font collection cache when font is loaded manually. (flutter/flutter#164588)2025-03-05 victorsanniay@gmail.com Fix race condition causing crash when interacting with an animating scrollable (flutter/flutter#164392)2025-03-05 58529443+srujzs@users.noreply.github.com Use dwds 24.3.6 and pass uri for the reload scripts path to FrontendServerDdcLibraryBundleProvider (flutter/flutter#164582)2025-03-05 engine-flutter-autoroll@skia.org Roll Packages from9e4684e toabba683 (8 revisions) (flutter/flutter#164630)2025-03-05 engine-flutter-autoroll@skia.org Roll Skia from 7e4323f72c9d to 4cf9f0b77d41 (1 revision) (flutter/flutter#164622)2025-03-05 harri.kirik@lab.mobi Fix to Linux_pixel_7pro integration_ui_keyboard_resize test flakiness (flutter/flutter#162308)2025-03-05 engine-flutter-autoroll@skia.org Roll Skia from 03a3f653d64e to 7e4323f72c9d (1 revision) (flutter/flutter#164599)2025-03-05 34871572+gmackall@users.noreply.github.com Implement `clipPath` Mutator for hcpp (flutter/flutter#164525)2025-03-05 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[Impeller] use DeviceLocal textures for gifs on non-iOS devices. (#164573)" (flutter/flutter#164600)2025-03-05 jonahwilliams@google.com [macos] prefer integrated GPU. (flutter/flutter#164569)2025-03-05 muhatashim@google.com Enforce minSdk constraint for Android Flutter (flutter/flutter#164251)2025-03-05 dkwingsmt@users.noreply.github.com Add `clipRSuperellipse`, and use them for dialogs (flutter/flutter#161111)2025-03-05 engine-flutter-autoroll@skia.org Roll Skia from 46705a22edc3 to 03a3f653d64e (1 revision) (flutter/flutter#164590)2025-03-05 psturm@esri.com when resetting FlutterPlatformViewsController, clear out some additional internal state to prevent it from carrying over across a Hot Restart (flutter/flutter#164456)2025-03-05 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from Rt6pxGFLVAJHduM0V... to fhm5z889sA5T1AQao... (flutter/flutter#164583)If this roll has caused a breakage, revert this CL and stop the rollerusing the controls here:https://autoroll.skia.org/r/flutter-packagesPlease CC stuartmorgan@google.com,tarrinneal@google.com on the revert to ensure that a humanis aware of the problem.To file a bug in Packages:https://github.com/flutter/flutter/issues/new/chooseTo report a problem with the AutoRoller itself, please file a bug:https://issues.skia.org/issues/new?component=1389291&template=1850622Documentation for the AutoRoller is here:https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestMay 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestMay 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull requestMay 21, 2025
androidseb pushed a commit to androidseb/packages that referenced this pull requestJun 8, 2025
flutter/flutter@2578d97...321fbc02025-03-06 engine-flutter-autoroll@skia.org Roll Skia from fefecd49e03a to ccd8cc23aa94 (1 revision) (flutter/flutter#164712)2025-03-06 mdebbar@google.com [web] Detect scrollable semantics nodes more reliably (flutter/flutter#164491)2025-03-06 matt.kosarek@canonical.com [windows] wire the focus request and the focus events through the Windows platform (flutter/flutter#164296)2025-03-06 engine-flutter-autoroll@skia.org Roll Skia from 02897747c7d5 to fefecd49e03a (1 revision) (flutter/flutter#164701)2025-03-06 engine-flutter-autoroll@skia.org Roll Skia from e315b0ab7c84 to 02897747c7d5 (1 revision) (flutter/flutter#164677)2025-03-06 engine-flutter-autoroll@skia.org Roll Skia from 0c3880f94970 to e315b0ab7c84 (1 revision) (flutter/flutter#164669)2025-03-06 jonahwilliams@google.com [Impeller] use device private on non-iOS devices. (flutter/flutter#164601)2025-03-05 engine-flutter-autoroll@skia.org Roll Skia from 43294a662fd0 to 0c3880f94970 (1 revision) (flutter/flutter#164661)2025-03-05 codefu@google.com Add a workflow (only triggered from rest events) for hasing experiment (flutter/flutter#164657)2025-03-05 engine-flutter-autoroll@skia.org Roll Skia from 4cf9f0b77d41 to 43294a662fd0 (4 revisions) (flutter/flutter#164649)2025-03-05 50643541+Mairramer@users.noreply.github.com Adds animateToItem to the CarouselController (flutter/flutter#162694)2025-03-05 30870216+gaaclarke@users.noreply.github.com Cleanup content context (flutter/flutter#164229)2025-03-05 34465683+rkishan516@users.noreply.github.com Fix: Update CupertinoSheetRoute transition rounded corner (flutter/flutter#163700)2025-03-05 jonahwilliams@google.com [Impeller] fix macOS managed memory. (flutter/flutter#164635)2025-03-05 jacksongardner@google.com [skwasm] Clear font collection cache when font is loaded manually. (flutter/flutter#164588)2025-03-05 victorsanniay@gmail.com Fix race condition causing crash when interacting with an animating scrollable (flutter/flutter#164392)2025-03-05 58529443+srujzs@users.noreply.github.com Use dwds 24.3.6 and pass uri for the reload scripts path to FrontendServerDdcLibraryBundleProvider (flutter/flutter#164582)2025-03-05 engine-flutter-autoroll@skia.org Roll Packages from9e4684e toabba683 (8 revisions) (flutter/flutter#164630)2025-03-05 engine-flutter-autoroll@skia.org Roll Skia from 7e4323f72c9d to 4cf9f0b77d41 (1 revision) (flutter/flutter#164622)2025-03-05 harri.kirik@lab.mobi Fix to Linux_pixel_7pro integration_ui_keyboard_resize test flakiness (flutter/flutter#162308)2025-03-05 engine-flutter-autoroll@skia.org Roll Skia from 03a3f653d64e to 7e4323f72c9d (1 revision) (flutter/flutter#164599)2025-03-05 34871572+gmackall@users.noreply.github.com Implement `clipPath` Mutator for hcpp (flutter/flutter#164525)2025-03-05 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[Impeller] use DeviceLocal textures for gifs on non-iOS devices. (#164573)" (flutter/flutter#164600)2025-03-05 jonahwilliams@google.com [macos] prefer integrated GPU. (flutter/flutter#164569)2025-03-05 muhatashim@google.com Enforce minSdk constraint for Android Flutter (flutter/flutter#164251)2025-03-05 dkwingsmt@users.noreply.github.com Add `clipRSuperellipse`, and use them for dialogs (flutter/flutter#161111)2025-03-05 engine-flutter-autoroll@skia.org Roll Skia from 46705a22edc3 to 03a3f653d64e (1 revision) (flutter/flutter#164590)2025-03-05 psturm@esri.com when resetting FlutterPlatformViewsController, clear out some additional internal state to prevent it from carrying over across a Hot Restart (flutter/flutter#164456)2025-03-05 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from Rt6pxGFLVAJHduM0V... to fhm5z889sA5T1AQao... (flutter/flutter#164583)If this roll has caused a breakage, revert this CL and stop the rollerusing the controls here:https://autoroll.skia.org/r/flutter-packagesPlease CC stuartmorgan@google.com,tarrinneal@google.com on the revert to ensure that a humanis aware of the problem.To file a bug in Packages:https://github.com/flutter/flutter/issues/new/chooseTo report a problem with the AutoRoller itself, please file a bug:https://issues.skia.org/issues/new?component=1389291&template=1850622Documentation for the AutoRoller is here:https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
FMorschel pushed a commit to FMorschel/packages that referenced this pull requestJun 9, 2025
flutter/flutter@2578d97...321fbc02025-03-06 engine-flutter-autoroll@skia.org Roll Skia from fefecd49e03a to ccd8cc23aa94 (1 revision) (flutter/flutter#164712)2025-03-06 mdebbar@google.com [web] Detect scrollable semantics nodes more reliably (flutter/flutter#164491)2025-03-06 matt.kosarek@canonical.com [windows] wire the focus request and the focus events through the Windows platform (flutter/flutter#164296)2025-03-06 engine-flutter-autoroll@skia.org Roll Skia from 02897747c7d5 to fefecd49e03a (1 revision) (flutter/flutter#164701)2025-03-06 engine-flutter-autoroll@skia.org Roll Skia from e315b0ab7c84 to 02897747c7d5 (1 revision) (flutter/flutter#164677)2025-03-06 engine-flutter-autoroll@skia.org Roll Skia from 0c3880f94970 to e315b0ab7c84 (1 revision) (flutter/flutter#164669)2025-03-06 jonahwilliams@google.com [Impeller] use device private on non-iOS devices. (flutter/flutter#164601)2025-03-05 engine-flutter-autoroll@skia.org Roll Skia from 43294a662fd0 to 0c3880f94970 (1 revision) (flutter/flutter#164661)2025-03-05 codefu@google.com Add a workflow (only triggered from rest events) for hasing experiment (flutter/flutter#164657)2025-03-05 engine-flutter-autoroll@skia.org Roll Skia from 4cf9f0b77d41 to 43294a662fd0 (4 revisions) (flutter/flutter#164649)2025-03-05 50643541+Mairramer@users.noreply.github.com Adds animateToItem to the CarouselController (flutter/flutter#162694)2025-03-05 30870216+gaaclarke@users.noreply.github.com Cleanup content context (flutter/flutter#164229)2025-03-05 34465683+rkishan516@users.noreply.github.com Fix: Update CupertinoSheetRoute transition rounded corner (flutter/flutter#163700)2025-03-05 jonahwilliams@google.com [Impeller] fix macOS managed memory. (flutter/flutter#164635)2025-03-05 jacksongardner@google.com [skwasm] Clear font collection cache when font is loaded manually. (flutter/flutter#164588)2025-03-05 victorsanniay@gmail.com Fix race condition causing crash when interacting with an animating scrollable (flutter/flutter#164392)2025-03-05 58529443+srujzs@users.noreply.github.com Use dwds 24.3.6 and pass uri for the reload scripts path to FrontendServerDdcLibraryBundleProvider (flutter/flutter#164582)2025-03-05 engine-flutter-autoroll@skia.org Roll Packages from9e4684e toabba683 (8 revisions) (flutter/flutter#164630)2025-03-05 engine-flutter-autoroll@skia.org Roll Skia from 7e4323f72c9d to 4cf9f0b77d41 (1 revision) (flutter/flutter#164622)2025-03-05 harri.kirik@lab.mobi Fix to Linux_pixel_7pro integration_ui_keyboard_resize test flakiness (flutter/flutter#162308)2025-03-05 engine-flutter-autoroll@skia.org Roll Skia from 03a3f653d64e to 7e4323f72c9d (1 revision) (flutter/flutter#164599)2025-03-05 34871572+gmackall@users.noreply.github.com Implement `clipPath` Mutator for hcpp (flutter/flutter#164525)2025-03-05 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[Impeller] use DeviceLocal textures for gifs on non-iOS devices. (#164573)" (flutter/flutter#164600)2025-03-05 jonahwilliams@google.com [macos] prefer integrated GPU. (flutter/flutter#164569)2025-03-05 muhatashim@google.com Enforce minSdk constraint for Android Flutter (flutter/flutter#164251)2025-03-05 dkwingsmt@users.noreply.github.com Add `clipRSuperellipse`, and use them for dialogs (flutter/flutter#161111)2025-03-05 engine-flutter-autoroll@skia.org Roll Skia from 46705a22edc3 to 03a3f653d64e (1 revision) (flutter/flutter#164590)2025-03-05 psturm@esri.com when resetting FlutterPlatformViewsController, clear out some additional internal state to prevent it from carrying over across a Hot Restart (flutter/flutter#164456)2025-03-05 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from Rt6pxGFLVAJHduM0V... to fhm5z889sA5T1AQao... (flutter/flutter#164583)If this roll has caused a breakage, revert this CL and stop the rollerusing the controls here:https://autoroll.skia.org/r/flutter-packagesPlease CC stuartmorgan@google.com,tarrinneal@google.com on the revert to ensure that a humanis aware of the problem.To file a bug in Packages:https://github.com/flutter/flutter/issues/new/chooseTo report a problem with the AutoRoller itself, please file a bug:https://issues.skia.org/issues/new?component=1389291&template=1850622Documentation for the AutoRoller is here:https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
@MairramerMairramer deleted the feat/add-animateToItem-into-carousel-controller branchJanuary 28, 2026 17:01
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@PiinksPiinksPiinks approved these changes

@QuncCcccccQuncCcccccQuncCccccc approved these changes

Assignees

No one assigned

Labels

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

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

carouselview add animateToItem

3 participants

@Mairramer@Piinks@QuncCccccc

Comments


[8]ページ先頭

©2009-2026 Movatter.jp