flutter_carousel_slider
flutter_carousel_slider copied to clipboard
Carousel_slider is Showing two imports
/C:/Users/melvi/AppData/Local/Pub/Cache/hosted/pub.dev/carousel_slider-4.2.1/lib/carousel_slider.dart:9:1: Error: 'CarouselController' is imported from both 'package:carousel_slider/carousel_controller.dart' and 'package:flutter/src/material/carousel.dart'. import 'carousel_controller.dart';
Before its working fine .But Now it showing error
This is my Flutter version Flutter 3.23.0
Hi, @MelvinITOI
This issue is already resolved on kishan-dhankecha/carousel_slider_plus@12fd3ee and soon will be pushed to the pub.dev.
When can the change be live. It is throwing error on vercel
It's already live!! check carousel_slider_plus
I am using: carousel_slider: 4.2.1 The code is generated by flutterflow automatically and imports carousal_slider everywhere. Its a massive task to replace this to your version. How do i do it?
Duplicate of #442
Here are steps to "fix" this issue (using a work around strategy) while we wait for the merge
I have one screen that uses the native carousel, and as far as I know, the steps are simple. However, the more instances of the component you have, the more changes you'll need to make. I'm testing the app locally using my Android phone in debug mode, so if your setup differs significantly from mine, the steps may not work for you.
Steps:
- download the code from flutterflow
- unzip the folder and open it using the code editor (in my case VScode)
- run
flutter pub cache repair(it takes a while to finish) - try to run the app (using your device id)
flutter run -d <device_id>it will fail - from the logs you'll see some files from the downloaded libraries, in my case, since I'm using windows, they contain
AppData/Local/Pub/Cachewhich indicates these files are related to pub packages. Open the file that contains the pathcarousel_slider-4.2.1/lib/carousel_slider.dart - use Ctrl + F and search for the term
CarouselControllerusing both Match Case and Match Whole Word features - replace all instances of
CarouselControllerwithCarouselControllerPlusthis is case sensitive, so pay attention - now change the search and replace all instance of
carouselControllerwithcarouselControllerPlusand save the file - go to the file
carousel_controller.dartalso inside the folderliband repeat the process, replace allCarouselControllerwithCarouselControllerPlus. there are no instances ofcarouselControllerin this file
now if we try to run the app again, it should still fail but the file paths shown in the error logs shouldn't include any paths from the pub get cache folder except for one which will probably include the message "Context: Found this candidate, but the arguments don't match."
All other file paths should be related to the usage of the Carousel widget on pages in your app, if you're also using the widget on a custom code then I don't know exactly how to fix them but it should be similar.
Now, for each file path in the logs that corresponds to a page in your app (in my case, there's only one), follow these steps:
- open the file (I use Ctrl + click on the file path), you should be placed in the line that is triggering the error, it probably looks like this
carouselController: _model.carouselController ??= CarouselController() - Ctrl + click (jump to definition) on the model.carouselController and replace
CarouselControllerwithCarouselControllerPlusandcarouselControllerwithcarouselControllerPlus. (don't click in the word "model", click in the word "carouselController") - go back to the page file and replace
CarouselControllerwithCarouselControllerPlusandcarouselControllerwithcarouselControllerPlus
don't forget to save all files of course
now lets run the command again and it should work flutter run -d <device_id>
Fixed in v5.0.0 and above, please upgrade your version