Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cat-voices): didUpdateWidget can't await async func #1680

Merged
merged 4 commits into from
Jan 27, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,12 @@ class _HeroSectionState extends State<HeroSection>
}

@override
Future<void> didUpdateWidget(covariant HeroSection oldWidget) async {
void didUpdateWidget(covariant HeroSection oldWidget) {
super.didUpdateWidget(oldWidget);

if (oldWidget.asset != widget.asset ||
oldWidget.assetPackageName != widget.assetPackageName) {
await _controller?.dispose();
_controller = VideoPlayerController.asset(
widget.asset,
package: widget.assetPackageName,
);
if (mounted) {
await _initalizedVideoPlayer();
}
unawaited(_disposeAndReinitializeVideoPlayer());
}
}

Expand Down Expand Up @@ -103,6 +96,17 @@ class _HeroSectionState extends State<HeroSection>
setState(() {});
}
}

Future<void> _disposeAndReinitializeVideoPlayer() async {
if (mounted) {
await _controller?.dispose();
_controller = VideoPlayerController.asset(
widget.asset,
package: widget.assetPackageName,
);
await _initalizedVideoPlayer();
}
}
LynxLynxx marked this conversation as resolved.
Show resolved Hide resolved
}

class _Background extends StatelessWidget {
Expand Down
Loading