build method
Builds a video player widget.
The widget is a GestureDetector that wraps a VideoPlayer in an
AspectRatio widget. When the video is not playing, a play arrow icon
is displayed centered on top of the video. If the video is not yet
initialized, a CircularProgressIndicator is displayed instead.
Implementation
@override
/// Builds a video player widget.
///
/// The widget is a [GestureDetector] that wraps a [VideoPlayer] in an
/// [AspectRatio] widget. When the video is not playing, a play arrow icon
/// is displayed centered on top of the video. If the video is not yet
/// initialized, a [CircularProgressIndicator] is displayed instead.
Widget build(BuildContext context) {
return Center(
child: _controller != null && _controller!.value.isInitialized
? Stack(
alignment: Alignment.center,
children: <Widget>[
GestureDetector(
onTap: _togglePlayPause,
child: AspectRatio(
aspectRatio: _controller!.value.aspectRatio,
child: VideoPlayer(_controller!),
),
),
if (!_isPlaying)
const Icon(
Icons.play_arrow,
size: 60,
color: Colors.white,
),
],
)
: const Center(child: CircularProgressIndicator()),
);
}