build method
Implementation
@override
Widget build(BuildContext context) {
// Check if widget is visible before wasting resources on building it
if (!widget.model.visible) return const Offstage();
// create the view
Widget view = Container();
if (_controller != null && _controller!.value.isInitialized) {
var videoPlayer = VideoPlayer(_controller!);
var subTitles = ClosedCaption(text: _controller!.value.caption.text);
var progressBar = widget.model.controls
? VideoProgressIndicator(_controller!, allowScrubbing: true)
: const Offstage();
var playButton =
widget.model.controls ? getPlayButton() : const Offstage();
var speedButton =
widget.model.controls ? getSpeedButton() : const Offstage();
var stack = Stack(alignment: Alignment.bottomCenter, children: <Widget>[
videoPlayer,
subTitles,
speedButton,
playButton,
progressBar
]);
view = AspectRatio(
aspectRatio: _controller!.value.aspectRatio, child: stack);
view = GestureDetector(onTap: startstop, child: view);
}
// add margins
view = addMargins(view);
// apply user defined constraints
view = applyConstraints(view, widget.model.tightestOrDefault);
// apply visual transforms
view = applyTransforms(view);
// final view
return view;
}