flutter_carousel_slider icon indicating copy to clipboard operation
flutter_carousel_slider copied to clipboard

Carousel_slider is Showing two imports

Open MelvinITOI opened this issue 1 year ago • 6 comments

/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

MelvinITOI avatar Jun 11 '24 16:06 MelvinITOI

Hi, @MelvinITOI

This issue is already resolved on kishan-dhankecha/carousel_slider_plus@12fd3ee and soon will be pushed to the pub.dev.

kishan-dhankecha avatar Jun 11 '24 16:06 kishan-dhankecha

When can the change be live. It is throwing error on vercel

dhirajbajaj avatar Jun 12 '24 15:06 dhirajbajaj

It's already live!! check carousel_slider_plus

kishan-dhankecha avatar Jun 12 '24 16:06 kishan-dhankecha

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?

dhirajbajaj avatar Jun 13 '24 09:06 dhirajbajaj

Duplicate of #442

kishan-dhankecha avatar Jun 13 '24 09:06 kishan-dhankecha

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:

  1. download the code from flutterflow
  2. unzip the folder and open it using the code editor (in my case VScode)
  3. run flutter pub cache repair (it takes a while to finish)
  4. try to run the app (using your device id) flutter run -d <device_id> it will fail
  5. 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/Cache which indicates these files are related to pub packages. Open the file that contains the path carousel_slider-4.2.1/lib/carousel_slider.dart
  6. use Ctrl + F and search for the term CarouselController using both Match Case and Match Whole Word features find-and-replace
  7. replace all instances of CarouselController with CarouselControllerPlus this is case sensitive, so pay attention
  8. now change the search and replace all instance of carouselController with carouselControllerPlus and save the file
  9. go to the file carousel_controller.dart also inside the folder lib and repeat the process, replace all CarouselController with CarouselControllerPlus. there are no instances of carouselController in 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:

  1. 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()
  2. Ctrl + click (jump to definition) on the model.carouselController and replace CarouselController with CarouselControllerPlus and carouselController with carouselControllerPlus. (don't click in the word "model", click in the word "carouselController")
  3. go back to the page file and replace CarouselController with CarouselControllerPlus and carouselController with carouselControllerPlus

don't forget to save all files of course

now lets run the command again and it should work flutter run -d <device_id>

lucas-almeida026 avatar Sep 09 '24 23:09 lucas-almeida026

Fixed in v5.0.0 and above, please upgrade your version

serenader2014 avatar Jun 07 '25 07:06 serenader2014