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
CarouselSliderState - isn't a type so it can't be used as a type argument #20
Comments
I couldn't reproduce this issue. Can you attach some stack traces? |
Just uploaded v1.1.0. Please let me know if the issue is still there in version 1.1.0 |
Hey, there were some errors in the example code that have not been errors in previous version of flutter but are related to the If you change the minimal example to import 'package:flutter/material.dart';
import 'package:flutter_carousel_slider/carousel_slider.dart';
import 'package:flutter_carousel_slider/carousel_slider_indicators.dart';
import 'package:flutter_carousel_slider/carousel_slider_transforms.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Cube Slider Try Out App',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final List<Color> colors = [
Colors.red,
Colors.orange,
Colors.yellow,
Colors.green,
Colors.blue,
Colors.indigo,
Colors.purple,
];
final List<String> letters = [
"A",
"B",
"C",
"D",
"E",
"F",
"G",
];
bool _isPlaying = true;
late CarouselSliderController _sliderController;
@override
void initState() {
super.initState();
_sliderController = CarouselSliderController();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: ListView(
children: <Widget>[
Container(
height: 500,
child: CarouselSlider.builder(
unlimitedMode: true,
controller: _sliderController,
slideBuilder: (index) {
return Container(
alignment: Alignment.center,
color: colors[index],
child: Text(
letters[index],
style: TextStyle(fontSize: 200, color: Colors.white),
),
);
},
slideTransform: CubeTransform(),
slideIndicator: CircularSlideIndicator(
padding: EdgeInsets.only(bottom: 32),
indicatorBorderColor: Colors.black,
),
itemCount: colors.length,
initialPage: 0,
enableAutoSlider: true,
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 32),
child: Align(
child: ConstrainedBox(
constraints: BoxConstraints(minWidth: 240, maxWidth: 600),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
IconButton(
iconSize: 48,
icon: Icon(Icons.skip_previous),
onPressed: () {
_sliderController.previousPage();
},
),
IconButton(
iconSize: 64,
icon: Icon(
_isPlaying ? Icons.pause_circle_outline : Icons.play_circle_outline,
),
onPressed: () {
setState(
() {
_isPlaying = !_isPlaying;
_sliderController.setAutoSliderEnabled(_isPlaying);
},
);
},
),
IconButton(
iconSize: 48,
icon: Icon(Icons.skip_next),
onPressed: () {
_sliderController.nextPage();
},
),
],
),
),
),
),
],
),
);
}
} it is working fine for me. PS: Is it possible to also have the cube effect vertically and horizontally at the same time? Sources: |
With
flutter 3.3.
I get the following error in Visual Studio Code when trying to run the example:for the line
and when trying to execute the code with
flutter run -d chrome
I imported the modules like
The text was updated successfully, but these errors were encountered: