Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Carousel_slider is Showing two imports #443

Open
MelvinITOI opened this issue Jun 11, 2024 · 6 comments
Open

Carousel_slider is Showing two imports #443

MelvinITOI opened this issue Jun 11, 2024 · 6 comments

Comments

@MelvinITOI
Copy link

/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

@kishan-dhankecha
Copy link

Hi, @MelvinITOI

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

@dhirajbajaj
Copy link

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

@kishan-dhankecha
Copy link

It's already live!! check carousel_slider_plus

@dhirajbajaj
Copy link

dhirajbajaj commented Jun 13, 2024

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?

@kishan-dhankecha
Copy link

Duplicate of #442

@lucas-almeida026
Copy link

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants