import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
import 'package:flick_video_player/flick_video_player.dart';

class ProblemVideo extends StatefulWidget {
  var videoUrl;
  ProblemVideo({this.videoUrl});

  @override
  State<ProblemVideo> createState() => _ProblemVideoState();
}

class _ProblemVideoState extends State<ProblemVideo> {

  late VideoPlayerController _controller;
  late Future<void> _initializeVideoPlayerFuture;
  late FlickManager flickManager;

  @override
  void initState() {
    super.initState();
    _controller = VideoPlayerController.networkUrl(
      Uri.parse(widget.videoUrl,),
    );
    flickManager = FlickManager(
        videoPlayerController:
        VideoPlayerController.networkUrl(Uri.parse(widget.videoUrl,),)
    );
    _initializeVideoPlayerFuture = _controller.initialize();
    _controller.setLooping(false);
  }
  @override
  void dispose() {
    // Ensure disposing of the VideoPlayerController to free up resources.
    _controller.dispose();
    flickManager.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      height: MediaQuery.of(context).size.height * .30,
      width: double.infinity,
      child:FlickVideoPlayer(
        flickManager: flickManager,
        flickVideoWithControls: FlickVideoWithControls(
          videoFit: BoxFit.fill,
          controls: FlickPortraitControls(
            progressBarSettings:
            FlickProgressBarSettings(playedColor: Colors.green),
          ),
        ),

      ),

    );
  }
}
