skip to Main Content

I start receiving this error when I try to run my flutter appenter image description here
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

2

Answers


  1. 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 lib

    hope this will solve your problem

    ref : https://stackoverflow.com/a/78690727/10423080

    Login or Signup to reply.
  2. 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:

    import 'package:carousel_slider/carousel_controller.dart';
    import 'package:flutter/src/material/carousel.dart';
    

    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();
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search