getwidget icon indicating copy to clipboard operation
getwidget copied to clipboard

Error when there are multiple Carousel Widget in one screen

Open helloalbin opened this issue 4 years ago • 1 comments

Describe the bug An exception is thrown when there are multiple carousels widget in a single screen.

======= Exception caught by widgets library =======================================================
The following assertion was thrown building AnimatedBuilder(animation: PageController#83143(2 clients), dirty, state: _AnimatedState#b14ef):
ScrollController attached to multiple scroll views.
'package:flutter/src/widgets/scroll_controller.dart':
Failed assertion: line 108 pos 12: '_positions.length == 1'

The relevant error-causing widget was: 
  AnimatedBuilder AnimatedBuilder:file:///C:/Apps/flutter/.pub-cache/hosted/pub.dartlang.org/getwidget-2.0.4/lib/components/carousel/gf_carousel.dart:228:22
When the exception was thrown, this was the stack: 
#2      ScrollController.position (package:flutter/src/widgets/scroll_controller.dart:108:12)
#3      _GFCarouselState.build.<anonymous closure>.<anonymous closure> (package:getwidget/components/carousel/gf_carousel.dart:238:40)
#4      AnimatedBuilder.build (package:flutter/src/widgets/transitions.dart:1032:19)
#5      _AnimatedState.build (package:flutter/src/widgets/transitions.dart:134:48)
#6      StatefulElement.build (package:flutter/src/widgets/framework.dart:4870:27)
#7      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4754:15)
#8      StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
#9      Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)

To Reproduce Create a page with multiple carousels without a height.

Expected behavior No exception should be thrown.

Smartphone (please complete the following information):

  • OS: Android 11

Note: This works fine if we specify the height parameter.

helloalbin avatar Feb 19 '22 18:02 helloalbin

@helloalbin

Hey, please share code example for the above. We tried to add multiple carousel in one page and its working fine. Thanks

abhishekk-788 avatar Mar 29 '22 11:03 abhishekk-788