Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 29 additions & 24 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,25 @@ class ThumbnailRequest {
final int quality;

const ThumbnailRequest(
{this.video,
this.thumbnailPath,
this.imageFormat,
this.maxHeight,
this.maxWidth,
this.timeMs,
this.quality});
{required this.video,
required this.thumbnailPath,
required this.imageFormat,
required this.maxHeight,
required this.maxWidth,
required this.timeMs,
required this.quality});
}

class ThumbnailResult {
final Image image;
final int dataSize;
final int height;
final int width;
const ThumbnailResult({this.image, this.dataSize, this.height, this.width});
const ThumbnailResult(
{required this.image,
required this.dataSize,
required this.height,
required this.width});
}

Future<ThumbnailResult> genThumbnail(ThumbnailRequest r) async {
Expand All @@ -66,10 +70,10 @@ Future<ThumbnailResult> genThumbnail(ThumbnailRequest r) async {

print("thumbnail file is located: $thumbnailPath");

final file = File(thumbnailPath);
final file = File(thumbnailPath!);
bytes = file.readAsBytesSync();
} else {
bytes = await VideoThumbnail.thumbnailData(
bytes = (await VideoThumbnail.thumbnailData(
video: r.video,
headers: {
"USERHEADER1": "user defined header1",
Expand All @@ -79,7 +83,7 @@ Future<ThumbnailResult> genThumbnail(ThumbnailRequest r) async {
maxHeight: r.maxHeight,
maxWidth: r.maxWidth,
timeMs: r.timeMs,
quality: r.quality);
quality: r.quality))!;
}

int _imageDataSize = bytes.length;
Expand All @@ -102,7 +106,8 @@ Future<ThumbnailResult> genThumbnail(ThumbnailRequest r) async {
class GenThumbnailImage extends StatefulWidget {
final ThumbnailRequest thumbnailRequest;

const GenThumbnailImage({Key key, this.thumbnailRequest}) : super(key: key);
const GenThumbnailImage({Key? key, required this.thumbnailRequest})
: super(key: key);

@override
_GenThumbnailImageState createState() => _GenThumbnailImageState();
Expand Down Expand Up @@ -183,9 +188,9 @@ class _DemoHomeState extends State<DemoHome> {
int _sizeW = 0;
int _timeMs = 0;

GenThumbnailImage _futreImage;
late GenThumbnailImage _futreImage;

String _tempDir;
late String _tempDir;

@override
void initState() {
Expand Down Expand Up @@ -275,7 +280,7 @@ class _DemoHomeState extends State<DemoHome> {
groupValue: _format,
value: ImageFormat.JPEG,
onChanged: (v) => setState(() {
_format = v;
_format = v!;
_editNode.unfocus();
}),
),
Expand All @@ -289,7 +294,7 @@ class _DemoHomeState extends State<DemoHome> {
groupValue: _format,
value: ImageFormat.PNG,
onChanged: (v) => setState(() {
_format = v;
_format = v!;
_editNode.unfocus();
}),
),
Expand All @@ -303,7 +308,7 @@ class _DemoHomeState extends State<DemoHome> {
groupValue: _format,
value: ImageFormat.WEBP,
onChanged: (v) => setState(() {
_format = v;
_format = v!;
_editNode.unfocus();
}),
),
Expand Down Expand Up @@ -379,10 +384,10 @@ class _DemoHomeState extends State<DemoHome> {
children: <Widget>[
FloatingActionButton(
onPressed: () async {
File video =
await ImagePicker.pickVideo(source: ImageSource.camera);
XFile? video =
await ImagePicker().pickImage(source: ImageSource.camera);
setState(() {
_video.text = video.path;
_video.text = video!.path;
});
},
child: Icon(Icons.videocam),
Expand All @@ -393,10 +398,10 @@ class _DemoHomeState extends State<DemoHome> {
),
FloatingActionButton(
onPressed: () async {
File video =
await ImagePicker.pickVideo(source: ImageSource.gallery);
XFile? video =
await ImagePicker().pickVideo(source: ImageSource.gallery);
setState(() {
_video.text = video?.path;
_video.text = video!.path;
});
},
child: Icon(Icons.local_movies),
Expand All @@ -412,7 +417,7 @@ class _DemoHomeState extends State<DemoHome> {
_futreImage = GenThumbnailImage(
thumbnailRequest: ThumbnailRequest(
video: _video.text,
thumbnailPath: null,
thumbnailPath: '',
imageFormat: _format,
maxHeight: _sizeH,
maxWidth: _sizeW,
Expand Down
4 changes: 2 additions & 2 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 0.1.7
publish_to: 'none'

environment:
sdk: ">=2.5.2 <3.0.0"
sdk: ">=2.12.2 <3.0.0"

dependencies:
flutter:
Expand All @@ -15,7 +15,7 @@ dev_dependencies:
sdk: flutter

image_picker: '>=0.6.2 <2.0.0'
path_provider: ^1.6.0
path_provider: ^2.1.0
video_thumbnail:
path: ../

Expand Down