diff --git a/lib/community/community_course.dart b/lib/community/community_course.dart index ba22dadb..81854309 100644 --- a/lib/community/community_course.dart +++ b/lib/community/community_course.dart @@ -55,9 +55,16 @@ class _CommunityCourse extends State setState(() {}); } }); - queryCourseBanner(); - classListAsync(); - collectionList(); + if (apiService == null) { + SharedPreferences.getInstance().then((value) { + apiService = ApiService( + Dio(), + context: context, + token: value.getString("token"), + ); + _onRefresh(); + }); + } } ///banner diff --git a/lib/community/community_view/class_details_video.dart b/lib/community/community_view/class_details_video.dart index e94cc065..05c236db 100644 --- a/lib/community/community_view/class_details_video.dart +++ b/lib/community/community_view/class_details_video.dart @@ -31,9 +31,9 @@ class ClassDetailsVideo extends StatefulWidget { } class ClassDetailsVideoState extends State { - late VideoPlayerController videoPlayerController; - late ChewieController chewieAudioController; - late Chewie chewies; + VideoPlayerController? videoPlayerController; + ChewieController? chewieAudioController; + Chewie? chewies; GlobalKey globalKey = GlobalKey(); double height = 0; @@ -60,14 +60,14 @@ class ClassDetailsVideoState extends State { } initVideo(videoUrl) async { - videoPlayerController.pause(); - videoPlayerController.dispose(); + videoPlayerController?.pause(); + videoPlayerController?.dispose(); videoPlayerController = VideoPlayerController.networkUrl( Uri.parse(videoUrl), )..initialize().then((value) { chewieAudioController = ChewieController( - videoPlayerController: videoPlayerController, - aspectRatio: videoPlayerController.value.aspectRatio, + videoPlayerController: videoPlayerController!, + aspectRatio: videoPlayerController?.value.aspectRatio, // aspectRatio: 1.44, //宽高比 autoPlay: false, @@ -87,7 +87,7 @@ class ClassDetailsVideoState extends State { // 拖动条样式颜色 autoInitialize: true, ); - chewieAudioController.addListener(_fullScreenListener); + chewieAudioController?.addListener(_fullScreenListener); if (mounted) setState(() {}); }); } @@ -101,7 +101,7 @@ class ClassDetailsVideoState extends State { ), color: Colors.black, key: globalKey, - child: (videoPlayerController.value.isInitialized ?? false) + child: (videoPlayerController?.value.isInitialized ?? false) ? videoWidget( MediaQuery.of(context).size.height, (MediaQuery.of(context).size.height / 1.44) - 43, @@ -115,11 +115,11 @@ class ClassDetailsVideoState extends State { void dispose() { super.dispose(); - chewieAudioController.pause(); - chewieAudioController.dispose(); + chewieAudioController?.pause(); + chewieAudioController?.dispose(); - videoPlayerController.pause(); - videoPlayerController.dispose(); + videoPlayerController?.pause(); + videoPlayerController?.dispose(); } Widget videoWidget(double width, double height, src) { @@ -137,7 +137,7 @@ class ClassDetailsVideoState extends State { height: MediaQuery.of(context).size.width / 1.5, // margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top), child: chewies = Chewie( - controller: chewieAudioController, + controller: chewieAudioController!, ), ) : Container( @@ -150,7 +150,7 @@ class ClassDetailsVideoState extends State { onTap: () { setState(() { widget.changeShowImg?.call(false); - chewieAudioController.play(); + chewieAudioController?.play(); }); }, child: Container( @@ -189,7 +189,7 @@ class ClassDetailsVideoState extends State { } Future _fullScreenListener() async { - if (!chewieAudioController.isFullScreen) { + if (!(chewieAudioController?.isFullScreen ?? false)) { Future.delayed(Duration(seconds: 1), () { widget.exitFull?.call(); }); diff --git a/lib/order/order_detail_page.dart b/lib/order/order_detail_page.dart index e8370049..6efd8440 100644 --- a/lib/order/order_detail_page.dart +++ b/lib/order/order_detail_page.dart @@ -113,7 +113,7 @@ class _OrderDetailPage extends State { refreshController.loadFailed(); }); if (baseData?.isSuccess ?? false) { - orderInfo = baseData!.data; + orderInfo = baseData?.data; payStatus = orderInfo?.payStatus ?? 0; orderStatus = orderInfo?.orderStatus ?? 0; sendStatus = orderInfo?.sendStatus ?? 0;