我正在尝试使用以下软件包fan_carousel_image_slider 0.1.2
显示滑块
完整错误文本:
_AssertionError('package:fan_carousel_image_slider/src/image_slider. dart':Assert失败:第49行位置16:'initalPageIndex <=(imagesLink.length - 1)&& initalPageIndex >= 0':这不是真的)。
我尝试更改属性和图像大小,但没有任何结果。
import 'package:fan_carousel_image_slider/fan_carousel_image_slider.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const Outlet());
}
class Outlet extends StatelessWidget {
const Outlet({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Outlet',
theme: ThemeData(
primarySwatch: Colors.red,
primaryColor: Colors.red[800],
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
static List<String> sampleImages = [
"assets/images/Sample (1).jpg"
"assets/images/Sample (2).jpg"
"assets/images/Sample (3).jpg"
"assets/images/Sample (4).jpg"
];
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Column(
children: <Widget>[
FanCarouselImageSlider(
imagesLink: MyHomePage.sampleImages,
isAssets: true,
autoPlay: true,
),
],
),
1条答案
按热度按时间tyky79it1#
删除Static关键字并将列表移动到_MyHomPageState类下面: