fix: Hero导致videoPlayer渲染两次

This commit is contained in:
guozhigq
2023-08-28 17:15:30 +08:00
parent ce1daec3c5
commit f7e9fbaea7

View File

@ -187,9 +187,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
builder: (context, boxConstraints) { builder: (context, boxConstraints) {
double maxWidth = boxConstraints.maxWidth; double maxWidth = boxConstraints.maxWidth;
double maxHeight = boxConstraints.maxHeight; double maxHeight = boxConstraints.maxHeight;
return Hero( return Stack(
tag: videoDetailController.heroTag,
child: Stack(
children: [ children: [
FutureBuilder( FutureBuilder(
future: _futureBuilderFuture, future: _futureBuilderFuture,
@ -197,29 +195,29 @@ class _VideoDetailPageState extends State<VideoDetailPage>
if (snapshot.hasData && if (snapshot.hasData &&
snapshot.data['status']) { snapshot.data['status']) {
return Obx( return Obx(
() => videoDetailController () => !videoDetailController
.autoPlay.value .autoPlay.value
? PLVideoPlayer( ? const SizedBox()
controller: : PLVideoPlayer(
plPlayerController!, controller: plPlayerController!,
headerControl: HeaderControl( headerControl: HeaderControl(
controller: controller:
plPlayerController, plPlayerController,
videoDetailCtr: videoDetailCtr:
videoDetailController, videoDetailController,
), ),
) ),
: const SizedBox(),
); );
} else { } else {
return const SizedBox(); return const SizedBox();
} }
}), }),
), ),
Obx( Obx(
() => Visibility( () => Visibility(
visible: videoDetailController visible:
.isShowCover.value, videoDetailController.isShowCover.value,
child: Positioned( child: Positioned(
top: 0, top: 0,
left: 0, left: 0,
@ -242,8 +240,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
.isShowCover.value && .isShowCover.value &&
videoDetailController videoDetailController
.isEffective.value && .isEffective.value &&
!videoDetailController !videoDetailController.autoPlay.value,
.autoPlay.value,
child: Stack( child: Stack(
children: [ children: [
Positioned( Positioned(
@ -281,8 +278,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
style: ButtonStyle( style: ButtonStyle(
backgroundColor: backgroundColor:
MaterialStateProperty MaterialStateProperty
.resolveWith( .resolveWith((states) {
(states) {
return Theme.of(context) return Theme.of(context)
.colorScheme .colorScheme
.primaryContainer; .primaryContainer;
@ -300,7 +296,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
)), )),
), ),
], ],
),
); );
}, },
), ),