I have added "carousel_pro: ^1.0.0" under dependencies in my pubspec.yaml file and imported in my desired file using "import ‘package:carousel_pro/carousel_pro.dart’;".
Heres the whole file
import 'package:carousel_pro/carousel_pro.dart';
import 'package:flutter/material.dart';
class CarouselImages extends StatefulWidget {
final List<String> imagesListUrl;
CarouselImages(this.imagesListUrl);
@override
_CarouselImagesState createState() => _CarouselImagesState();
}
class _CarouselImagesState extends State<CarouselImages> {
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Container(
height: size.height * 0.35,
child: Carousel(
dotSize: 5,
dotBgColor: Colors.transparent,
autoplay: false,
images: [
AssetImage(widget.imagesListUrl[0],),
AssetImage(widget.imagesListUrl[1],),
AssetImage(widget.imagesListUrl[2],),
AssetImage(widget.imagesListUrl[3],),
AssetImage(widget.imagesListUrl[4],),
AssetImage(widget.imagesListUrl[5],),
],
),
);
}
}
But the code is not running, I have a red line underlined at the import and carousel widget.
Hovering over the import code it says:Target of URI doesn’t exist: ‘package:carousel_pro/carousel_pro.dart’.dart(uri_does_not_exist)
and when I hover over the widget it says The method ‘Carousel’ isn’t defined for the type _CarouselImagesState'.dart(undefined_method)
Quick fixes are telling me to create class, method or function.
Help me solve this
I tried upgrading and downgrading flutter and dart versions, and also the carousel package. I also tried changing from carousel_pro to carousel_slider but its still not working.
I expected that this would solve the issue by having a more stable version of dart and flutter or the dependency
2
Answers
1.this library is not supported by latest versions of flutter
2.in the description of the question you did not indicate the version of flutter installed on your PC
3.I recommend trying another library, for example this one
screenshot from pub dev
The carousel package is on some old version of Flutter.
Let me help. Create your own carousel file. Here’s the code:
There’s a file where i keep all my constants, which is referenced in this code. Here’s the relevant bits.
Enjoy