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.21k stars 26.65k forks source link

Animation exception when using Carousel and ReorderableListView - Flutter #146757

Closed gamba-letto closed 1 month ago

gamba-letto commented 1 month ago

Steps to reproduce

  1. Create a flutter project
  2. Add a Carousel with two or more items (in my case I have two)
  3. Inside each carousel's child add a ReorderableListView.builder and manage the reorder with a function
  4. Reorder the item of the ReorderableListView and then switch to a different carousel's child

Expected results

I should expect a simple behaviour

Actual results

It throws an exception like the following one: 'package:flutter/src/animation/animation_controller.dart': Failed assertion: line 822 pos 12: 'elapsedInSeconds >= 0.0': is not true.

Code sample

Code sample ```dart Expanded( child: Align( alignment: Alignment.topLeft, child: CarouselSlider( items: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'First Page', style: Theme.of(context).textTheme.bodyMedium, ), const Gap(15), Expanded( child: ValueListenableBuilder( valueListenable: travel, builder: (context, index, _) { return ReorderableListView.builder( buildDefaultDragHandles: false, onReorder: (oldIndex, newIndex) => reorder(oldIndex, newIndex), itemCount: (travel.value.poi ?? []).length, itemBuilder: (context, index) { return Card( key: ValueKey(travel.value.poi![index]), color: Theme.of(context).cardColor, child: ReorderableDragStartListener( index: index, child: Padding( padding: const EdgeInsets.all(8), child: Text(travel.value.poi![index].name ?? ''), ), ), ); }, ); }, ), ), ], ), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Second Page', style: Theme.of(context).textTheme.bodyMedium, ), const Gap(15), Expanded( child: ValueListenableBuilder( valueListenable: travel, builder: (context, index, _) { return ReorderableListView.builder( buildDefaultDragHandles: false, onReorder: (oldIndex, newIndex) => reorder(oldIndex, newIndex), itemCount: (travel.value.poi ?? []).length, itemBuilder: (context, index) { return Card( key: ValueKey(travel.value.poi![index]), color: Theme.of(context).cardColor, child: ReorderableDragStartListener( index: index, child: Padding( padding: const EdgeInsets.all(8), child: Text(travel.value.poi![index].name ?? ''), ), ), ); }, ); }, ), ), ], ), ], options: CarouselOptions( initialPage: 0, autoPlay: false, //Mostra interamente l'elemento selezionato della lista, senza mostrare lateralmente gli altri viewportFraction: 1, enableInfiniteScroll: false, onPageChanged: (index, reason) { setState(() { indiceScelto = index; }); }, ), ), ), ), ```

Screenshots or Video

Screenshots / Video demonstration [Upload media here] errore1 errore2

Logs

Logs ```console [Paste your logs here] ```

Flutter Doctor output

Doctor output ```console [√] Flutter (Channel stable, 3.16.0, on Microsoft Windows [Versione 10.0.22631.3447], locale it-IT) • Flutter version 3.16.0 on channel stable at C:\ws\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision db7ef5bf9f (5 months ago), 2023-11-15 11:25:44 -0800 • Engine revision 74d16627b9 • Dart version 3.2.0 • DevTools version 2.28.2 [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at C:\Users\gabriele.mestriner\AppData\Local\Android\sdk • Platform android-34, build-tools 34.0.0 • Java binary at: C:\Program Files\Android\Android Studio1\jbr\bin\java • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-10027231) • All Android licenses accepted. [√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe [√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.9.5) • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community • Visual Studio Community 2022 version 17.9.34723.18 • Windows 10 SDK version 10.0.22000.0 [!] Android Studio (version 2021.3) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart X Unable to determine bundled Java version. • Try updating or re-installing Android Studio. [√] Android Studio (version 2022.3) • Android Studio at C:\Program Files\Android\Android Studio1 • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-10027231) [√] VS Code (version 1.88.1) • VS Code at C:\Users\gabriele.mestriner\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.56.0 [√] Connected device (3 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Versione 10.0.22631.3447] • Chrome (web) • chrome • web-javascript • Google Chrome 123.0.6312.107 • Edge (web) • edge • web-javascript • Microsoft Edge 123.0.2420.97 [√] Network resources • All expected network resources are available. ! Doctor found issues in 1 category. ```
darshankawar commented 1 month ago

@gamba-letto Based on the error log, it seems similar to https://github.com/flutter/flutter/issues/106277 in which you can follow-up for further updates. Closing this as a duplicate. If you disagree, write in comments and I'll reopen it.

github-actions[bot] commented 2 weeks ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.