我正在为carousel_slider 4.0.0使用我的颤振(空安全版本)应用程序,滑块工作但是,我遇到了这个错误
类型“Null”不是类型转换中“List”类型的子类型
有什么解决方案吗?
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:flutter_svg/svg.dart';
import 'package:carousel_slider/carousel_slider.dart';
import 'package:rmapp/provider/theme_provider.dart';
class HomeScreen extends StatefulWidget {
@override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
//swiper current index
late final List<String> imageList = [
"https://www.setaswall.com/wp-content/uploads/2018/08/Spiderman-Wallpaper-76-1280x720.jpg",
"https://lh3.googleusercontent.com/proxy/yL2FmQfZA79S5eIDza9MH2NjKGIKWPOGRHxHdYwiNPcYDW26YmK6qnP01ZDLsBENZpiADc1ohkj3LzVjrwoX8Pb-crT6MYZb3Jp9gy3ZrlET_yvoFS0qtUHLq4DtVPcqIdxPiNWI_j08omBVACv-YJc",
];
@override
Widget build(BuildContext context) {
Provider.of<ThemeProvider>(context).themeMode == ThemeMode.dark
? 'DarkTheme'
: 'LightTheme';
return Scaffold(
// Setting up AppBar
appBar: AppBar(
automaticallyImplyLeading: false,
iconTheme: Theme.of(context).iconTheme,
),
// Setting up Background Color
// Body
body: Container(
child: ListView(
physics: ClampingScrollPhysics(),
children: <Widget>[
Padding(
padding: EdgeInsets.only(left: 16, bottom: 10, top: 10,),
child: Text(
'Hi, Welcome back!',
//style: mTitleStyle,
),
),
//Promo Slider
_promoSlider(),
],
),
),
);
}
//Promo Slider
Widget _promoSlider() {
return Container(
child: CarouselSlider(
options: CarouselOptions(
enlargeCenterPage: true,
enableInfiniteScroll: false,
autoPlay: true,
),
items: imageList.map((e) => ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Stack(
fit: StackFit.expand,
children: <Widget>[
Image.network(e,
width: 1050,
height: 350,
fit: BoxFit.cover,)
],
) ,
)).toList(),
),);
}
}