12345678910111213141516171819202122232425262728293031323334 |
- import 'dart:typed_data';
- import 'package:flutter/material.dart';
- import 'package:video_thumbnail/video_thumbnail.dart';
- class YSVideoImage extends StatefulWidget {
- final String path;
- const YSVideoImage({Key? key, required this.path}) : super(key: key);
- @override
- YSVideoImageState createState() => YSVideoImageState();
- }
- class YSVideoImageState extends State<YSVideoImage> {
- Uint8List? _uint8list;
- @override
- void initState() {
- _getListData();
- super.initState();
- }
- _getListData() async{
- _uint8list = await VideoThumbnail.thumbnailData(
- video: widget.path,
- imageFormat: ImageFormat.JPEG,
- maxWidth: 128, // specify the width of the thumbnail, let the height auto-scaled to keep the source aspect ratio
- quality: 25,
- );
- setState(() {});
- }
- @override
- Widget build(BuildContext context) {
- return _uint8list!=null?Image.memory(_uint8list!,fit: BoxFit.cover,):const SizedBox();
- }
- }
|