content: import 'dart:io';
  
  import 'package:flutter/material.dart';
  import 'package:video_player/video_player.dart';
  
  class MyVideoPlayer extends StatefulWidget {
  
    final String videoPath;
  
    const MyVideoPlayer({Key key, this.videoPath}) : super(key: key);
  
  
  
    @override
    _VideoPlayerState createState() => _VideoPlayerState();
  }
  
  class _VideoPlayerState extends State<MyVideoPlayer> {
  
  
    VideoPlayerController _controller;
  
    @override
    void initState() {
      super.initState();
      _controller = VideoPlayerController.file(File(widget.videoPath))
        ..initialize().then((_) {
          // Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
          setState(() {});
        });
    }
  
    @override
    void dispose() {
      super.dispose();
      _controller.dispose();
    }
  
    @override
    Widget build(BuildContext context) {
      return Stack(
        children: <Widget>[
          Center(
            child: _controller.value.initialized
                ? AspectRatio(
              aspectRatio: _controller.value.aspectRatio,
              child: VideoPlayer(_controller),
            )
                : Container(),
          ),
          Container(
            alignment: Alignment.center,
            child: GestureDetector(
              onTap: () {
                setState(() {
                  _controller.value.isPlaying
                      ? _controller.pause()
                      : _controller.play();
                });
              },
              child: Container(
                width: 50,height: 50,
  
                decoration: BoxDecoration(
                  color: Colors.grey.withOpacity(0.5),
                  shape: BoxShape.circle
                ),
                alignment: Alignment.center,
                child: Icon(
                  _controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
                  size: 40,
                  color: Colors.white,
                ),
              ),
            ),
          ),
        ],
      );
    }
  }
  