From 79ee7164d4ada25566644048b999aa1a119d9f29 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Sun, 20 Aug 2023 12:35:35 +0530 Subject: [PATCH] fix: dart : 3.0 --- example/lib/main.dart | 53 +++++++++++++++++++++++-------------------- example/pubspec.yaml | 4 ++-- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 115d516..a296d30 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -29,13 +29,13 @@ 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 { @@ -43,7 +43,11 @@ class ThumbnailResult { 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 genThumbnail(ThumbnailRequest r) async { @@ -66,10 +70,10 @@ Future 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", @@ -79,7 +83,7 @@ Future genThumbnail(ThumbnailRequest r) async { maxHeight: r.maxHeight, maxWidth: r.maxWidth, timeMs: r.timeMs, - quality: r.quality); + quality: r.quality))!; } int _imageDataSize = bytes.length; @@ -102,7 +106,8 @@ Future 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(); @@ -183,9 +188,9 @@ class _DemoHomeState extends State { int _sizeW = 0; int _timeMs = 0; - GenThumbnailImage _futreImage; + late GenThumbnailImage _futreImage; - String _tempDir; + late String _tempDir; @override void initState() { @@ -275,7 +280,7 @@ class _DemoHomeState extends State { groupValue: _format, value: ImageFormat.JPEG, onChanged: (v) => setState(() { - _format = v; + _format = v!; _editNode.unfocus(); }), ), @@ -289,7 +294,7 @@ class _DemoHomeState extends State { groupValue: _format, value: ImageFormat.PNG, onChanged: (v) => setState(() { - _format = v; + _format = v!; _editNode.unfocus(); }), ), @@ -303,7 +308,7 @@ class _DemoHomeState extends State { groupValue: _format, value: ImageFormat.WEBP, onChanged: (v) => setState(() { - _format = v; + _format = v!; _editNode.unfocus(); }), ), @@ -379,10 +384,10 @@ class _DemoHomeState extends State { children: [ 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), @@ -393,10 +398,10 @@ class _DemoHomeState extends State { ), 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), @@ -412,7 +417,7 @@ class _DemoHomeState extends State { _futreImage = GenThumbnailImage( thumbnailRequest: ThumbnailRequest( video: _video.text, - thumbnailPath: null, + thumbnailPath: '', imageFormat: _format, maxHeight: _sizeH, maxWidth: _sizeW, diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 2805862..02c19c9 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -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: @@ -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: ../