Skip to content

[Bug]: This widget has been unmounted #59

Open
@RTAzis

Description

@RTAzis

Description:

When using a FlutterCarouselController in a parent widget, if the child FlutterCarousel widget is unmounted and startAutoPlay() is called, it leads to an unmounted error. Additionally, checking controller.ready still returns true. The _FlutterCarouselState should check its mounted state before interacting with the controller and properly dispose of it when the widget is unmounted.

Steps to Reproduce:

  1. Create a parent widget with a FlutterCarouselController.
  2. In the child widget, use FlutterCarousel with this controller.
  3. Unmount the child widget while the carousel is running.
  4. Call startAutoPlay() on the controller.
  5. The unmounted error occurs because the child widget is no longer in the widget tree.

Version

^3.1.0

What devices are you seeing the problem on?

Android

OS

Android API 35

Relevant log output

#2      _FlutterCarouselState._getTimer.<anonymous closure> (package:flutter_carousel_widget/src/_flutter_carousel_widget.dart:213:35)
_flutter_carousel_widget.dart:213
      #3      _rootRunUnary (dart:async/zone.dart:1407:47)
zone.dart:1407
      #4      _CustomZone.runUnary (dart:async/zone.dart:1308:19)
zone.dart:1308
      #5      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1217:7)
zone.dart:1217
      #6      _CustomZone.bindUnaryCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1254:26)
zone.dart:1254
      #7      _rootRunUnary (dart:async/zone.dart:1415:13)
zone.dart:1415
      #8      _CustomZone.runUnary (dart:async/zone.dart:1308:19)
zone.dart:1308
      #9      _CustomZone.bindUnaryCallback.<anonymous closure> (dart:async/zone.dart:1238:26)
zone.dart:1238
      #10     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)
timer_impl.dart:398
      #11     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5)
timer_impl.dart:429
      #12     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
isolate_patch.dart:184

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions