Ensure that the controller is disposed only if initialized

This commit is contained in:
Vishnu Mohandas 2020-06-24 06:19:12 +05:30
parent 36467b6673
commit 4a90dde9a3

View file

@ -40,7 +40,9 @@ class _VideoWidgetState extends State<VideoWidget> {
@override
void dispose() {
_videoPlayerController.dispose();
_chewieController.dispose();
if (_chewieController != null) {
_chewieController.dispose();
}
super.dispose();
}
@ -66,6 +68,10 @@ class _VideoWidgetState extends State<VideoWidget> {
Widget _getLoadingWidget() {
return Stack(children: [
_getThumbnail(),
Container(
color: Colors.black12,
constraints: BoxConstraints.expand(),
),
loadWidget,
]);
}