I start receiving this error when I try to run my flutter app
and before I received same error but with image that it’s from flutter material and coincide with image from another package I got. What I should do? I comment where I had image but I know this is not the right solution
The error you’re encountering is due to the CarouselController being imported from two different packages, leading to a naming conflict. To resolve this, you can give a nickname to one of the imports to differentiate between the two controllers. Here’s how you can structure your code:
To resolve this conflict, you can give a nickname to one of the imports using the ‘as’ keyword and use that nickname whenever you need to refer to the class or function from that package.
import 'package:carousel_slider/carousel_controller.dart' as carousel_slider;
import 'package:flutter/material.dart';
Now, use this ‘carousel_slider’ to refer to CarouselController from carousel_slider package
var controller = carousel_slider.CarouselController();
2
Answers
It have conflict import in lib you can try to folk and fix it like this guy did or just use this repo https://github.com/amarjeetpatidar007/flutter_carousel_widget
or just use alternative lib like
infinite_carousel
or other carousel libhope this will solve your problem
ref : https://stackoverflow.com/a/78690727/10423080
The error you’re encountering is due to the CarouselController being imported from two different packages, leading to a naming conflict. To resolve this, you can give a nickname to one of the imports to differentiate between the two controllers. Here’s how you can structure your code:
conflicting imports:
To resolve this conflict, you can give a nickname to one of the imports using the ‘as’ keyword and use that nickname whenever you need to refer to the class or function from that package.
Now, use this ‘carousel_slider’ to refer to CarouselController from carousel_slider package