Video URL Thumbnail In Flutter

Video URL Thumbnail In Flutter :

Screenshot :

Video URL Thumbnail In Flutter

AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />

main.dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'dart:io';
import 'package:video_thumbnail/video_thumbnail.dart';
import 'package:path_provider/path_provider.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  ImageFormat _format = ImageFormat.JPEG;
  int _quality = 10;
  int _size = 0;

  String _tempDir;
  String filePath;

  @override
  void initState() {
    super.initState();
    getTemporaryDirectory().then((d) => _tempDir = d.path);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            title: const Text('Flutter Tutorial'),
          ),
          body: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              filePath != null
                  ? Image(image: AssetImage(filePath))
                  : Text('No Floatting Button Click')
            ],
          ),
          floatingActionButton: Row(
            mainAxisAlignment: MainAxisAlignment.end,
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              FloatingActionButton(
                tooltip: "Generate a file of thumbnail",
                onPressed: () async {
                  final thumbnail = await VideoThumbnail.thumbnailFile(
                      video:
                          'https://www.sample-videos.com/video123/mp4/720/big_buck_bunny_720p_20mb.mp4',
                      thumbnailPath: _tempDir,
                      imageFormat: _format,
                      maxHeightOrWidth: _size,
                      quality: _quality);

                  setState(() {
                    final file = File(thumbnail);
                    filePath = file.path;
                  });
                },
                child: Text('Click'),
              ),
            ],
          )),
    );
  }
}

pubspec.yaml

name: fluttertutorial
description: A new Flutter application.

version: 1.0.0+1

environment:
sdk:
“>=2.1.0 <3.0.0”

dependencies:
flutter:
sdk:
flutter

font_awesome_flutter:
path_provider:
video_thumbnail:

dev_dependencies:
flutter_test:

sdk: flutter

flutter:
uses-material-design: true