Edit: I just started studying Flutter and I still have a lot to learn. For now, I had a hard time looking for ways to replay a video. My goal is to replay a video when it is finished and a replay icon is shown for a user to click. These are the only packages I imported.
import 'package:video_player/video_player.dart';
import 'package:flutter/material.dart';
Widget _buildVideoPlay() {
return Center(
child: _controller.value.initialized ? _VideoStack() : Container(),
);
}
Widget _VideoStack() {
return Stack(
children: [
_VideoCore(),
FlatButton(
onPressed: () => setState(() {
_controller.value.isPlaying ? _controller.initialize() : _controller.pause()
}),
child: Center(
child: _controller.value.isPlaying
? Icon(Icons.pause, color: Colors.blue, size: 30.0)
: Icon(Icons.play_arrow, color: Colors.blue, size: 30.0),
),
],
);
}
Widget _VideoCore() {
return Container(
child: Center(
child: AspectRatio(
aspectRatio: _controller.value.aspectRatio,
child: VideoPlayer(_controller),
),
),
);
}