Carousel
将颤振更新到最新版本后,我遇到了这个异常。Carousel
在颤振版本 1.22.4 上运行良好。但是在切换到最新版本(2.0.3)时,我得到了这个例外。下面是代码和异常。我正在使用以下包
https://pub.dev/packages/carousel_pro
例外
════════ 渲染库捕获的异常══════════════════════════════S═下面的方法是═══S═错误在 performLayout() 期间抛出:在 null 上调用了 getter 'key'。接收者:null 尝试调用:key
相关的导致错误的小部件是 Carousel lib\...\homeViews\homeAppBarDelegate.dart:39 当抛出异常时,这是堆栈 #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5) # 1 SliverChildListDelegate.build 包:flutter/…/widgets/sliver.dart:722 #2 SliverMultiBoxAdaptorElement._build 包:flutter/…/widgets/sliver.dart:1201 #3 SliverMultiBoxAdaptorElement.createChild。package:flutter/…/widgets/sliver.dart:1214 #4 BuildOwner.buildScope package:flutter/…/widgets/framework.dart:2647 ... 引发异常时正在处理以下 RenderObject:RenderSliverFillViewport#4a87d relayoutBoundary =up2 NEEDS-LAYOUT NEEDS-PAINT RenderObject:RenderSliverFillViewport#4a87d relayoutBoundary=up2 NEEDS-LAYOUT NEEDS-PAINT parentData:paintOffset=Offset(0.0, 0.
代码
class HomeView extends StatefulWidget {
@override
_HomeViewState createState() => _HomeViewState();
}
class _HomeViewState extends State<HomeView> {
@override
Widget build(BuildContext context) {
return Scaffold(
...................
Stack(
children: [
CustomScrollView(
controller: _scrollController,
slivers: <Widget>[
SliverPersistentHeader(
delegate: HomeAppBarDelegate(
maxExtent: 230,
minExtent: 50,
),
pinned: true,
floating: false,
),
],
),
],
),
),
},
}
import 'package:carousel_pro/carousel_pro.dart';
class HomeAppBarDelegate extends SliverPersistentHeaderDelegate {
@override
Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) {
return Stack(
children: [
...................
// ------------------------------ C O V E R B L U R I M A G E S
Carousel(
animationCurve: Curves.easeInOutQuint,
animationDuration: Duration(seconds: 1),
dotBgColor: Colors.transparent,
overlayShadow: true,
autoplayDuration: Duration(seconds: 4),
showIndicator: false,
dotIncreasedColor: Colors.brown,
onImageChange: (prevInd, currInd) => coverImgIndex = currInd,
images: [
...coverImagesList.map(
(singleImg) => HomeBlurCoverImg(
imgURl: singleImg,
animationVal: animationVal,
maxExtent: maxExtent,
sizingInformation: sizingInformation,
),
),
],
),
],
),
获取空白屏幕