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
1 change: 1 addition & 0 deletions example/.flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"thumbnails","path":"/Users/Macky/Downloads/Flutter_Thumbnails/","dependencies":[]}],"android":[{"name":"thumbnails","path":"/Users/Macky/Downloads/Flutter_Thumbnails/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"thumbnails","dependencies":[]}],"date_created":"2021-09-25 00:21:14.941774","version":"2.2.3"}
1 change: 1 addition & 0 deletions example/ios/Flutter/Debug.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
1 change: 1 addition & 0 deletions example/ios/Flutter/Release.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
14 changes: 14 additions & 0 deletions example/ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/Users/Macky/Macky/applications/flutter"
export "FLUTTER_APPLICATION_PATH=/Users/Macky/Downloads/Flutter_Thumbnails/example"
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=false"
export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=.packages"
38 changes: 38 additions & 0 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}

def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end

File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
13 changes: 7 additions & 6 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ class _MyAppState extends State<MyApp> {
// Fetch thumbnail and store in a specified output folder
void _toUserFolder() async {
String thumb = await Thumbnails.getThumbnail(
thumbnailFolder: '/storage/emulated/0/Videos/Thumbnails',
videoFile: '/storage/emulated/0/Videos/Testvideo.mp4',
imageType: ThumbFormat.PNG,
quality: 30);
thumbnailFolder: '/storage/emulated/0/Videos/Thumbnails',
videoFile: '/storage/emulated/0/Videos/Testvideo.mp4',
imageType: ThumbFormat.PNG,
quality: 30,
);
print('path to File: $thumb');
}

Expand All @@ -38,9 +39,9 @@ class _MyAppState extends State<MyApp> {
body: new Center(
child: Column(
children: <Widget>[
RaisedButton(
ElevatedButton(
onPressed: _toUserFolder, child: Text('To Specified Folder')),
RaisedButton(
ElevatedButton(
onPressed: _noFolder, child: Text('No Folder Specified')),
],
),
Expand Down
14 changes: 7 additions & 7 deletions lib/thumbnails.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:thumbnails/validators.dart';

Expand All @@ -8,18 +7,19 @@ enum ThumbFormat { PNG, JPEG, WEBP }
class Thumbnails {
static const MethodChannel _channel = const MethodChannel('thumbnails');

static Future<String> getThumbnail(
{@required String videoFile,
String thumbnailFolder,
ThumbFormat imageType,
int quality}) async {
static Future<String?> getThumbnail(
{required String videoFile,
String? thumbnailFolder,
ThumbFormat? imageType,
required int? quality}) async {
var utilMap = <String, dynamic>{
'videoFilePath': videoFile,
'thumbFilePath': thumbnailFolder,
'thumbnailFormat': validateType(imageType),
'thumbnailQuality': validateQuality(quality)
};
String thumbnailPath = await _channel.invokeMethod('getThumbnail', utilMap);
String? thumbnailPath =
await _channel.invokeMethod('getThumbnail', utilMap);
return thumbnailPath;
}
}
9 changes: 3 additions & 6 deletions lib/validators.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,20 @@ import 'package:thumbnails/thumbnails.dart';
const DEFAULT_THUMB_QUALITY = 50;
const DEFAULT_IMAGE_TYPE = ThumbFormat.JPEG;

int validateQuality(int choice) {
if (choice < 10 || choice > 100 || choice == null)
int validateQuality(int? choice) {
if (choice == null || choice < 10 || choice > 100)
return DEFAULT_THUMB_QUALITY;
return choice;
}

int validateType(ThumbFormat type) {
int validateType(ThumbFormat? type) {
if (type == null) return 1;
switch (type) {
case ThumbFormat.JPEG:
return 1;
break;
case ThumbFormat.PNG:
return 2;
break;
case ThumbFormat.WEBP:
return 3;
}
return 1;
}
4 changes: 3 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ author: AsapJay <asapjayfroshcr9@gmail.com>
homepage: https://github.com/asapJ/Flutter_Thumbnails

environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
sdk: '>=2.12.0 <3.0.0'

dependencies:
flutter:
Expand All @@ -19,6 +19,8 @@ flutter:
plugin:
androidPackage: com.asapjay.thumbnails
pluginClass: ThumbnailsPlugin
dev_dependencies:
test: ^1.17.12

# To add assets to your plugin package, add an assets section, like this:
# assets:
Expand Down