flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
162.97k stars 26.8k forks source link

Adding a Carousel Widget #125980

Open MaxYablochkin opened 1 year ago

MaxYablochkin commented 1 year ago

Proposal

Part of: #91605

Adding a new Carousel component widget according to Material 3 specifications

unnamed1

Use case

  1. Default carousel
  2. Carousel with reduced motion settings turned on

https://user-images.githubusercontent.com/102767277/235958580-c5db0309-b173-4d64-9f00-4ac4ed1ad838.mp4

huycozy commented 1 year ago

I think it makes sense to have a such widget that meets the M3 specs. Also, I see there are some packages already implemented that you may try using: carousel_slider, flutter_carousel_widget.

Labeling this issue for more opinions. May be similar: https://github.com/flutter/flutter/issues/25074.

HansMuller commented 1 year ago

An M3 compliant carousel would be a welcome contribution as a separate package. Looks like a fun project.

fredgrott commented 10 months ago

A question for @HansMuller it would seem that MD3 Carousel is or should be a refactor of say carousel slider since is uses PageView underneath to allow the transforms to be applied to both the current index and current index-1 and current index+1 which then would give the correct animation and other effects implied in the spec of the MD3 Carousel.

Have I got the gist of it as it would be fun from the transforms part especially if one allowed to some other transforms as well...

I will take a shot later this week to implement one re-using carousel slider code, should be some fun indeed.

HuiAzir commented 9 months ago

Is this work already in progress?

HansMuller commented 9 months ago

The Framework team at Google isn't working on it however @fredgrott might be

followthemoney1 commented 8 months ago

Please can someone ping me an the example of how this can be implemented right now until the Google team answers there :)

Who interested I've created a small snipped but it not looks so cool: https://gist.github.com/followthemoney1/a38ec5928fba4899700b9815c6be7fdc

https://github.com/flutter/flutter/assets/8526612/9d35b3b9-65f0-4415-adf5-8bb8a6efc060

fredgrott commented 6 months ago

Okay here is what I know...

Normal page view will not work as the builder above the viewport builder is the wrong builder...What is needed is a new page view that has the right layout builder above the viewport builder.

There are already some carousels that take the approach of redoing page view with the right layout builder. That combined with the right breakpoints and the scrolling recipe from the cookbook example than gives a full MD3 carousel.

paadevelopments commented 6 months ago

I had to build this while we wait for a Flutter support.

sample

Also available on Pub.

fredgrott commented 6 months ago

Good job @paadevelopments

flutter-triage-bot[bot] commented 4 months ago

This issue is assigned to @QuncCccccc but has had no recent status updates. Please consider unassigning this issue if it is not going to be addressed in the near future. This allows people to have a clearer picture of what work is actually planned. Thanks!

RubenCesario commented 2 weeks ago

According to the Material Carousel homepage (https://m3.material.io/components/carousel/overview) the component is in the "Planned" state. Is it possible to know when developments will begin? Alternatively, can the Flutter team recommend a package to consider as 'official' while waiting for it to be developed internally?

mattermoran commented 2 weeks ago

There are 2 PRs for it. Part 1 was merged recently and Part 2 one should be available soon. It was featured in the Notable Commits

mattermoran commented 2 weeks ago

Also you don't have to wait until it's available on stable. In the meanwhile you can copy the widget code (just one file) into your project and use it. here's the example from second PR.