nixrajput / flutter_carousel_widget

A customizable Flutter carousel widget with infinite scrolling, auto-scrolling, pre-built indicators, expandable widgets, auto-sized child support, and enlarged center page.
https://pub.dev/packages/flutter_carousel_widget
MIT License
34 stars 20 forks source link

[Question] Remove Center from each child #9

Closed stormenergy91 closed 1 year ago

stormenergy91 commented 1 year ago

The plugin is forcing a center widget in each of its elements, constraining the application of this plugin.

E.g If i want the carousel to have the image at left of the screen it would be almost impossible because of this Center widget without using some obscure hacky stuff ;)

There is some way to don't force this behavior in the carousel?

I want to have this effect

immagine

Edit: I tried to use the disableCenter: true option but it doesn't work.

nixrajput commented 1 year ago

Hi @stormenergy91,

Thank you for using this package.

I will look into this issue and will fix it in the next update.

Thanks again for raising the issue.

stormenergy91 commented 1 year ago

Thanks @nixrajput, is a great plugin. If you need more info or some testing I'm here!

nixrajput commented 1 year ago

Hi @stormenergy91,

Can you please share some code snippets for testing the changes you want in the package?

stormenergy91 commented 1 year ago

@nixrajput as you can see in this image, on the left there is the actual result, on the right what I want to have:

plugin_demo

Here the code that I have used:

ListView(
      children: [
        Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [

            ...

            FutureBuilder(
                future: items,
                builder: (context, AsyncSnapshot snapshot) {
                  List<CustomhView> itemsList = [];

                  if (snapshot.connectionState == ConnectionState.waiting) {
                    return Container(
                      height: 200,
                      child: Center(
                        child: CircularProgressIndicator(),
                      ),
                    );
                  } else {
                    if (snapshot.hasError) {
                      return const Text("Network Error");
                    } else {
                      if (snapshot.data.length == 0) {
                        return const Text("No Items");
                      } else {
                        for (var i = 0; i < snapshot.data.length; i++) {
                          itemsList.add(CustomView(snapshot.data[i]));
                        }

                        return FlutterCarousel(
                          items: itemsList,
                          options: CarouselOptions(
                            viewportFraction: 0.70,
                            height: 280.0,
                            showIndicator: false,
                            pageSnapping: false,
                            disableCenter: true,
                            enableInfiniteScroll: false,
                            slideIndicator: CircularSlideIndicator(),
                          ),
                        );
                      }
                    }
                  }
                }),

                ...

          ],
        ),
      ],
    )

The property disableCenterwhat is used for?

nixrajput commented 1 year ago

Hi @stormenergy91,

I checked and tested the code and I found that no additional change requires in the code for this issue.

In your case, you can use padEnds property to false.

CarouselOptions(
  viewportFraction: 0.70,
  height: 280.0,
  showIndicator: false,
  padEnds: false,
  enableInfiniteScroll: false,
  slideIndicator: CircularSlideIndicator(),
),

Thanks

stormenergy91 commented 1 year ago

Thanks so much! :)