Giter Site home page Giter Site logo

flutter-carousel-pro's Introduction

Carousel Pro pub package

A Flutter Carousel widget.

Usage

As simple as using any flutter Widget.

Example: Add the module to your project pubspec.yaml:

...
dependencies:
 ...
 carousel_pro: ^1.0.0
...

And install it using flutter packages get on your project folder. After that, just import the module and use it:

import 'package:carousel_pro/carousel_pro.dart';

//...
SizedBox(
  height: 150.0,
  width: 300.0,
  child: Carousel(
    images: [
      NetworkImage('https://cdn-images-1.medium.com/max/2000/1*GqdzzfB_BHorv7V2NV7Jgg.jpeg'),
      NetworkImage('https://cdn-images-1.medium.com/max/2000/1*wnIEgP1gNMrK5gZU7QS0-A.jpeg'),
      ExactAssetImage("assets/images/LaunchImage.jpg")
    ],
  )
),

ScreenShot 01

import 'package:carousel_pro/carousel_pro.dart';

//...
SizedBox(
  height: 200.0,
  width: 350.0,
  child: Carousel(
    images: [
      NetworkImage('https://cdn-images-1.medium.com/max/2000/1*GqdzzfB_BHorv7V2NV7Jgg.jpeg'),
      NetworkImage('https://cdn-images-1.medium.com/max/2000/1*wnIEgP1gNMrK5gZU7QS0-A.jpeg'),
      ExactAssetImage("assets/images/LaunchImage.jpg")
    ],
    dotSize: 4.0,
    dotSpacing: 15.0,
    dotColor: Colors.lightGreenAccent,
    indicatorBgPadding: 5.0,
    dotBgColor: Colors.purple.withOpacity(0.5),
    borderRadius: true,
  )
),

ScreenShot 02

import 'package:carousel_pro/carousel_pro.dart';

//...
SizedBox(
    height: 200.0,
    width: 350.0,
    child: Carousel(
      images: [
        NetworkImage('https://cdn-images-1.medium.com/max/2000/1*GqdzzfB_BHorv7V2NV7Jgg.jpeg'),
        NetworkImage('https://cdn-images-1.medium.com/max/2000/1*wnIEgP1gNMrK5gZU7QS0-A.jpeg'),
        ExactAssetImage("assets/images/LaunchImage.jpg")
      ],
      dotSize: 4.0,
      dotSpacing: 15.0,
      dotColor: Colors.lightGreenAccent,
      indicatorBgPadding: 5.0,
      dotBgColor: Colors.purple.withOpacity(0.5),
      borderRadius: true,
      moveIndicatorFromBottom: 180.0,
      noRadiusForIndicator: true,
    )
),

ScreenShot 03

import 'package:carousel_pro/carousel_pro.dart';

//...
SizedBox(
    height: 200.0,
    width: 350.0,
    child: Carousel(
      images: [
        NetworkImage('https://cdn-images-1.medium.com/max/2000/1*GqdzzfB_BHorv7V2NV7Jgg.jpeg'),
        NetworkImage('https://cdn-images-1.medium.com/max/2000/1*wnIEgP1gNMrK5gZU7QS0-A.jpeg'),
        ExactAssetImage("assets/images/LaunchImage.jpg")
      ],
      dotSize: 4.0,
      dotSpacing: 15.0,
      dotColor: Colors.lightGreenAccent,
      indicatorBgPadding: 5.0,
      dotBgColor: Colors.purple.withOpacity(0.5),
      borderRadius: false,
      moveIndicatorFromBottom: 180.0,
      noRadiusForIndicator: true,
      overlayShadow: true,
      overlayShadowColors: Colors.white,
      overlayShadowSize: 0.7,
    )
),

ScreenShot 04

import 'package:carousel_pro/carousel_pro.dart';

//...
SizedBox(
    height: 200.0,
    width: 350.0,
    child: Carousel(
      images: [
        NetworkImage('https://cdn-images-1.medium.com/max/2000/1*GqdzzfB_BHorv7V2NV7Jgg.jpeg'),
        NetworkImage('https://cdn-images-1.medium.com/max/2000/1*wnIEgP1gNMrK5gZU7QS0-A.jpeg'),
        ExactAssetImage("assets/images/LaunchImage.jpg")
      ],
      showIndicator: false,
      borderRadius: false,
      moveIndicatorFromBottom: 180.0,
      noRadiusForIndicator: true,
      overlayShadow: true,
      overlayShadowColors: Colors.white,
      overlayShadowSize: 0.7,
    )
),

ScreenShot 05

Parameters and Values

images

All the images on this Carousel. Type: List

animationCurve

The transition animation timing curve Default value: Curves.ease Type: Curve

Values
  • Curves.linear;
  • Curves.fastOutSlowIn;
  • Curves.ease;
  • Curves.bounceOut;
  • Curves.bounceIn;
  • Curves.bounceInOut;
  • Curves.decelerate;
  • Curves.ease;
  • Curves.easeIn;
  • Curves.easeInOut;
  • Curves.easeOut;
  • Curves.elasticIn;
  • Curves.elasticInOut;
  • Curves.elasticOut;

animationDuration

The transition animation duration Type: Duration Default value: 300ms.

dotSize

The base size of the dots Type: double Default value: 8.0

dotIncreaseSize

The increase in the size of the selected dot Type: double Default value: 2.0

dotSpacing

The distance between the center of each dot Type: double Default value: 25.0

dotColor

The Color of each dot Type: Color Default value: Colors.white

dotBgColor

The background Color of the dots Type: Color Default value: Colors.grey[800].withOpacity(0.5)

showIndicator

Enable or Disable the indicator (dots) Type: bool Default value: true

indicatorBgPadding

Padding Size of the background Indicator Type: double Default value: 20.0

boxFit

How to show the images in the box Type: BoxFit Default value: cover

Values
  • BoxFit.cover;
  • BoxFit.fitWidth;
  • BoxFit.fitHeight;
  • BoxFit.scaleDown;
  • BoxFit.fill;
  • BoxFit.contain;
  • BoxFit.none;

borderRadius

Enable/Disable radius Border for the images Type: bool Default value: false

radius

Border Radius of the images Type: Radius Default value: Radius.circular(8.0)

moveIndicatorFromBottom

Move the Indicator From the Bottom Type: double Default value: 0.0

noRadiusForIndicator

Remove the radius bottom from the indicator background Type: bool Default value: false

overlayShadow

Enable/Disable Image Overlay Shadow Type: bool Default value: false

overlayShadowColors

Choose the color of the overlay Shadow color Type: Color Default value: Colors.grey[800]

overlayShadowSize

Choose the size of the Overlay Shadow, from 0.0 to 1.0 Type: double Default value: 0.5

autoplay

Enable/Disable autoplay carousel Type: bool Default value: true

autoplayDuration

The autoplay transition duration Type: Duration Default value: 3s

Credits

Developed by JLouage (Julien Louage) [email protected]

Contributing

Feel free to help!

flutter-carousel-pro's People

Contributors

anisalibegic avatar jinugeorge33 avatar jlouage avatar julindra avatar moshiplus avatar p30arena avatar saifallak avatar sh0umik avatar shashikantx avatar xportation avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

flutter-carousel-pro's Issues

FlexibaleSpace bare error.

Hi, i am using it inside a flexibale space bare 'bacground',when space bare collabsed i get the following error, Advice please.
#2 is it ok not specifying the width and let it adjust to the parent width?

E/flutter (20377): [ERROR:flutter/shell/common/shell.cc(181)] Dart Error: Unhandled exception:
E/flutter (20377): 'package:flutter/src/widgets/page_view.dart': Failed assertion: line 96 pos 7: 'positions.isNotEmpty': PageController.page cannot be accessed before a PageView is built with it.
E/flutter (20377): #0      _AssertionError._doThrowNew (dart:core/runtime/liberrors_patch.dart:40:39)
E/flutter (20377): #1      _AssertionError._throwNew (dart:core/runtime/liberrors_patch.dart:36:5)
E/flutter (20377): #2      PageController.page (package:flutter/src/widgets/page_view.dart:96:7)
E/flutter (20377): #3      CarouselState.initState.<anonymous closure> (package:carousel_pro/src/carousel_pro.dart:110:24)
E/flutter (20377): #4      _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
E/flutter (20377): #5      _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
E/flutter (20377): #6      _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)

How to remove margin/padding top and bottom?

Hi @jlouage ,

Do you still support this plugin? I have a question about how to remove margin/padding top and bottom of image. My code is:

Container(
  alignment: Alignment.topCenter,
  decoration: BoxDecoration(color: Colors.red),
  child: Carousel(
    dotSize: 4,
    dotSpacing: 8,
    dotBgColor: Colors.transparent,
    autoplayDuration: Duration(seconds: 5),
    images: carouselImages,
    showIndicator: true,
    boxFit: BoxFit.contain,
  ),
),

Then please refer to following screenshot, as you can see there's red background indicate margin/padding top and bottom:
flutter_01

How could I remove it? Thanks in advance!

I got the following error message: PageController.page cannot be accessed before a PageView is built with it

I got the following error message, I just add 1 Carousel widget into my page, nothing else. Please take a look and tell me how to fix it.

E/flutter (13647): [ERROR:flutter/shell/common/shell.cc(181)] Dart Error: Unhandled exception:
E/flutter (13647): 'package:flutter/src/widgets/page_view.dart': Failed assertion: line 96 pos 7: 'positions.isNotEmpty': PageController.page cannot be accessed before a PageView is built with it.
E/flutter (13647): #0      _AssertionError._doThrowNew (dart:core/runtime/liberrors_patch.dart:40:39)
E/flutter (13647): #1      _AssertionError._throwNew (dart:core/runtime/liberrors_patch.dart:36:5)
E/flutter (13647): #2      PageController.page (package:flutter/src/widgets/page_view.dart:96:7)
E/flutter (13647): #3      CarouselState.initState.<anonymous closure> (package:carousel_pro/src/carousel_pro.dart:110:24)
E/flutter (13647): #4      _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
E/flutter (13647): #5      _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
E/flutter (13647): #6      _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)

Suggestion: initial index

I would like to always start the carousel with the last image the user saw in the last time he used the app. Would be nice to expose the initial index for doing it

Can you add a license that will allow others to use this nice repo

I was excited to test out this repo until I saw the license.

I'm not sure how other people are legally using your repo including the 15 forks
since it's "All rights reserved."

Maybe I'm just mis-understanding copy right law

Thanks for the hard work you did creating this project!

Support null safety

This is a request to add support for null safety to package:carousel_pro.
We depend on your awesome package, so would be great to have null safety enabled.

The Dart/Flutter team already encourages publishing the migrated packages: See this blog post.

See the migration guide for details about enabling null safety.

Carousel pro should use dynamic height of the images.

Currently we need to add a sizedbox for the carousel to display images with some fixed height and width. Instead, there should be one more check in the code, if user dont provide height width then the carousel should take the height width of the image or of the device and calculate it and set the images with that height or width. It will become more dynamic for everyone to use.

Multiple Carousels (swipe scrolls all)

I have multiple Carousels on my page, horizontal swiping one, makes them all go to the next / previous image, whilst it should only be the one being swiped on.

Exception thrown during performLayout();

The carousel is working fine but the following error is thrown at equal intervals. There is a long error that comes at startup.
Error that comes when app is loaded

I/flutter (29371): The following assertion was thrown during performLayout():
I/flutter (29371): 'package:flutter/src/rendering/sliver_fixed_extent_list.dart': Failed assertion: line 276 pos 12:
I/flutter (29371): 'firstIndex == 0 || childScrollOffset(firstChild) - scrollOffset <= precisionErrorTolerance': is not
I/flutter (29371): true.
I/flutter (29371):
I/flutter (29371): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter (29371): more information in this error message to help you determine and fix the underlying cause.
I/flutter (29371): In either case, please report this assertion by filing a bug on GitHub:
I/flutter (29371):   https://github.com/flutter/flutter/issues/new?template=BUG.md
I/flutter (29371):
I/flutter (29371): The relevant error-causing widget was:
I/flutter (29371):   PageView
I/flutter (29371):   file:///C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/carousel_pro-1.0.0/lib/src/carousel_pro.dart:314:33
I/flutter (29371):
I/flutter (29371): When the exception was thrown, this was the stack:
I/flutter (29371): #2      RenderSliverFixedExtentBoxAdaptor.performLayout (package:flutter/src/rendering/sliver_fixed_extent_list.dart:276:12)
I/flutter (29371): #3      RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
I/flutter (29371): #4      RenderSliverEdgeInsetsPadding.performLayout (package:flutter/src/rendering/sliver_padding.dart:135:11)
I/flutter (29371): #5      _RenderSliverFractionalPadding.performLayout (package:flutter/src/widgets/sliver_fill.dart:168:11)
I/flutter (29371): #6      RenderObject.layout (package:flutter/src/rendering/object.dart:1767:7)
I/flutter (29371): #7      RenderViewportBase.layoutChildSequence (package:flutter/src/rendering/viewport.dart:452:13)
I/flutter (29371): #8      RenderViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:1444:12)
I/flutter (29371): #9      RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:1353:20)
I/flutter (29371): #10     RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1630:7)
I/flutter (29371): #11     PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:887:18)
I/flutter (29371): #12     RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:402:19)
I/flutter (29371): #13     WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:884:13)
I/flutter (29371): #14     RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:284:5)
I/flutter (29371): #15     SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1113:15)
I/flutter (29371): #16     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1052:9)
I/flutter (29371): #17     SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:968:5)
I/flutter (29371): #21     _invoke (dart:ui/hooks.dart:261:10)
I/flutter (29371): #22     _drawFrame (dart:ui/hooks.dart:219:3)
I/flutter (29371): (elided 5 frames from class _AssertionError and dart:async)
I/flutter (29371):
I/flutter (29371): The following RenderObject was being processed when the exception was fired: RenderSliverFillViewport#38a95 relayoutBoundary=up2 NEEDS-LAYOUT NEEDS-COMPOSITING-BITS-UPDATE:
I/flutter (29371):   needs compositing
I/flutter (29371):   creator: _SliverFillViewportRenderObjectWidget ← _SliverFractionalPadding ← SliverFillViewport ←
I/flutter (29371):     Viewport ← IgnorePointer-[GlobalKey#73898] ← Semantics ← _PointerListener ← Listener ←
I/flutter (29371):     _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#b5513] ←
I/flutter (29371):     _PointerListener ← Listener ← ⋯
I/flutter (29371):   parentData: paintOffset=Offset(0.0, 0.0) (can use size)
I/flutter (29371):   constraints: SliverConstraints(AxisDirection.right, GrowthDirection.forward, ScrollDirection.idle,
I/flutter (29371):     scrollOffset: 719.3, remainingPaintExtent: 359.7, crossAxisExtent: 190.3, crossAxisDirection:
I/flutter (29371):     AxisDirection.down, viewportMainAxisExtent: 359.7, remainingCacheExtent: 359.7, cacheOrigin: 0.0)
I/flutter (29371):   geometry: SliverGeometry(scrollExtent: 1438.6, paintExtent: 359.7, maxPaintExtent: 1438.6,
I/flutter (29371):     hasVisualOverflow: true, cacheExtent: 359.7)
I/flutter (29371):   currently live children: 2 to 2
I/flutter (29371): This RenderObject had the following descendants (showing up to depth 5):
I/flutter (29371):     child with index 2: RenderIndexedSemantics#76ebe
I/flutter (29371):       child: RenderRepaintBoundary#7d1d5
I/flutter (29371):         child: RenderDecoratedBox#05cf5
I/flutter (29371):           child: RenderLimitedBox#b3c2a
I/flutter (29371):             child: RenderConstrainedBox#9afab
I/flutter (29371): ════════════════════════════════════════════════════════════════════════════════════════════════════

Error that comes after an interval of time

exception was thrown: 'package:flutter/src/rendering/sliver_fixed_extent_list.dart': Failed assertion: line 276 pos 12: 'firstIndex == 0 || childScrollOffset(firstChild) - scrollOffset <= precisionErrorTolerance': is not true.

I have the following code that I am rendering.

return Container(
      height: MediaQuery.of(context).size.height * 0.25,
      child: Carousel(
        boxFit: BoxFit.contain,
        images: [
          AssetImage('images/Notesbg.png'),
          AssetImage('images/Notesbg.png'),
          AssetImage('images/Notesbg.png'),
          AssetImage('images/Notesbg.png')
        ],
        
        autoplay: true,
        autoplayDuration: Duration(seconds: 5),
        animationCurve: Curves.fastLinearToSlowEaseIn,
        animationDuration: Duration(milliseconds: 2000),
        dotSize: 6.0,
        indicatorBgPadding: 1.0,
        dotBgColor: Colors.transparent,
        dotSpacing: 13,
        dotIncreaseSize: 1.4,
        dotIncreasedColor: Colors.red,
      ),
    );

Overflow with high number of images

If I put too many images in the carousel, the dots go beyond the screen causing an overflow. Can we find a way to limit the number of dots, overriding itemCount: listImages.length ?

I have seen many just keep three dots and keep remaining on the middle one until the carousel reaches the end

CarouselState.initState.<anonymous closure> (package:carousel_pro/src/carousel_pro.dart:110)

E/flutter (14589): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Bad state: No element
E/flutter (14589): #0      _GrowableList.single (dart:core-patch/growable_array.dart:229)
E/flutter (14589): #1      ScrollController.position (package:flutter/src/widgets/scroll_controller.dart:112)
E/flutter (14589): #2      PageController.page (package:flutter/src/widgets/page_view.dart:147)
E/flutter (14589): #3      CarouselState.initState.<anonymous closure> (package:carousel_pro/src/carousel_pro.dart:110)
E/flutter (14589): #4      _rootRunUnary (dart:async/zone.dart:1192)
E/flutter (14589): #5      _CustomZone.runUnary (dart:async/zone.dart:1085)
E/flutter (14589): #6      _CustomZone.runUnaryGuarded (dart:async/zone.dart:987)
E/flutter (14589): #7      _CustomZone.bindUnaryCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1024)
E/flutter (14589): #8      _rootRunUnary (dart:async/zone.dart:1196)
E/flutter (14589): #9      _CustomZone.runUnary (dart:async/zone.dart:1085)
E/flutter (14589): #10     _CustomZone.bindUnaryCallback.<anonymous closure> (dart:async/zone.dart:1008)
E/flutter (14589): #11     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398)
E/flutter (14589): #12     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429)
E/flutter (14589): #13     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168)
E/flutter (14589): 
E/flutter (14589): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Bad state: No element
E/flutter (14589): #0      _GrowableList.single (dart:core-patch/growable_array.dart:229)
E/flutter (14589): #1      ScrollController.position (package:flutter/src/widgets/scroll_controller.dart:112)
E/flutter (14589): #2      PageController.page (package:flutter/src/widgets/page_view.dart:147)
E/flutter (14589): #3      CarouselState.initState.<anonymous closure> (package:carousel_pro/src/carousel_pro.dart:110)
E/flutter (14589): #4      _rootRunUnary (dart:async/zone.dart:1192)
E/flutter (14589): #5      _CustomZone.runUnary (dart:async/zone.dart:1085)
E/flutter (14589): #6      _CustomZone.runUnaryGuarded (dart:async/zone.dart:987)
E/flutter (14589): #7      _CustomZone.bindUnaryCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1024)
E/flutter (14589): #8      _rootRunUnary (dart:async/zone.dart:1196)
E/flutter (14589): #9      _CustomZone.runUnary (dart:async/zone.dart:1085)
E/flutter (14589): #10     _CustomZone.bindUnaryCallback.<anonymous closure> (dart:async/zone.dart:1008)
E/flutter (14589): #11     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398)
E/flutter (14589): #12     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429)
E/flutter (14589): #13     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168)
E/flutter (14589): 
E/flutter (14589): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Bad state: No element
E/flutter (14589): #0      _GrowableList.single (dart:core-patch/growable_array.dart:229)
E/flutter (14589): #1      ScrollController.position (package:flutter/src/widgets/scroll_controller.dart:112)
E/flutter (14589): #2      PageController.page (package:flutter/src/widgets/page_view.dart:147)
E/flutter (14589): #3      CarouselState.initState.<anonymous closure> (package:carousel_pro/src/carousel_pro.dart:110)
E/flutter (14589): #4      _rootRunUnary (dart:async/zone.dart:1192)
E/flutter (14589): #5      _CustomZone.runUnary (dart:async/zone.dart:1085)
E/flutter (14589): #6      _CustomZone.runUnaryGuarded (dart:async/zone.dart:987)
E/flutter (14589): #7      _CustomZone.bindUnaryCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1024)
E/flutter (14589): #8      _rootRunUnary (dart:async/zone.dart:1196)
E/flutter (14589): #9      _CustomZone.runUnary (dart:async/zone.dart:1085)
E/flutter (14589): #10     _CustomZone.bindUnaryCallback.<anonymous closure> (dart:async/zone.dart:1008)
E/flutter (14589): #11     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398)
E/flutter (14589): #12     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429)
E/flutter (14589): #13     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168)
E/flutter (14589): 
E/flutter (14589): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Bad state: No element
E/flutter (14589): #0      _GrowableList.single (dart:core-patch/growable_array.dart:229)
E/flutter (14589): #1      ScrollController.position (package:flutter/src/widgets/scroll_controller.dart:112)
E/flutter (14589): #2      PageController.page (package:flutter/src/widgets/page_view.dart:147)
E/flutter (14589): #3      CarouselState.initState.<anonymous closure> (package:carousel_pro/src/carousel_pro.dart:110)
E/flutter (14589): #4      _rootRunUnary (dart:async/zone.dart:1192)
E/flutter (14589): #5      _CustomZone.runUnary (dart:async/zone.dart:1085)
E/flutter (14589): #6      _CustomZone.runUnaryGuarded (dart:async/zone.dart:987)
E/flutter (14589): #7      _CustomZone.bindUnaryCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1024)
E/flutter (14589): #8      _rootRunUnary (dart:async/zone.dart:1196)
E/flutter (14589): #9      _CustomZone.runUnary (dart:async/zone.dart:1085)
E/flutter (14589): #10     _CustomZone.bindUnaryCallback.<anonymous closure> (dart:async/zone.dart:1008)
E/flutter (14589): #11     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398)
E/flutter (14589): #12     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429)
E/flutter (14589): #13     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168)
E/flutter (14589): 
E/flutter (14589): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Bad state: No element
E/flutter (14589): #0      _GrowableList.single (dart:core-patch/growable_array.dart:229)
E/flutter (14589): #1      ScrollController.position (package:flutter/src/widgets/scroll_controller.dart:112)
E/flutter (14589): #2      PageController.page (package:flutter/src/widgets/page_view.dart:147)
E/flutter (14589): #3      CarouselState.initState.<anonymous closure> (package:carousel_pro/src/carousel_pro.dart:110)
E/flutter (14589): #4      _rootRunUnary (dart:async/zone.dart:1192)
E/flutter (14589): #5      _CustomZone.runUnary (dart:async/zone.dart:1085)
E/flutter (14589): #6      _CustomZone.runUnaryGuarded (dart:async/zone.dart:987)
E/flutter (14589): #7      _CustomZone.bindUnaryCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1024)
E/flutter (14589): #8      _rootRunUnary (dart:async/zone.dart:1196)
E/flutter (14589): #9      _CustomZone.runUnary (dart:async/zone.dart:1085)
E/flutter (14589): #10     _CustomZone.bindUnaryCallback.<anonymous closure> (dart:async/zone.dart:1008)
E/flutter (14589): #11     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398)
E/flutter (14589): #12     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429)
E/flutter (14589): #13     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168)
E/flutter (14589): 
E/flutter (14589): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Bad state: No element
E/flutter (14589): #0      _GrowableList.single (dart:core-patch/growable_array.dart:229)
E/flutter (14589): #1      ScrollController.position (package:flutter/src/widgets/scroll_controller.dart:112)
E/flutter (14589): #2      PageController.page (package:flutter/src/widgets/page_view.dart:147)
E/flutter (14589): #3      CarouselState.initState.<anonymous closure> (package:carousel_pro/src/carousel_pro.dart:110)
E/flutter (14589): #4      _rootRunUnary (dart:async/zone.dart:1192)
E/flutter (14589): #5      _CustomZone.runUnary (dart:async/zone.dart:1085)
E/flutter (14589): #6      _CustomZone.runUnaryGuarded (dart:async/zone.dart:987)
E/flutter (14589): #7      _CustomZone.bindUnaryCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1024)
E/flutter (14589): #8      _rootRunUnary (dart:async/zone.dart:1196)
E/flutter (14589): #9      _CustomZone.runUnary (dart:async/zone.dart:1085)
E/flutter (14589): #10     _CustomZone.bindUnaryCallback.<anonymous closure> (dart:async/zone.dart:1008)
E/flutter (14589): #11     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398)
E/flutter (14589): #12     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429)
E/flutter (14589): #13     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168)

Image onTap

When I want to click on the image to another page, I don't know how to do.

Stop slide animation on screen touch

Is it possibe to stop sliding when the user tap on the screen ?

I tried to solve this issue by changing the autoplay to false ontap.. but still stuck.

Box Fit always set to Cover

Line 140 of carousel_pro.dart:

fit: BoxFit.cover,

It seems to be forced on cover, instead it should be like:

fit: widget.boxFit,

fit: BoxFit.Cover

I can't see any documentation on whether images can me fitted with box fit cover, this is very important for an image package, I think.. Am I missing something?

Carousel in Listview

Hi,

I have used the below code to show the carousel. However, it won't work. Can you tell me how to use the carousel in listview?

Code


SizedBox(
                  height: 200,
                  width: double.infinity,
                  child: ListView.builder(
                    itemCount: demoProductCarousel.length,
                    itemBuilder: (_, i) {
                      return Carousel(
                        dotSize: 4.0,
                        dotSpacing: 15.0,
                        dotColor: kPrimaryColor,
                        indicatorBgPadding: 15.0,
                        dotBgColor: Colors.transparent,
                        dotVerticalPadding: 5.0,
                        dotPosition: DotPosition.bottomRight,
                        images: [
                          Image.asset(
                            demoProductCarousel[i].imagePath,                            
                            fit: BoxFit.cover,
                          )
                        ],
                      );
                    },
                  ),
)

Thanks

FadeInImage requires BorderRadius

When using FadeInImage, borderReadius is required because it uses ClipRRect and when borderRadius is set to false, a borderradius of null is supplied which is not allowed. Workaround: borderRadius: true, radius: Radius.zero

Not work properly in android

everything works good in ios but in android when the last image loaded then it does not rotate to the first image.

Auto-play stops at the last image

In Android device, when you set the autoplay to true, the Carousel works like a charm but stops at the last image. I couldn't find any setting in properties for infinite looping or sth. like this, Is it possible to do that ?

Infinite Loop Not working?

Having problem above?
Just find if(_controller.page == widget.images.length-1) {
replace it to if(_controller.page.round() == widget.images.length-1) {

I don't know if this is permanent fix, but somehow _controller.page return double, so it needs to be rounded

@jlouage Also if you don't mind please change image argument not just ImageProvider, because I need widget children, if that's possible.. thanks

Showing a error

Scaffold(
body: Stack(
children: [
BackgroundImageInContainer(),
Align(
child: Container(
// color: Colors.cyan,
height: getPercentSize(70, true, context),
child: Carousel(
images: [
intro1(context),
intro2(context),
intro3(context),
intro4(context),
],
dotSize: 4.0,
dotSpacing: 15.0,
dotColor: Colors.blueAccent,
indicatorBgPadding: 5.0,
dotBgColor: Colors.purple.withOpacity(0),
borderRadius: false,
moveIndicatorFromBottom: 180.0,
noRadiusForIndicator: true,
animationDuration: Duration(seconds: 2),
autoplayDuration: Duration(seconds: 5),
animationCurve: Curves.decelerate,
),
),
),

'package:flutter/src/rendering/sliver_fixed_extent_list.dart': Failed assertion: line 276 pos 12: 'firstIndex == 0 || childScrollOffset(firstChild) - scrollOffset <= precisionErrorTolerance': is not true.

image

[Feature] Support CachedNetworkImages

This will help improve presentation without a lengthy workaround. Although it would show loading the first time, it would load from the cache on subsequent runs.
Ignore horrible quality gif

carouselpro

Image Alignment

I need an alignment property like this : "alignment: FractionalOffset.topCenter". How can I handle this?

crash on exit

hi .
crash on exit because PageController not disposed .
here the log
`[ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter ( 2562): 'package:flutter/src/widgets/page_view.dart': Failed assertion: line 96 pos 7: 'positions.isNotEmpty': PageController.page cannot be accessed before a PageView is built with it.
E/flutter ( 2562): #0 _AssertionError._doThrowNew (dart:core/runtime/liberrors_patch.dart:37:39)
E/flutter ( 2562): #1 _AssertionError._throwNew (dart:core/runtime/liberrors_patch.dart:33:5)
E/flutter ( 2562): #2 PageController.page (package:flutter/src/widgets/page_view.dart)
E/flutter ( 2562): #3 CarouselState.initState. (package:carousel_pro/src/carousel_pro.dart:110:24)
E/flutter ( 2562): #4 _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
E/flutter ( 2562): #5 _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
E/flutter ( 2562): #6 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:165:12)

`

setState() called after dispose(): _ImageState#04f75(lifecycle state: defunct, not mounted, stream: ImageStream#a48f7(MultiFrameImageStreamCompleter#286e8, [1680×1050] @ 1.0x, 2 listeners), pixels: null, loadingProgress: null, frameNumber: null, wasSynchronouslyLoaded: false)

I am using flutter carousel pro and in somehow I am getting this error any solution?

it says like this:
The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree.
This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose().

control in tabview error

Performing hot restart...
E/flutter (18054): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter (18054): 'package:flutter/src/widgets/page_view.dart': Failed assertion: line 96 pos 7: 'positions.isNotEmpty': PageController.page cannot be accessed before a PageView is built with it.
E/flutter (18054): #0 _AssertionError._doThrowNew (dart:core/runtime/liberrors_patch.dart:37:39)
E/flutter (18054): #1 _AssertionError._throwNew (dart:core/runtime/liberrors_patch.dart:33:5)
E/flutter (18054): #2 PageController.page (package:flutter/src/widgets/page_view.dart)
E/flutter (18054): #3 CarouselState.initState. (package:carousel_pro/src/carousel_pro.dart:110:24)
E/flutter (18054): #4 _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
E/flutter (18054): #5 _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
E/flutter (18054): #6 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:165:12)
Restarted app in 1,805ms.
I/flutter (18054): start

Autoplay is not working and errors are display on stack

E/flutter ( 7048): NoSuchMethodError: The method 'round' was called on null.
E/flutter ( 7048): Receiver: null
E/flutter ( 7048): Tried calling: round()
E/flutter ( 7048): #0 Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:46:5)
E/flutter ( 7048): #1 PageController.nextPage (package:flutter/src/widgets/page_view.dart:142:31)
E/flutter ( 7048): #2 CarouselState.initState. (package:carousel_pro/src/carousel_pro.dart:117:23)
E/flutter ( 7048): #3 _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
E/flutter ( 7048): #4 _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
E/flutter ( 7048): #5 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:165:12)
D/ ( 7048): HostConnection::get() New Host Connection established 0xa8508440, tid 7205
D/EGL_emulation( 7048): eglMakeCurrent: 0x9ae32820: ver 2 0 (tinfo 0xa85031f0)

use carousel with dynamic widget

hello, I search to add custon widget in carousel. Currently all carousel use only image. But if "children[ my widgets] " can be add , it will be perfect. thank you

[Suggestion] Add callback to some events.

I think that:

  • onPressed(int count)
  • an event fired when the carousel goes to the end, and the user still drag it

are necessary.

Hope you can implement, thanks~

(Or just close this issue, never mind.)

Infinite loop not working!

Animation gets stuck at last item, doesn't return to first element. Also items are aggressively going to next slide while sliding back to previous slide.

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, v0.5.6-pre.26, on Microsoft Windows [Version 10.0.17134.112], locale en-IN)
[√] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[√] Android Studio (version 3.1)
[!] VS Code, 64-bit edition (version 1.25.0)
[√] Connected devices (1 available)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.