From 6f35340abc360e763789cc0969a8b63cab7626ce Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Fri, 11 May 2018 09:47:47 -0400 Subject: [PATCH 01/41] Adding Video Record and Selection for Android and iOS - Tested on Google Pixel - Tested on iPhone X --- packages/image_picker/.vscode/launch.json | 14 ++ packages/image_picker/.vscode/settings.json | 3 + .../android/src/main/AndroidManifest.xml | 5 +- .../imagepicker/ImagePickerDelegate.java | 63 ++++++++- .../imagepicker/ImagePickerPlugin.java | 15 ++- .../image_picker/example/.vscode/launch.json | 19 +++ .../ios/Runner.xcodeproj/project.pbxproj | 31 +++-- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++ .../example/ios/Runner/Info.plist | 14 +- packages/image_picker/example/lib/main.dart | 125 +++++++++++++++--- packages/image_picker/example/pubspec.yaml | 1 + .../ios/Classes/ImagePickerPlugin.m | 107 ++++++++++----- packages/image_picker/lib/image_picker.dart | 25 ++++ 13 files changed, 363 insertions(+), 67 deletions(-) create mode 100644 packages/image_picker/.vscode/launch.json create mode 100644 packages/image_picker/.vscode/settings.json create mode 100644 packages/image_picker/example/.vscode/launch.json mode change 100755 => 100644 packages/image_picker/example/ios/Runner.xcodeproj/project.pbxproj create mode 100644 packages/image_picker/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/packages/image_picker/.vscode/launch.json b/packages/image_picker/.vscode/launch.json new file mode 100644 index 000000000000..3b9020740c36 --- /dev/null +++ b/packages/image_picker/.vscode/launch.json @@ -0,0 +1,14 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Flutter", + "type": "dart", + "request": "launch", + "program": "${workspaceFolder}/example//lib/main.dart" + } + ] +} \ No newline at end of file diff --git a/packages/image_picker/.vscode/settings.json b/packages/image_picker/.vscode/settings.json new file mode 100644 index 000000000000..b52fc7b87bda --- /dev/null +++ b/packages/image_picker/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "dart.promptToUpgradeWorkspace": true +} \ No newline at end of file diff --git a/packages/image_picker/android/src/main/AndroidManifest.xml b/packages/image_picker/android/src/main/AndroidManifest.xml index 7672d73e5e09..22e6e624f09f 100755 --- a/packages/image_picker/android/src/main/AndroidManifest.xml +++ b/packages/image_picker/android/src/main/AndroidManifest.xml @@ -1,7 +1,8 @@ - - + + + /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -427,7 +438,7 @@ buildSettings = { ARCHS = arm64; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = 3GRKCVVJ22; + DEVELOPMENT_TEAM = 9FK3425VTA; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -450,7 +461,7 @@ buildSettings = { ARCHS = arm64; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = 3GRKCVVJ22; + DEVELOPMENT_TEAM = 9FK3425VTA; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", diff --git a/packages/image_picker/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/packages/image_picker/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000000..18d981003d68 --- /dev/null +++ b/packages/image_picker/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/packages/image_picker/example/ios/Runner/Info.plist b/packages/image_picker/example/ios/Runner/Info.plist index 780303c86d1c..f9c1909383ca 100755 --- a/packages/image_picker/example/ios/Runner/Info.plist +++ b/packages/image_picker/example/ios/Runner/Info.plist @@ -22,6 +22,16 @@ 1 LSRequiresIPhoneOS + NSCameraUsageDescription + Used to demonstrate image picker plugin + NSMicrophoneUsageDescription + Used to capture audio for image picker plugin + NSPhotoLibraryUsageDescription + Used to demonstrate image picker plugin + UIBackgroundModes + + remote-notification + UILaunchStoryboardName LaunchScreen UIMainStoryboardFile @@ -43,10 +53,6 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight - NSCameraUsageDescription - Used to demonstrate image picker plugin - NSPhotoLibraryUsageDescription - Used to demonstrate image picker plugin UIViewControllerBasedStatusBarAppearance diff --git a/packages/image_picker/example/lib/main.dart b/packages/image_picker/example/lib/main.dart index 25c54bfb37cc..ff7310516483 100755 --- a/packages/image_picker/example/lib/main.dart +++ b/packages/image_picker/example/lib/main.dart @@ -7,6 +7,8 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:image_picker/image_picker.dart'; +import 'package:video_player/video_player.dart'; + void main() { runApp(new MyApp()); @@ -32,51 +34,140 @@ class MyHomePage extends StatefulWidget { } class _MyHomePageState extends State { - Future _imageFile; + Future _mediaFile; + bool isVideo = false; + VideoPlayerController _controller; + VoidCallback listener; void _onImageButtonPressed(ImageSource source) { setState(() { - _imageFile = ImagePicker.pickImage(source: source); + if (_controller != null) { + _controller.setVolume(0.0); + _controller.removeListener(listener); + } + if (isVideo) { + _mediaFile = ImagePicker.pickVideo(source: source).then((onValue) { + _controller = VideoPlayerController.file(onValue) + ..addListener(listener) + ..setVolume(1.0) + ..initialize() + ..setLooping(true) + ..play(); + setState(() {}); + }); + } else { + _mediaFile = ImagePicker.pickImage(source: source); + } }); } + @override + void deactivate() { + _controller.setVolume(0.0); + _controller.removeListener(listener); + super.deactivate(); + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + void initState() { + super.initState(); + listener = () { + setState(() {}); + }; + } + @override Widget build(BuildContext context) { + Widget _previewImage = new FutureBuilder( + future: _mediaFile, + builder: (BuildContext context, AsyncSnapshot snapshot) { + if (snapshot.connectionState == ConnectionState.done && + snapshot.data != null) { + return new Image.file(snapshot.data); + } else if (snapshot.error != null) { + return const Text('Error picking image.'); + } else { + return const Text('You have not yet picked an image.'); + } + }, + ); + return new Scaffold( appBar: new AppBar( title: const Text('Image Picker Example'), ), body: new Center( - child: new FutureBuilder( - future: _imageFile, - builder: (BuildContext context, AsyncSnapshot snapshot) { - if (snapshot.connectionState == ConnectionState.done && - snapshot.data != null) { - return new Image.file(snapshot.data); - } else if (snapshot.error != null) { - return const Text('error picking image.'); - } else { - return const Text('You have not yet picked an image.'); - } - }, - ), + child: isVideo + ? _controller.value.initialized + ? new Padding( + padding: const EdgeInsets.all(10.0), + child: new AspectRatio( + aspectRatio: _controller.value.size.width / + _controller.value.size.height, + child: VideoPlayer( + _controller, + ), + ), + ) + : Container() + : _previewImage, ), floatingActionButton: new Column( mainAxisAlignment: MainAxisAlignment.end, children: [ new FloatingActionButton( - onPressed: () => _onImageButtonPressed(ImageSource.gallery), + onPressed: () { + isVideo = false; + _onImageButtonPressed(ImageSource.gallery); + }, + heroTag: 'image0', tooltip: 'Pick Image from gallery', child: const Icon(Icons.photo_library), ), new Padding( padding: const EdgeInsets.only(top: 16.0), child: new FloatingActionButton( - onPressed: () => _onImageButtonPressed(ImageSource.camera), + onPressed: () { + isVideo = false; + _onImageButtonPressed(ImageSource.camera); + }, + heroTag: 'image1', tooltip: 'Take a Photo', child: const Icon(Icons.camera_alt), ), ), + new Padding( + padding: const EdgeInsets.only(top: 16.0), + child: new FloatingActionButton( + backgroundColor: Colors.red, + onPressed: () { + isVideo = true; + _onImageButtonPressed(ImageSource.gallery); + }, + heroTag: 'video0', + tooltip: 'Pick Video from gallery', + child: const Icon(Icons.video_library), + ), + ), + new Padding( + padding: const EdgeInsets.only(top: 16.0), + child: new FloatingActionButton( + backgroundColor: Colors.red, + onPressed: () { + isVideo = true; + _onImageButtonPressed(ImageSource.camera); + }, + heroTag: 'video1', + tooltip: 'Take a Video', + child: const Icon(Icons.videocam), + ), + ), ], ), ); diff --git a/packages/image_picker/example/pubspec.yaml b/packages/image_picker/example/pubspec.yaml index 919751f68148..10c3b713dc2e 100755 --- a/packages/image_picker/example/pubspec.yaml +++ b/packages/image_picker/example/pubspec.yaml @@ -2,6 +2,7 @@ name: image_picker_example description: Demonstrates how to use the image_picker plugin. dependencies: + video_player: "0.5.1" flutter: sdk: flutter image_picker: diff --git a/packages/image_picker/ios/Classes/ImagePickerPlugin.m b/packages/image_picker/ios/Classes/ImagePickerPlugin.m index ef6106b8fcc7..1793bdf790a0 100644 --- a/packages/image_picker/ios/Classes/ImagePickerPlugin.m +++ b/packages/image_picker/ios/Classes/ImagePickerPlugin.m @@ -2,10 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -@import UIKit; - #import "ImagePickerPlugin.h" +#import +#import +#import + @interface FLTImagePickerPlugin () @end @@ -50,6 +52,8 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result if ([@"pickImage" isEqualToString:call.method]) { _imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext; _imagePickerController.delegate = self; + _imagePickerController.mediaTypes = @[(NSString*)kUTTypeImage]; + _result = result; _arguments = call.arguments; @@ -69,6 +73,30 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result details:nil]); break; } + } else if ([@"pickVideo" isEqualToString:call.method]) { + _imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext; + _imagePickerController.delegate = self; + _imagePickerController.mediaTypes = @[(NSString*)kUTTypeMovie, (NSString*)kUTTypeAVIMovie, (NSString*)kUTTypeVideo, (NSString*)kUTTypeMPEG4]; + _imagePickerController.videoQuality = UIImagePickerControllerQualityTypeHigh; + + _result = result; + _arguments = call.arguments; + + int imageSource = [[_arguments objectForKey:@"source"] intValue]; + + switch (imageSource) { + case SOURCE_CAMERA: + [self showCamera]; + break; + case SOURCE_GALLERY: + [self showPhotoLibrary]; + break; + default: + result([FlutterError errorWithCode:@"invalid_source" + message:@"Invalid video source." + details:nil]); + break; + } } else { result(FlutterMethodNotImplemented); } @@ -96,34 +124,53 @@ - (void)showPhotoLibrary { - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { - [_imagePickerController dismissViewControllerAnimated:YES completion:nil]; - UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage]; - if (image == nil) { - image = [info objectForKey:UIImagePickerControllerOriginalImage]; - } - image = [self normalizedImage:image]; - - NSNumber *maxWidth = [_arguments objectForKey:@"maxWidth"]; - NSNumber *maxHeight = [_arguments objectForKey:@"maxHeight"]; - - if (maxWidth != (id)[NSNull null] || maxHeight != (id)[NSNull null]) { - image = [self scaledImage:image maxWidth:maxWidth maxHeight:maxHeight]; - } - - NSData *data = UIImageJPEGRepresentation(image, 1.0); - NSString *tmpDirectory = NSTemporaryDirectory(); - NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; - // TODO(jackson): Using the cache directory might be better than temporary - // directory. - NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.jpg", guid]; - NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; - if ([[NSFileManager defaultManager] createFileAtPath:tmpPath contents:data attributes:nil]) { - _result(tmpPath); - } else { - _result([FlutterError errorWithCode:@"create_error" - message:@"Temporary file could not be created" - details:nil]); - } + NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL]; + UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage]; + [_imagePickerController dismissViewControllerAnimated:YES completion:nil]; + if (image == nil) { + image = [info objectForKey:UIImagePickerControllerOriginalImage]; + } + image = [self normalizedImage:image]; + + NSNumber *maxWidth = [_arguments objectForKey:@"maxWidth"]; + NSNumber *maxHeight = [_arguments objectForKey:@"maxHeight"]; + + if (maxWidth != (id)[NSNull null] || maxHeight != (id)[NSNull null]) { + image = [self scaledImage:image maxWidth:maxWidth maxHeight:maxHeight]; + } + + if (videoURL != nil) { + NSLog(@"MediaURL = %@", videoURL); + NSData *data = [NSData dataWithContentsOfURL:videoURL]; + NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; + NSString *tmpFile = [NSString stringWithFormat:@"video_picker_%@.MOV", guid]; + NSString *tmpDirectory = NSTemporaryDirectory(); + NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; + + if ([[NSFileManager defaultManager] createFileAtPath:tmpPath contents:data attributes:nil]) { + _result(tmpPath); + } else { + _result([FlutterError errorWithCode:@"create_error" + message:@"Temporary file could not be created" + details:nil]); + } + } else { + + NSData *data = UIImageJPEGRepresentation(image, 1.0); + NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; + NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.jpg", guid]; + NSString *tmpDirectory = NSTemporaryDirectory(); + NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; + + if ([[NSFileManager defaultManager] createFileAtPath:tmpPath contents:data attributes:nil]) { + _result(tmpPath); + } else { + _result([FlutterError errorWithCode:@"create_error" + message:@"Temporary file could not be created" + details:nil]); + } + } + _result = nil; _arguments = nil; } diff --git a/packages/image_picker/lib/image_picker.dart b/packages/image_picker/lib/image_picker.dart index 287431869b68..1214eb120dcf 100755 --- a/packages/image_picker/lib/image_picker.dart +++ b/packages/image_picker/lib/image_picker.dart @@ -55,4 +55,29 @@ class ImagePicker { return path != null ? new File(path) : null; } + static Future pickVideo({ + @required ImageSource source, + double maxWidth, + double maxHeight, + }) async { + assert(source != null); + + if (maxWidth != null && maxWidth < 0) { + throw new ArgumentError.value(maxWidth, 'maxWidth can\'t be negative'); + } + + if (maxHeight != null && maxHeight < 0) { + throw new ArgumentError.value(maxHeight, 'maxHeight can\'t be negative'); + } + + final String path = await _channel.invokeMethod( + 'pickVideo', + { + 'source': source.index, + 'maxWidth': maxWidth, + 'maxHeight': maxHeight, + }, + ); + return path != null ? new File(path) : null; + } } From 3b660f5544f4bed2a5303a2c68af114fbbbefbb5 Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Fri, 11 May 2018 10:13:27 -0400 Subject: [PATCH 02/41] Fixing Null Error on Video Selection --- packages/image_picker/example/lib/main.dart | 100 ++++++++++-------- .../ios/Classes/ImagePickerPlugin.m | 4 +- 2 files changed, 54 insertions(+), 50 deletions(-) diff --git a/packages/image_picker/example/lib/main.dart b/packages/image_picker/example/lib/main.dart index ff7310516483..4d5d9bfe084f 100755 --- a/packages/image_picker/example/lib/main.dart +++ b/packages/image_picker/example/lib/main.dart @@ -9,17 +9,16 @@ import 'package:flutter/material.dart'; import 'package:image_picker/image_picker.dart'; import 'package:video_player/video_player.dart'; - void main() { - runApp(new MyApp()); + runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - return new MaterialApp( + return MaterialApp( title: 'Image Picker Demo', - home: new MyHomePage(title: 'Image Picker Example'), + home: MyHomePage(title: 'Image Picker Example'), ); } } @@ -30,7 +29,7 @@ class MyHomePage extends StatefulWidget { final String title; @override - _MyHomePageState createState() => new _MyHomePageState(); + _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State { @@ -46,8 +45,8 @@ class _MyHomePageState extends State { _controller.removeListener(listener); } if (isVideo) { - _mediaFile = ImagePicker.pickVideo(source: source).then((onValue) { - _controller = VideoPlayerController.file(onValue) + _mediaFile = ImagePicker.pickVideo(source: source).then((File _file) { + _controller = VideoPlayerController.file(_file) ..addListener(listener) ..setVolume(1.0) ..initialize() @@ -82,46 +81,53 @@ class _MyHomePageState extends State { }; } + Widget _previewVideo(VideoPlayerController controller) { + if (controller == null) { + return const Text('You have not yet picked a video'); + } else if (controller.value.initialized) { + return Padding( + padding: const EdgeInsets.all(10.0), + child: AspectRatio( + aspectRatio: + controller.value.size.width / controller.value.size.height, + child: VideoPlayer( + controller, + ), + ), + ); + } else { + return const Text('Error Loading Video'); + } + } + + Widget _previewImage() { + return FutureBuilder( + future: _mediaFile, + builder: (BuildContext context, AsyncSnapshot snapshot) { + if (snapshot.connectionState == ConnectionState.done && + snapshot.data != null) { + return Image.file(snapshot.data); + } else if (snapshot.error != null) { + return const Text('Error picking image.'); + } else { + return const Text('You have not yet picked an image.'); + } + }); + } + @override Widget build(BuildContext context) { - Widget _previewImage = new FutureBuilder( - future: _mediaFile, - builder: (BuildContext context, AsyncSnapshot snapshot) { - if (snapshot.connectionState == ConnectionState.done && - snapshot.data != null) { - return new Image.file(snapshot.data); - } else if (snapshot.error != null) { - return const Text('Error picking image.'); - } else { - return const Text('You have not yet picked an image.'); - } - }, - ); - - return new Scaffold( - appBar: new AppBar( - title: const Text('Image Picker Example'), + return Scaffold( + appBar: AppBar( + title: Text(widget.title), ), - body: new Center( - child: isVideo - ? _controller.value.initialized - ? new Padding( - padding: const EdgeInsets.all(10.0), - child: new AspectRatio( - aspectRatio: _controller.value.size.width / - _controller.value.size.height, - child: VideoPlayer( - _controller, - ), - ), - ) - : Container() - : _previewImage, + body: Center( + child: isVideo ? _previewVideo(_controller) : _previewImage(), ), - floatingActionButton: new Column( + floatingActionButton: Column( mainAxisAlignment: MainAxisAlignment.end, children: [ - new FloatingActionButton( + FloatingActionButton( onPressed: () { isVideo = false; _onImageButtonPressed(ImageSource.gallery); @@ -130,9 +136,9 @@ class _MyHomePageState extends State { tooltip: 'Pick Image from gallery', child: const Icon(Icons.photo_library), ), - new Padding( + Padding( padding: const EdgeInsets.only(top: 16.0), - child: new FloatingActionButton( + child: FloatingActionButton( onPressed: () { isVideo = false; _onImageButtonPressed(ImageSource.camera); @@ -142,9 +148,9 @@ class _MyHomePageState extends State { child: const Icon(Icons.camera_alt), ), ), - new Padding( + Padding( padding: const EdgeInsets.only(top: 16.0), - child: new FloatingActionButton( + child: FloatingActionButton( backgroundColor: Colors.red, onPressed: () { isVideo = true; @@ -155,9 +161,9 @@ class _MyHomePageState extends State { child: const Icon(Icons.video_library), ), ), - new Padding( + Padding( padding: const EdgeInsets.only(top: 16.0), - child: new FloatingActionButton( + child: FloatingActionButton( backgroundColor: Colors.red, onPressed: () { isVideo = true; diff --git a/packages/image_picker/ios/Classes/ImagePickerPlugin.m b/packages/image_picker/ios/Classes/ImagePickerPlugin.m index 1793bdf790a0..3bce5d7ead17 100644 --- a/packages/image_picker/ios/Classes/ImagePickerPlugin.m +++ b/packages/image_picker/ios/Classes/ImagePickerPlugin.m @@ -140,10 +140,9 @@ - (void)imagePickerController:(UIImagePickerController *)picker } if (videoURL != nil) { - NSLog(@"MediaURL = %@", videoURL); NSData *data = [NSData dataWithContentsOfURL:videoURL]; NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; - NSString *tmpFile = [NSString stringWithFormat:@"video_picker_%@.MOV", guid]; + NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.MOV", guid]; NSString *tmpDirectory = NSTemporaryDirectory(); NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; @@ -155,7 +154,6 @@ - (void)imagePickerController:(UIImagePickerController *)picker details:nil]); } } else { - NSData *data = UIImageJPEGRepresentation(image, 1.0); NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.jpg", guid]; From a1143e44f22e8d03177ba0456d877ed7eb0a0af2 Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Fri, 11 May 2018 10:18:27 -0400 Subject: [PATCH 03/41] Updating Number --- packages/image_picker/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/image_picker/pubspec.yaml b/packages/image_picker/pubspec.yaml index 6cf51d57a373..ece829d4e57c 100755 --- a/packages/image_picker/pubspec.yaml +++ b/packages/image_picker/pubspec.yaml @@ -3,7 +3,7 @@ description: Flutter plugin for selecting images from the Android and iOS image library, and taking new pictures with the camera. author: Flutter Team homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker -version: 0.4.1 +version: 0.4.2 flutter: plugin: From 54c3f68e3b7282c48b1cf25132bac57e61667885 Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Fri, 11 May 2018 10:35:56 -0400 Subject: [PATCH 04/41] Updating Formating pub global activate flutter_plugin_tools && pub global run flutter_plugin_tools format --- .../io/flutter/plugins/imagepicker/ImagePickerDelegate.java | 2 +- .../java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java | 2 +- packages/image_picker/lib/image_picker.dart | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java b/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java index ee0a6e7b649e..1450cbcaf449 100644 --- a/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java +++ b/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java @@ -295,7 +295,7 @@ private void launchTakeImageWithCameraIntent() { activity.startActivityForResult(intent, REQUEST_CODE_TAKE_WITH_CAMERA); } - + private File createTemporaryWritableImageFile() { String filename = UUID.randomUUID().toString(); File image; diff --git a/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java b/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java index 1a0adb5338e3..b3cc895575c9 100644 --- a/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java +++ b/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java @@ -61,7 +61,7 @@ public void onMethodCall(MethodCall call, MethodChannel.Result result) { default: throw new IllegalArgumentException("Invalid image source: " + imageSource); } - } else if (call.method.equals("pickVideo")) { + } else if (call.method.equals("pickVideo")) { switch (imageSource) { case SOURCE_GALLERY: delegate.chooseVideoFromGallery(call, result); diff --git a/packages/image_picker/lib/image_picker.dart b/packages/image_picker/lib/image_picker.dart index 1214eb120dcf..ad7f8018816e 100755 --- a/packages/image_picker/lib/image_picker.dart +++ b/packages/image_picker/lib/image_picker.dart @@ -55,6 +55,7 @@ class ImagePicker { return path != null ? new File(path) : null; } + static Future pickVideo({ @required ImageSource source, double maxWidth, @@ -78,6 +79,6 @@ class ImagePicker { 'maxHeight': maxHeight, }, ); - return path != null ? new File(path) : null; + return path != null ? new File(path) : null; } } From 4f3b1c39abc18cc1336d0a8eb6691114e73e002b Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Fri, 11 May 2018 10:36:47 -0400 Subject: [PATCH 05/41] Rolling Back Number --- packages/image_picker/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/image_picker/pubspec.yaml b/packages/image_picker/pubspec.yaml index ece829d4e57c..6cf51d57a373 100755 --- a/packages/image_picker/pubspec.yaml +++ b/packages/image_picker/pubspec.yaml @@ -3,7 +3,7 @@ description: Flutter plugin for selecting images from the Android and iOS image library, and taking new pictures with the camera. author: Flutter Team homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker -version: 0.4.2 +version: 0.4.1 flutter: plugin: From 74f775d390bfbf84b333116bb751fe3610f55dd0 Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Fri, 11 May 2018 10:44:07 -0400 Subject: [PATCH 06/41] Updating Formating --- .../ios/Classes/ImagePickerPlugin.m | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/packages/image_picker/ios/Classes/ImagePickerPlugin.m b/packages/image_picker/ios/Classes/ImagePickerPlugin.m index 3bce5d7ead17..08723a75c608 100644 --- a/packages/image_picker/ios/Classes/ImagePickerPlugin.m +++ b/packages/image_picker/ios/Classes/ImagePickerPlugin.m @@ -124,50 +124,50 @@ - (void)showPhotoLibrary { - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { - NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL]; - UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage]; - [_imagePickerController dismissViewControllerAnimated:YES completion:nil]; - if (image == nil) { - image = [info objectForKey:UIImagePickerControllerOriginalImage]; - } - image = [self normalizedImage:image]; - - NSNumber *maxWidth = [_arguments objectForKey:@"maxWidth"]; - NSNumber *maxHeight = [_arguments objectForKey:@"maxHeight"]; +NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL]; +UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage]; +[_imagePickerController dismissViewControllerAnimated:YES completion:nil]; +if (image == nil) { + image = [info objectForKey:UIImagePickerControllerOriginalImage]; +} +image = [self normalizedImage:image]; + +NSNumber *maxWidth = [_arguments objectForKey:@"maxWidth"]; +NSNumber *maxHeight = [_arguments objectForKey:@"maxHeight"]; - if (maxWidth != (id)[NSNull null] || maxHeight != (id)[NSNull null]) { - image = [self scaledImage:image maxWidth:maxWidth maxHeight:maxHeight]; +if (maxWidth != (id)[NSNull null] || maxHeight != (id)[NSNull null]) { + image = [self scaledImage:image maxWidth:maxWidth maxHeight:maxHeight]; +} + +if (videoURL != nil) { + NSData *data = [NSData dataWithContentsOfURL:videoURL]; + NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; + NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.MOV", guid]; + NSString *tmpDirectory = NSTemporaryDirectory(); + NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; + + if ([[NSFileManager defaultManager] createFileAtPath:tmpPath contents:data attributes:nil]) { + _result(tmpPath); + } else { + _result([FlutterError errorWithCode:@"create_error" + message:@"Temporary file could not be created" + details:nil]); } - - if (videoURL != nil) { - NSData *data = [NSData dataWithContentsOfURL:videoURL]; - NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; - NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.MOV", guid]; - NSString *tmpDirectory = NSTemporaryDirectory(); - NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; - - if ([[NSFileManager defaultManager] createFileAtPath:tmpPath contents:data attributes:nil]) { - _result(tmpPath); - } else { - _result([FlutterError errorWithCode:@"create_error" - message:@"Temporary file could not be created" - details:nil]); - } +} else { + NSData *data = UIImageJPEGRepresentation(image, 1.0); + NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; + NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.jpg", guid]; + NSString *tmpDirectory = NSTemporaryDirectory(); + NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; + + if ([[NSFileManager defaultManager] createFileAtPath:tmpPath contents:data attributes:nil]) { + _result(tmpPath); } else { - NSData *data = UIImageJPEGRepresentation(image, 1.0); - NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; - NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.jpg", guid]; - NSString *tmpDirectory = NSTemporaryDirectory(); - NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; - - if ([[NSFileManager defaultManager] createFileAtPath:tmpPath contents:data attributes:nil]) { - _result(tmpPath); - } else { - _result([FlutterError errorWithCode:@"create_error" - message:@"Temporary file could not be created" - details:nil]); - } + _result([FlutterError errorWithCode:@"create_error" + message:@"Temporary file could not be created" + details:nil]); } +} _result = nil; _arguments = nil; From 1fb8bf71fa556142b0b2a85aeedcd84e38df74a0 Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Fri, 11 May 2018 10:45:15 -0400 Subject: [PATCH 07/41] Revert "Updating Formating" This reverts commit 74f775d390bfbf84b333116bb751fe3610f55dd0. --- .../ios/Classes/ImagePickerPlugin.m | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/packages/image_picker/ios/Classes/ImagePickerPlugin.m b/packages/image_picker/ios/Classes/ImagePickerPlugin.m index 08723a75c608..3bce5d7ead17 100644 --- a/packages/image_picker/ios/Classes/ImagePickerPlugin.m +++ b/packages/image_picker/ios/Classes/ImagePickerPlugin.m @@ -124,50 +124,50 @@ - (void)showPhotoLibrary { - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { -NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL]; -UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage]; -[_imagePickerController dismissViewControllerAnimated:YES completion:nil]; -if (image == nil) { - image = [info objectForKey:UIImagePickerControllerOriginalImage]; -} -image = [self normalizedImage:image]; - -NSNumber *maxWidth = [_arguments objectForKey:@"maxWidth"]; -NSNumber *maxHeight = [_arguments objectForKey:@"maxHeight"]; + NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL]; + UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage]; + [_imagePickerController dismissViewControllerAnimated:YES completion:nil]; + if (image == nil) { + image = [info objectForKey:UIImagePickerControllerOriginalImage]; + } + image = [self normalizedImage:image]; -if (maxWidth != (id)[NSNull null] || maxHeight != (id)[NSNull null]) { - image = [self scaledImage:image maxWidth:maxWidth maxHeight:maxHeight]; -} - -if (videoURL != nil) { - NSData *data = [NSData dataWithContentsOfURL:videoURL]; - NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; - NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.MOV", guid]; - NSString *tmpDirectory = NSTemporaryDirectory(); - NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; - - if ([[NSFileManager defaultManager] createFileAtPath:tmpPath contents:data attributes:nil]) { - _result(tmpPath); - } else { - _result([FlutterError errorWithCode:@"create_error" - message:@"Temporary file could not be created" - details:nil]); + NSNumber *maxWidth = [_arguments objectForKey:@"maxWidth"]; + NSNumber *maxHeight = [_arguments objectForKey:@"maxHeight"]; + + if (maxWidth != (id)[NSNull null] || maxHeight != (id)[NSNull null]) { + image = [self scaledImage:image maxWidth:maxWidth maxHeight:maxHeight]; } -} else { - NSData *data = UIImageJPEGRepresentation(image, 1.0); - NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; - NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.jpg", guid]; - NSString *tmpDirectory = NSTemporaryDirectory(); - NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; - - if ([[NSFileManager defaultManager] createFileAtPath:tmpPath contents:data attributes:nil]) { - _result(tmpPath); + + if (videoURL != nil) { + NSData *data = [NSData dataWithContentsOfURL:videoURL]; + NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; + NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.MOV", guid]; + NSString *tmpDirectory = NSTemporaryDirectory(); + NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; + + if ([[NSFileManager defaultManager] createFileAtPath:tmpPath contents:data attributes:nil]) { + _result(tmpPath); + } else { + _result([FlutterError errorWithCode:@"create_error" + message:@"Temporary file could not be created" + details:nil]); + } } else { - _result([FlutterError errorWithCode:@"create_error" - message:@"Temporary file could not be created" - details:nil]); + NSData *data = UIImageJPEGRepresentation(image, 1.0); + NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; + NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.jpg", guid]; + NSString *tmpDirectory = NSTemporaryDirectory(); + NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; + + if ([[NSFileManager defaultManager] createFileAtPath:tmpPath contents:data attributes:nil]) { + _result(tmpPath); + } else { + _result([FlutterError errorWithCode:@"create_error" + message:@"Temporary file could not be created" + details:nil]); + } } -} _result = nil; _arguments = nil; From 86d5e8886cb1d49b4f313a56fd9b0e3c0a0b4f29 Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Fri, 11 May 2018 10:45:17 -0400 Subject: [PATCH 08/41] Revert "Revert "Updating Formating"" This reverts commit 1fb8bf71fa556142b0b2a85aeedcd84e38df74a0. --- .../ios/Classes/ImagePickerPlugin.m | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/packages/image_picker/ios/Classes/ImagePickerPlugin.m b/packages/image_picker/ios/Classes/ImagePickerPlugin.m index 3bce5d7ead17..08723a75c608 100644 --- a/packages/image_picker/ios/Classes/ImagePickerPlugin.m +++ b/packages/image_picker/ios/Classes/ImagePickerPlugin.m @@ -124,50 +124,50 @@ - (void)showPhotoLibrary { - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { - NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL]; - UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage]; - [_imagePickerController dismissViewControllerAnimated:YES completion:nil]; - if (image == nil) { - image = [info objectForKey:UIImagePickerControllerOriginalImage]; - } - image = [self normalizedImage:image]; - - NSNumber *maxWidth = [_arguments objectForKey:@"maxWidth"]; - NSNumber *maxHeight = [_arguments objectForKey:@"maxHeight"]; +NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL]; +UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage]; +[_imagePickerController dismissViewControllerAnimated:YES completion:nil]; +if (image == nil) { + image = [info objectForKey:UIImagePickerControllerOriginalImage]; +} +image = [self normalizedImage:image]; + +NSNumber *maxWidth = [_arguments objectForKey:@"maxWidth"]; +NSNumber *maxHeight = [_arguments objectForKey:@"maxHeight"]; - if (maxWidth != (id)[NSNull null] || maxHeight != (id)[NSNull null]) { - image = [self scaledImage:image maxWidth:maxWidth maxHeight:maxHeight]; +if (maxWidth != (id)[NSNull null] || maxHeight != (id)[NSNull null]) { + image = [self scaledImage:image maxWidth:maxWidth maxHeight:maxHeight]; +} + +if (videoURL != nil) { + NSData *data = [NSData dataWithContentsOfURL:videoURL]; + NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; + NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.MOV", guid]; + NSString *tmpDirectory = NSTemporaryDirectory(); + NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; + + if ([[NSFileManager defaultManager] createFileAtPath:tmpPath contents:data attributes:nil]) { + _result(tmpPath); + } else { + _result([FlutterError errorWithCode:@"create_error" + message:@"Temporary file could not be created" + details:nil]); } - - if (videoURL != nil) { - NSData *data = [NSData dataWithContentsOfURL:videoURL]; - NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; - NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.MOV", guid]; - NSString *tmpDirectory = NSTemporaryDirectory(); - NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; - - if ([[NSFileManager defaultManager] createFileAtPath:tmpPath contents:data attributes:nil]) { - _result(tmpPath); - } else { - _result([FlutterError errorWithCode:@"create_error" - message:@"Temporary file could not be created" - details:nil]); - } +} else { + NSData *data = UIImageJPEGRepresentation(image, 1.0); + NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; + NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.jpg", guid]; + NSString *tmpDirectory = NSTemporaryDirectory(); + NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; + + if ([[NSFileManager defaultManager] createFileAtPath:tmpPath contents:data attributes:nil]) { + _result(tmpPath); } else { - NSData *data = UIImageJPEGRepresentation(image, 1.0); - NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; - NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.jpg", guid]; - NSString *tmpDirectory = NSTemporaryDirectory(); - NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; - - if ([[NSFileManager defaultManager] createFileAtPath:tmpPath contents:data attributes:nil]) { - _result(tmpPath); - } else { - _result([FlutterError errorWithCode:@"create_error" - message:@"Temporary file could not be created" - details:nil]); - } + _result([FlutterError errorWithCode:@"create_error" + message:@"Temporary file could not be created" + details:nil]); } +} _result = nil; _arguments = nil; From eaa2f8d718a0399a76432db1b08658fc9ea32754 Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Fri, 11 May 2018 10:45:19 -0400 Subject: [PATCH 09/41] Revert "Revert "Revert "Updating Formating""" This reverts commit 86d5e8886cb1d49b4f313a56fd9b0e3c0a0b4f29. --- .../ios/Classes/ImagePickerPlugin.m | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/packages/image_picker/ios/Classes/ImagePickerPlugin.m b/packages/image_picker/ios/Classes/ImagePickerPlugin.m index 08723a75c608..3bce5d7ead17 100644 --- a/packages/image_picker/ios/Classes/ImagePickerPlugin.m +++ b/packages/image_picker/ios/Classes/ImagePickerPlugin.m @@ -124,50 +124,50 @@ - (void)showPhotoLibrary { - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { -NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL]; -UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage]; -[_imagePickerController dismissViewControllerAnimated:YES completion:nil]; -if (image == nil) { - image = [info objectForKey:UIImagePickerControllerOriginalImage]; -} -image = [self normalizedImage:image]; - -NSNumber *maxWidth = [_arguments objectForKey:@"maxWidth"]; -NSNumber *maxHeight = [_arguments objectForKey:@"maxHeight"]; + NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL]; + UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage]; + [_imagePickerController dismissViewControllerAnimated:YES completion:nil]; + if (image == nil) { + image = [info objectForKey:UIImagePickerControllerOriginalImage]; + } + image = [self normalizedImage:image]; -if (maxWidth != (id)[NSNull null] || maxHeight != (id)[NSNull null]) { - image = [self scaledImage:image maxWidth:maxWidth maxHeight:maxHeight]; -} - -if (videoURL != nil) { - NSData *data = [NSData dataWithContentsOfURL:videoURL]; - NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; - NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.MOV", guid]; - NSString *tmpDirectory = NSTemporaryDirectory(); - NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; - - if ([[NSFileManager defaultManager] createFileAtPath:tmpPath contents:data attributes:nil]) { - _result(tmpPath); - } else { - _result([FlutterError errorWithCode:@"create_error" - message:@"Temporary file could not be created" - details:nil]); + NSNumber *maxWidth = [_arguments objectForKey:@"maxWidth"]; + NSNumber *maxHeight = [_arguments objectForKey:@"maxHeight"]; + + if (maxWidth != (id)[NSNull null] || maxHeight != (id)[NSNull null]) { + image = [self scaledImage:image maxWidth:maxWidth maxHeight:maxHeight]; } -} else { - NSData *data = UIImageJPEGRepresentation(image, 1.0); - NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; - NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.jpg", guid]; - NSString *tmpDirectory = NSTemporaryDirectory(); - NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; - - if ([[NSFileManager defaultManager] createFileAtPath:tmpPath contents:data attributes:nil]) { - _result(tmpPath); + + if (videoURL != nil) { + NSData *data = [NSData dataWithContentsOfURL:videoURL]; + NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; + NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.MOV", guid]; + NSString *tmpDirectory = NSTemporaryDirectory(); + NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; + + if ([[NSFileManager defaultManager] createFileAtPath:tmpPath contents:data attributes:nil]) { + _result(tmpPath); + } else { + _result([FlutterError errorWithCode:@"create_error" + message:@"Temporary file could not be created" + details:nil]); + } } else { - _result([FlutterError errorWithCode:@"create_error" - message:@"Temporary file could not be created" - details:nil]); + NSData *data = UIImageJPEGRepresentation(image, 1.0); + NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; + NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.jpg", guid]; + NSString *tmpDirectory = NSTemporaryDirectory(); + NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; + + if ([[NSFileManager defaultManager] createFileAtPath:tmpPath contents:data attributes:nil]) { + _result(tmpPath); + } else { + _result([FlutterError errorWithCode:@"create_error" + message:@"Temporary file could not be created" + details:nil]); + } } -} _result = nil; _arguments = nil; From c6e35dadb0849296d5210f0e5298dafc5086e295 Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Fri, 11 May 2018 10:45:30 -0400 Subject: [PATCH 10/41] Revert "Rolling Back Number" This reverts commit 4f3b1c39abc18cc1336d0a8eb6691114e73e002b. --- packages/image_picker/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/image_picker/pubspec.yaml b/packages/image_picker/pubspec.yaml index 6cf51d57a373..ece829d4e57c 100755 --- a/packages/image_picker/pubspec.yaml +++ b/packages/image_picker/pubspec.yaml @@ -3,7 +3,7 @@ description: Flutter plugin for selecting images from the Android and iOS image library, and taking new pictures with the camera. author: Flutter Team homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker -version: 0.4.1 +version: 0.4.2 flutter: plugin: From 7e83b8f461da8989fa34c386820b803ff191ce3c Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Fri, 11 May 2018 10:45:37 -0400 Subject: [PATCH 11/41] Revert "Updating Formating" This reverts commit 54c3f68e3b7282c48b1cf25132bac57e61667885. --- .../io/flutter/plugins/imagepicker/ImagePickerDelegate.java | 2 +- .../java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java | 2 +- packages/image_picker/lib/image_picker.dart | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java b/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java index 1450cbcaf449..ee0a6e7b649e 100644 --- a/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java +++ b/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java @@ -295,7 +295,7 @@ private void launchTakeImageWithCameraIntent() { activity.startActivityForResult(intent, REQUEST_CODE_TAKE_WITH_CAMERA); } - + private File createTemporaryWritableImageFile() { String filename = UUID.randomUUID().toString(); File image; diff --git a/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java b/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java index b3cc895575c9..1a0adb5338e3 100644 --- a/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java +++ b/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java @@ -61,7 +61,7 @@ public void onMethodCall(MethodCall call, MethodChannel.Result result) { default: throw new IllegalArgumentException("Invalid image source: " + imageSource); } - } else if (call.method.equals("pickVideo")) { + } else if (call.method.equals("pickVideo")) { switch (imageSource) { case SOURCE_GALLERY: delegate.chooseVideoFromGallery(call, result); diff --git a/packages/image_picker/lib/image_picker.dart b/packages/image_picker/lib/image_picker.dart index ad7f8018816e..1214eb120dcf 100755 --- a/packages/image_picker/lib/image_picker.dart +++ b/packages/image_picker/lib/image_picker.dart @@ -55,7 +55,6 @@ class ImagePicker { return path != null ? new File(path) : null; } - static Future pickVideo({ @required ImageSource source, double maxWidth, @@ -79,6 +78,6 @@ class ImagePicker { 'maxHeight': maxHeight, }, ); - return path != null ? new File(path) : null; + return path != null ? new File(path) : null; } } From ae485343b9795a4d1cf179bd30666e732f44d2c4 Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Fri, 11 May 2018 10:45:42 -0400 Subject: [PATCH 12/41] Revert "Updating Number" This reverts commit a1143e44f22e8d03177ba0456d877ed7eb0a0af2. --- packages/image_picker/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/image_picker/pubspec.yaml b/packages/image_picker/pubspec.yaml index ece829d4e57c..6cf51d57a373 100755 --- a/packages/image_picker/pubspec.yaml +++ b/packages/image_picker/pubspec.yaml @@ -3,7 +3,7 @@ description: Flutter plugin for selecting images from the Android and iOS image library, and taking new pictures with the camera. author: Flutter Team homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker -version: 0.4.2 +version: 0.4.1 flutter: plugin: From 97bc60d02163337598300ac37075c9de4024cc16 Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Fri, 11 May 2018 10:50:33 -0400 Subject: [PATCH 13/41] Updating Formatting --- .../io/flutter/plugins/imagepicker/ImagePickerDelegate.java | 2 +- .../java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java | 2 +- packages/image_picker/lib/image_picker.dart | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java b/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java index ee0a6e7b649e..1450cbcaf449 100644 --- a/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java +++ b/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java @@ -295,7 +295,7 @@ private void launchTakeImageWithCameraIntent() { activity.startActivityForResult(intent, REQUEST_CODE_TAKE_WITH_CAMERA); } - + private File createTemporaryWritableImageFile() { String filename = UUID.randomUUID().toString(); File image; diff --git a/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java b/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java index 1a0adb5338e3..b3cc895575c9 100644 --- a/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java +++ b/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java @@ -61,7 +61,7 @@ public void onMethodCall(MethodCall call, MethodChannel.Result result) { default: throw new IllegalArgumentException("Invalid image source: " + imageSource); } - } else if (call.method.equals("pickVideo")) { + } else if (call.method.equals("pickVideo")) { switch (imageSource) { case SOURCE_GALLERY: delegate.chooseVideoFromGallery(call, result); diff --git a/packages/image_picker/lib/image_picker.dart b/packages/image_picker/lib/image_picker.dart index 1214eb120dcf..ad7f8018816e 100755 --- a/packages/image_picker/lib/image_picker.dart +++ b/packages/image_picker/lib/image_picker.dart @@ -55,6 +55,7 @@ class ImagePicker { return path != null ? new File(path) : null; } + static Future pickVideo({ @required ImageSource source, double maxWidth, @@ -78,6 +79,6 @@ class ImagePicker { 'maxHeight': maxHeight, }, ); - return path != null ? new File(path) : null; + return path != null ? new File(path) : null; } } From 95b6bb36ee8bf1e90d175bf4b93d45dffd739811 Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Fri, 11 May 2018 11:11:32 -0400 Subject: [PATCH 14/41] Updating Formatting --- .../ios/Classes/ImagePickerPlugin.m | 291 +++++++++--------- 1 file changed, 146 insertions(+), 145 deletions(-) diff --git a/packages/image_picker/ios/Classes/ImagePickerPlugin.m b/packages/image_picker/ios/Classes/ImagePickerPlugin.m index 3bce5d7ead17..1734347822ee 100644 --- a/packages/image_picker/ios/Classes/ImagePickerPlugin.m +++ b/packages/image_picker/ios/Classes/ImagePickerPlugin.m @@ -1,3 +1,4 @@ + // Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -15,115 +16,115 @@ @interface FLTImagePickerPlugin () *)registrar { - FlutterMethodChannel *channel = - [FlutterMethodChannel methodChannelWithName:@"plugins.flutter.io/image_picker" - binaryMessenger:[registrar messenger]]; - UIViewController *viewController = - [UIApplication sharedApplication].delegate.window.rootViewController; - FLTImagePickerPlugin *instance = - [[FLTImagePickerPlugin alloc] initWithViewController:viewController]; - [registrar addMethodCallDelegate:instance channel:channel]; + FlutterMethodChannel *channel = + [FlutterMethodChannel methodChannelWithName:@"plugins.flutter.io/image_picker" + binaryMessenger:[registrar messenger]]; + UIViewController *viewController = + [UIApplication sharedApplication].delegate.window.rootViewController; + FLTImagePickerPlugin *instance = + [[FLTImagePickerPlugin alloc] initWithViewController:viewController]; + [registrar addMethodCallDelegate:instance channel:channel]; } - (instancetype)initWithViewController:(UIViewController *)viewController { - self = [super init]; - if (self) { - _viewController = viewController; - _imagePickerController = [[UIImagePickerController alloc] init]; - } - return self; + self = [super init]; + if (self) { + _viewController = viewController; + _imagePickerController = [[UIImagePickerController alloc] init]; + } + return self; } - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result { - if (_result) { - _result([FlutterError errorWithCode:@"multiple_request" - message:@"Cancelled by a second request" - details:nil]); - _result = nil; - } - - if ([@"pickImage" isEqualToString:call.method]) { - _imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext; - _imagePickerController.delegate = self; - _imagePickerController.mediaTypes = @[(NSString*)kUTTypeImage]; - - - _result = result; - _arguments = call.arguments; - - int imageSource = [[_arguments objectForKey:@"source"] intValue]; - - switch (imageSource) { - case SOURCE_CAMERA: - [self showCamera]; - break; - case SOURCE_GALLERY: - [self showPhotoLibrary]; - break; - default: - result([FlutterError errorWithCode:@"invalid_source" - message:@"Invalid image source." - details:nil]); - break; + if (_result) { + _result([FlutterError errorWithCode:@"multiple_request" + message:@"Cancelled by a second request" + details:nil]); + _result = nil; + } + + if ([@"pickImage" isEqualToString:call.method]) { + _imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext; + _imagePickerController.delegate = self; + _imagePickerController.mediaTypes = @[(NSString*)kUTTypeImage]; + + + _result = result; + _arguments = call.arguments; + + int imageSource = [[_arguments objectForKey:@"source"] intValue]; + + switch (imageSource) { + case SOURCE_CAMERA: + [self showCamera]; + break; + case SOURCE_GALLERY: + [self showPhotoLibrary]; + break; + default: + result([FlutterError errorWithCode:@"invalid_source" + message:@"Invalid image source." + details:nil]); + break; + } + } else if ([@"pickVideo" isEqualToString:call.method]) { + _imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext; + _imagePickerController.delegate = self; + _imagePickerController.mediaTypes = @[(NSString*)kUTTypeMovie, (NSString*)kUTTypeAVIMovie, (NSString*)kUTTypeVideo, (NSString*)kUTTypeMPEG4]; + _imagePickerController.videoQuality = UIImagePickerControllerQualityTypeHigh; + + _result = result; + _arguments = call.arguments; + + int imageSource = [[_arguments objectForKey:@"source"] intValue]; + + switch (imageSource) { + case SOURCE_CAMERA: + [self showCamera]; + break; + case SOURCE_GALLERY: + [self showPhotoLibrary]; + break; + default: + result([FlutterError errorWithCode:@"invalid_source" + message:@"Invalid video source." + details:nil]); + break; + } + } else { + result(FlutterMethodNotImplemented); } - } else if ([@"pickVideo" isEqualToString:call.method]) { - _imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext; - _imagePickerController.delegate = self; - _imagePickerController.mediaTypes = @[(NSString*)kUTTypeMovie, (NSString*)kUTTypeAVIMovie, (NSString*)kUTTypeVideo, (NSString*)kUTTypeMPEG4]; - _imagePickerController.videoQuality = UIImagePickerControllerQualityTypeHigh; - - _result = result; - _arguments = call.arguments; - - int imageSource = [[_arguments objectForKey:@"source"] intValue]; - - switch (imageSource) { - case SOURCE_CAMERA: - [self showCamera]; - break; - case SOURCE_GALLERY: - [self showPhotoLibrary]; - break; - default: - result([FlutterError errorWithCode:@"invalid_source" - message:@"Invalid video source." - details:nil]); - break; - } - } else { - result(FlutterMethodNotImplemented); - } } - (void)showCamera { - // Camera is not available on simulators - if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { - _imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera; - [_viewController presentViewController:_imagePickerController animated:YES completion:nil]; - } else { - [[[UIAlertView alloc] initWithTitle:@"Error" - message:@"Camera not available." - delegate:nil - cancelButtonTitle:@"OK" - otherButtonTitles:nil] show]; - } + // Camera is not available on simulators + if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { + _imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera; + [_viewController presentViewController:_imagePickerController animated:YES completion:nil]; + } else { + [[[UIAlertView alloc] initWithTitle:@"Error" + message:@"Camera not available." + delegate:nil + cancelButtonTitle:@"OK" + otherButtonTitles:nil] show]; + } } - (void)showPhotoLibrary { - // No need to check if SourceType is available. It always is. - _imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; - [_viewController presentViewController:_imagePickerController animated:YES completion:nil]; + // No need to check if SourceType is available. It always is. + _imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; + [_viewController presentViewController:_imagePickerController animated:YES completion:nil]; } - (void)imagePickerController:(UIImagePickerController *)picker - didFinishPickingMediaWithInfo:(NSDictionary *)info { +didFinishPickingMediaWithInfo:(NSDictionary *)info { NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL]; UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage]; [_imagePickerController dismissViewControllerAnimated:YES completion:nil]; @@ -145,7 +146,7 @@ - (void)imagePickerController:(UIImagePickerController *)picker NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.MOV", guid]; NSString *tmpDirectory = NSTemporaryDirectory(); NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; - + if ([[NSFileManager defaultManager] createFileAtPath:tmpPath contents:data attributes:nil]) { _result(tmpPath); } else { @@ -159,7 +160,7 @@ - (void)imagePickerController:(UIImagePickerController *)picker NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.jpg", guid]; NSString *tmpDirectory = NSTemporaryDirectory(); NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; - + if ([[NSFileManager defaultManager] createFileAtPath:tmpPath contents:data attributes:nil]) { _result(tmpPath); } else { @@ -169,8 +170,8 @@ - (void)imagePickerController:(UIImagePickerController *)picker } } - _result = nil; - _arguments = nil; + _result = nil; + _arguments = nil; } // The way we save images to the tmp dir currently throws away all EXIF data @@ -179,63 +180,63 @@ - (void)imagePickerController:(UIImagePickerController *)picker // image data. // TODO(goderbauer): investigate how to preserve EXIF data. - (UIImage *)normalizedImage:(UIImage *)image { - if (image.imageOrientation == UIImageOrientationUp) return image; - - UIGraphicsBeginImageContextWithOptions(image.size, NO, image.scale); - [image drawInRect:(CGRect){0, 0, image.size}]; - UIImage *normalizedImage = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - return normalizedImage; + if (image.imageOrientation == UIImageOrientationUp) return image; + + UIGraphicsBeginImageContextWithOptions(image.size, NO, image.scale); + [image drawInRect:(CGRect){0, 0, image.size}]; + UIImage *normalizedImage = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + return normalizedImage; } - (UIImage *)scaledImage:(UIImage *)image maxWidth:(NSNumber *)maxWidth maxHeight:(NSNumber *)maxHeight { - double originalWidth = image.size.width; - double originalHeight = image.size.height; - - bool hasMaxWidth = maxWidth != (id)[NSNull null]; - bool hasMaxHeight = maxHeight != (id)[NSNull null]; - - double width = hasMaxWidth ? MIN([maxWidth doubleValue], originalWidth) : originalWidth; - double height = hasMaxHeight ? MIN([maxHeight doubleValue], originalHeight) : originalHeight; - - bool shouldDownscaleWidth = hasMaxWidth && [maxWidth doubleValue] < originalWidth; - bool shouldDownscaleHeight = hasMaxHeight && [maxHeight doubleValue] < originalHeight; - bool shouldDownscale = shouldDownscaleWidth || shouldDownscaleHeight; - - if (shouldDownscale) { - double downscaledWidth = (height / originalHeight) * originalWidth; - double downscaledHeight = (width / originalWidth) * originalHeight; - - if (width < height) { - if (!hasMaxWidth) { - width = downscaledWidth; - } else { - height = downscaledHeight; - } - } else if (height < width) { - if (!hasMaxHeight) { - height = downscaledHeight; - } else { - width = downscaledWidth; - } - } else { - if (originalWidth < originalHeight) { - width = downscaledWidth; - } else if (originalHeight < originalWidth) { - height = downscaledHeight; - } + double originalWidth = image.size.width; + double originalHeight = image.size.height; + + bool hasMaxWidth = maxWidth != (id)[NSNull null]; + bool hasMaxHeight = maxHeight != (id)[NSNull null]; + + double width = hasMaxWidth ? MIN([maxWidth doubleValue], originalWidth) : originalWidth; + double height = hasMaxHeight ? MIN([maxHeight doubleValue], originalHeight) : originalHeight; + + bool shouldDownscaleWidth = hasMaxWidth && [maxWidth doubleValue] < originalWidth; + bool shouldDownscaleHeight = hasMaxHeight && [maxHeight doubleValue] < originalHeight; + bool shouldDownscale = shouldDownscaleWidth || shouldDownscaleHeight; + + if (shouldDownscale) { + double downscaledWidth = (height / originalHeight) * originalWidth; + double downscaledHeight = (width / originalWidth) * originalHeight; + + if (width < height) { + if (!hasMaxWidth) { + width = downscaledWidth; + } else { + height = downscaledHeight; + } + } else if (height < width) { + if (!hasMaxHeight) { + height = downscaledHeight; + } else { + width = downscaledWidth; + } + } else { + if (originalWidth < originalHeight) { + width = downscaledWidth; + } else if (originalHeight < originalWidth) { + height = downscaledHeight; + } + } } - } - - UIGraphicsBeginImageContextWithOptions(CGSizeMake(width, height), NO, 1.0); - [image drawInRect:CGRectMake(0, 0, width, height)]; - - UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - - return scaledImage; + + UIGraphicsBeginImageContextWithOptions(CGSizeMake(width, height), NO, 1.0); + [image drawInRect:CGRectMake(0, 0, width, height)]; + + UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + + return scaledImage; } @end From d7d342ec52150df592c58f36c11e5a77e4351f3d Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Fri, 11 May 2018 11:32:10 -0400 Subject: [PATCH 15/41] Updating Formatting Based on Google Style Guide --- .../ios/Classes/ImagePickerPlugin.m | 360 +++++++++--------- 1 file changed, 180 insertions(+), 180 deletions(-) diff --git a/packages/image_picker/ios/Classes/ImagePickerPlugin.m b/packages/image_picker/ios/Classes/ImagePickerPlugin.m index 1734347822ee..445188541b6e 100644 --- a/packages/image_picker/ios/Classes/ImagePickerPlugin.m +++ b/packages/image_picker/ios/Classes/ImagePickerPlugin.m @@ -5,9 +5,9 @@ #import "ImagePickerPlugin.h" -#import #import #import +#import @interface FLTImagePickerPlugin () @end @@ -16,162 +16,162 @@ @interface FLTImagePickerPlugin () *)registrar { - FlutterMethodChannel *channel = - [FlutterMethodChannel methodChannelWithName:@"plugins.flutter.io/image_picker" - binaryMessenger:[registrar messenger]]; - UIViewController *viewController = - [UIApplication sharedApplication].delegate.window.rootViewController; - FLTImagePickerPlugin *instance = - [[FLTImagePickerPlugin alloc] initWithViewController:viewController]; - [registrar addMethodCallDelegate:instance channel:channel]; + FlutterMethodChannel *channel = + [FlutterMethodChannel methodChannelWithName:@"plugins.flutter.io/image_picker" + binaryMessenger:[registrar messenger]]; + UIViewController *viewController = + [UIApplication sharedApplication].delegate.window.rootViewController; + FLTImagePickerPlugin *instance = + [[FLTImagePickerPlugin alloc] initWithViewController:viewController]; + [registrar addMethodCallDelegate:instance channel:channel]; } - (instancetype)initWithViewController:(UIViewController *)viewController { - self = [super init]; - if (self) { - _viewController = viewController; - _imagePickerController = [[UIImagePickerController alloc] init]; - } - return self; + self = [super init]; + if (self) { + _viewController = viewController; + _imagePickerController = [[UIImagePickerController alloc] init]; + } + return self; } - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result { - if (_result) { - _result([FlutterError errorWithCode:@"multiple_request" - message:@"Cancelled by a second request" - details:nil]); - _result = nil; + if (_result) { + _result([FlutterError errorWithCode:@"multiple_request" + message:@"Cancelled by a second request" + details:nil]); + _result = nil; + } + + if ([@"pickImage" isEqualToString:call.method]) { + _imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext; + _imagePickerController.delegate = self; + _imagePickerController.mediaTypes = @[(NSString*)kUTTypeImage]; + + + _result = result; + _arguments = call.arguments; + + int imageSource = [[_arguments objectForKey:@"source"] intValue]; + + switch (imageSource) { + case SOURCE_CAMERA: + [self showCamera]; + break; + case SOURCE_GALLERY: + [self showPhotoLibrary]; + break; + default: + result([FlutterError errorWithCode:@"invalid_source" + message:@"Invalid image source." + details:nil]); + break; } + } else if ([@"pickVideo" isEqualToString:call.method]) { + _imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext; + _imagePickerController.delegate = self; + _imagePickerController.mediaTypes = @[(NSString*)kUTTypeMovie, (NSString*)kUTTypeAVIMovie, (NSString*)kUTTypeVideo, (NSString*)kUTTypeMPEG4]; + _imagePickerController.videoQuality = UIImagePickerControllerQualityTypeHigh; - if ([@"pickImage" isEqualToString:call.method]) { - _imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext; - _imagePickerController.delegate = self; - _imagePickerController.mediaTypes = @[(NSString*)kUTTypeImage]; - - - _result = result; - _arguments = call.arguments; - - int imageSource = [[_arguments objectForKey:@"source"] intValue]; - - switch (imageSource) { - case SOURCE_CAMERA: - [self showCamera]; - break; - case SOURCE_GALLERY: - [self showPhotoLibrary]; - break; - default: - result([FlutterError errorWithCode:@"invalid_source" - message:@"Invalid image source." - details:nil]); - break; - } - } else if ([@"pickVideo" isEqualToString:call.method]) { - _imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext; - _imagePickerController.delegate = self; - _imagePickerController.mediaTypes = @[(NSString*)kUTTypeMovie, (NSString*)kUTTypeAVIMovie, (NSString*)kUTTypeVideo, (NSString*)kUTTypeMPEG4]; - _imagePickerController.videoQuality = UIImagePickerControllerQualityTypeHigh; - - _result = result; - _arguments = call.arguments; - - int imageSource = [[_arguments objectForKey:@"source"] intValue]; - - switch (imageSource) { - case SOURCE_CAMERA: - [self showCamera]; - break; - case SOURCE_GALLERY: - [self showPhotoLibrary]; - break; - default: - result([FlutterError errorWithCode:@"invalid_source" - message:@"Invalid video source." - details:nil]); - break; - } - } else { - result(FlutterMethodNotImplemented); + _result = result; + _arguments = call.arguments; + + int imageSource = [[_arguments objectForKey:@"source"] intValue]; + + switch (imageSource) { + case SOURCE_CAMERA: + [self showCamera]; + break; + case SOURCE_GALLERY: + [self showPhotoLibrary]; + break; + default: + result([FlutterError errorWithCode:@"invalid_source" + message:@"Invalid video source." + details:nil]); + break; } + } else { + result(FlutterMethodNotImplemented); + } } - (void)showCamera { - // Camera is not available on simulators - if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { - _imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera; - [_viewController presentViewController:_imagePickerController animated:YES completion:nil]; - } else { - [[[UIAlertView alloc] initWithTitle:@"Error" - message:@"Camera not available." - delegate:nil - cancelButtonTitle:@"OK" - otherButtonTitles:nil] show]; - } + // Camera is not available on simulators + if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { + _imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera; + [_viewController presentViewController:_imagePickerController animated:YES completion:nil]; + } else { + [[[UIAlertView alloc] initWithTitle:@"Error" + message:@"Camera not available." + delegate:nil + cancelButtonTitle:@"OK" + otherButtonTitles:nil] show]; + } } - (void)showPhotoLibrary { - // No need to check if SourceType is available. It always is. - _imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; - [_viewController presentViewController:_imagePickerController animated:YES completion:nil]; + // No need to check if SourceType is available. It always is. + _imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; + [_viewController presentViewController:_imagePickerController animated:YES completion:nil]; } - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { - NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL]; - UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage]; - [_imagePickerController dismissViewControllerAnimated:YES completion:nil]; - if (image == nil) { - image = [info objectForKey:UIImagePickerControllerOriginalImage]; - } - image = [self normalizedImage:image]; + NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL]; + UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage]; + [_imagePickerController dismissViewControllerAnimated:YES completion:nil]; + if (image == nil) { + image = [info objectForKey:UIImagePickerControllerOriginalImage]; + } + image = [self normalizedImage:image]; + + NSNumber *maxWidth = [_arguments objectForKey:@"maxWidth"]; + NSNumber *maxHeight = [_arguments objectForKey:@"maxHeight"]; + + if (maxWidth != (id)[NSNull null] || maxHeight != (id)[NSNull null]) { + image = [self scaledImage:image maxWidth:maxWidth maxHeight:maxHeight]; + } + + if (videoURL != nil) { + NSData *data = [NSData dataWithContentsOfURL:videoURL]; + NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; + NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.MOV", guid]; + NSString *tmpDirectory = NSTemporaryDirectory(); + NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; - NSNumber *maxWidth = [_arguments objectForKey:@"maxWidth"]; - NSNumber *maxHeight = [_arguments objectForKey:@"maxHeight"]; - - if (maxWidth != (id)[NSNull null] || maxHeight != (id)[NSNull null]) { - image = [self scaledImage:image maxWidth:maxWidth maxHeight:maxHeight]; + if ([[NSFileManager defaultManager] createFileAtPath:tmpPath contents:data attributes:nil]) { + _result(tmpPath); + } else { + _result([FlutterError errorWithCode:@"create_error" + message:@"Temporary file could not be created" + details:nil]); } + } else { + NSData *data = UIImageJPEGRepresentation(image, 1.0); + NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; + NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.jpg", guid]; + NSString *tmpDirectory = NSTemporaryDirectory(); + NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; - if (videoURL != nil) { - NSData *data = [NSData dataWithContentsOfURL:videoURL]; - NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; - NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.MOV", guid]; - NSString *tmpDirectory = NSTemporaryDirectory(); - NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; - - if ([[NSFileManager defaultManager] createFileAtPath:tmpPath contents:data attributes:nil]) { - _result(tmpPath); - } else { - _result([FlutterError errorWithCode:@"create_error" - message:@"Temporary file could not be created" - details:nil]); - } + if ([[NSFileManager defaultManager] createFileAtPath:tmpPath contents:data attributes:nil]) { + _result(tmpPath); } else { - NSData *data = UIImageJPEGRepresentation(image, 1.0); - NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; - NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.jpg", guid]; - NSString *tmpDirectory = NSTemporaryDirectory(); - NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; - - if ([[NSFileManager defaultManager] createFileAtPath:tmpPath contents:data attributes:nil]) { - _result(tmpPath); - } else { - _result([FlutterError errorWithCode:@"create_error" - message:@"Temporary file could not be created" - details:nil]); - } + _result([FlutterError errorWithCode:@"create_error" + message:@"Temporary file could not be created" + details:nil]); } - - _result = nil; - _arguments = nil; + } + + _result = nil; + _arguments = nil; } // The way we save images to the tmp dir currently throws away all EXIF data @@ -180,63 +180,63 @@ - (void)imagePickerController:(UIImagePickerController *)picker // image data. // TODO(goderbauer): investigate how to preserve EXIF data. - (UIImage *)normalizedImage:(UIImage *)image { - if (image.imageOrientation == UIImageOrientationUp) return image; - - UIGraphicsBeginImageContextWithOptions(image.size, NO, image.scale); - [image drawInRect:(CGRect){0, 0, image.size}]; - UIImage *normalizedImage = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - return normalizedImage; + if (image.imageOrientation == UIImageOrientationUp) return image; + + UIGraphicsBeginImageContextWithOptions(image.size, NO, image.scale); + [image drawInRect:(CGRect){0, 0, image.size}]; + UIImage *normalizedImage = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + return normalizedImage; } - (UIImage *)scaledImage:(UIImage *)image maxWidth:(NSNumber *)maxWidth maxHeight:(NSNumber *)maxHeight { - double originalWidth = image.size.width; - double originalHeight = image.size.height; + double originalWidth = image.size.width; + double originalHeight = image.size.height; + + bool hasMaxWidth = maxWidth != (id)[NSNull null]; + bool hasMaxHeight = maxHeight != (id)[NSNull null]; + + double width = hasMaxWidth ? MIN([maxWidth doubleValue], originalWidth) : originalWidth; + double height = hasMaxHeight ? MIN([maxHeight doubleValue], originalHeight) : originalHeight; + + bool shouldDownscaleWidth = hasMaxWidth && [maxWidth doubleValue] < originalWidth; + bool shouldDownscaleHeight = hasMaxHeight && [maxHeight doubleValue] < originalHeight; + bool shouldDownscale = shouldDownscaleWidth || shouldDownscaleHeight; + + if (shouldDownscale) { + double downscaledWidth = (height / originalHeight) * originalWidth; + double downscaledHeight = (width / originalWidth) * originalHeight; - bool hasMaxWidth = maxWidth != (id)[NSNull null]; - bool hasMaxHeight = maxHeight != (id)[NSNull null]; - - double width = hasMaxWidth ? MIN([maxWidth doubleValue], originalWidth) : originalWidth; - double height = hasMaxHeight ? MIN([maxHeight doubleValue], originalHeight) : originalHeight; - - bool shouldDownscaleWidth = hasMaxWidth && [maxWidth doubleValue] < originalWidth; - bool shouldDownscaleHeight = hasMaxHeight && [maxHeight doubleValue] < originalHeight; - bool shouldDownscale = shouldDownscaleWidth || shouldDownscaleHeight; - - if (shouldDownscale) { - double downscaledWidth = (height / originalHeight) * originalWidth; - double downscaledHeight = (width / originalWidth) * originalHeight; - - if (width < height) { - if (!hasMaxWidth) { - width = downscaledWidth; - } else { - height = downscaledHeight; - } - } else if (height < width) { - if (!hasMaxHeight) { - height = downscaledHeight; - } else { - width = downscaledWidth; - } - } else { - if (originalWidth < originalHeight) { - width = downscaledWidth; - } else if (originalHeight < originalWidth) { - height = downscaledHeight; - } - } + if (width < height) { + if (!hasMaxWidth) { + width = downscaledWidth; + } else { + height = downscaledHeight; + } + } else if (height < width) { + if (!hasMaxHeight) { + height = downscaledHeight; + } else { + width = downscaledWidth; + } + } else { + if (originalWidth < originalHeight) { + width = downscaledWidth; + } else if (originalHeight < originalWidth) { + height = downscaledHeight; + } } - - UIGraphicsBeginImageContextWithOptions(CGSizeMake(width, height), NO, 1.0); - [image drawInRect:CGRectMake(0, 0, width, height)]; - - UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - - return scaledImage; + } + + UIGraphicsBeginImageContextWithOptions(CGSizeMake(width, height), NO, 1.0); + [image drawInRect:CGRectMake(0, 0, width, height)]; + + UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + + return scaledImage; } @end From ffe05d02db5c159f93469f789cf23448a297e3e3 Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Fri, 11 May 2018 11:42:04 -0400 Subject: [PATCH 16/41] Fixing Spacing --- .../ios/Classes/ImagePickerPlugin.m | 62 ++++++++++--------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/packages/image_picker/ios/Classes/ImagePickerPlugin.m b/packages/image_picker/ios/Classes/ImagePickerPlugin.m index 445188541b6e..705137244355 100644 --- a/packages/image_picker/ios/Classes/ImagePickerPlugin.m +++ b/packages/image_picker/ios/Classes/ImagePickerPlugin.m @@ -24,12 +24,12 @@ @implementation FLTImagePickerPlugin { + (void)registerWithRegistrar:(NSObject *)registrar { FlutterMethodChannel *channel = - [FlutterMethodChannel methodChannelWithName:@"plugins.flutter.io/image_picker" + [FlutterMethodChannel methodChannelWithName:@"plugins.flutter.io/image_picker" binaryMessenger:[registrar messenger]]; UIViewController *viewController = - [UIApplication sharedApplication].delegate.window.rootViewController; + [UIApplication sharedApplication].delegate.window.rootViewController; FLTImagePickerPlugin *instance = - [[FLTImagePickerPlugin alloc] initWithViewController:viewController]; + [[FLTImagePickerPlugin alloc] initWithViewController:viewController]; [registrar addMethodCallDelegate:instance channel:channel]; } @@ -49,18 +49,17 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result details:nil]); _result = nil; } - + if ([@"pickImage" isEqualToString:call.method]) { _imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext; _imagePickerController.delegate = self; - _imagePickerController.mediaTypes = @[(NSString*)kUTTypeImage]; - - + _imagePickerController.mediaTypes = @[ (NSString*)kUTTypeImage ]; + _result = result; _arguments = call.arguments; - + int imageSource = [[_arguments objectForKey:@"source"] intValue]; - + switch (imageSource) { case SOURCE_CAMERA: [self showCamera]; @@ -77,14 +76,17 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result } else if ([@"pickVideo" isEqualToString:call.method]) { _imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext; _imagePickerController.delegate = self; - _imagePickerController.mediaTypes = @[(NSString*)kUTTypeMovie, (NSString*)kUTTypeAVIMovie, (NSString*)kUTTypeVideo, (NSString*)kUTTypeMPEG4]; + _imagePickerController.mediaTypes = @[ + (NSString*)kUTTypeMovie, (NSString*)kUTTypeAVIMovie, (NSString*)kUTTypeVideo, + (NSString*)kUTTypeMPEG4 + ]; _imagePickerController.videoQuality = UIImagePickerControllerQualityTypeHigh; - + _result = result; _arguments = call.arguments; - + int imageSource = [[_arguments objectForKey:@"source"] intValue]; - + switch (imageSource) { case SOURCE_CAMERA: [self showCamera]; @@ -124,7 +126,7 @@ - (void)showPhotoLibrary { } - (void)imagePickerController:(UIImagePickerController *)picker -didFinishPickingMediaWithInfo:(NSDictionary *)info { + didFinishPickingMediaWithInfo:(NSDictionary *)info { NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL]; UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage]; [_imagePickerController dismissViewControllerAnimated:YES completion:nil]; @@ -132,21 +134,21 @@ - (void)imagePickerController:(UIImagePickerController *)picker image = [info objectForKey:UIImagePickerControllerOriginalImage]; } image = [self normalizedImage:image]; - + NSNumber *maxWidth = [_arguments objectForKey:@"maxWidth"]; NSNumber *maxHeight = [_arguments objectForKey:@"maxHeight"]; - + if (maxWidth != (id)[NSNull null] || maxHeight != (id)[NSNull null]) { image = [self scaledImage:image maxWidth:maxWidth maxHeight:maxHeight]; } - + if (videoURL != nil) { NSData *data = [NSData dataWithContentsOfURL:videoURL]; NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.MOV", guid]; NSString *tmpDirectory = NSTemporaryDirectory(); NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; - + if ([[NSFileManager defaultManager] createFileAtPath:tmpPath contents:data attributes:nil]) { _result(tmpPath); } else { @@ -160,7 +162,7 @@ - (void)imagePickerController:(UIImagePickerController *)picker NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.jpg", guid]; NSString *tmpDirectory = NSTemporaryDirectory(); NSString *tmpPath = [tmpDirectory stringByAppendingPathComponent:tmpFile]; - + if ([[NSFileManager defaultManager] createFileAtPath:tmpPath contents:data attributes:nil]) { _result(tmpPath); } else { @@ -169,7 +171,7 @@ - (void)imagePickerController:(UIImagePickerController *)picker details:nil]); } } - + _result = nil; _arguments = nil; } @@ -181,7 +183,7 @@ - (void)imagePickerController:(UIImagePickerController *)picker // TODO(goderbauer): investigate how to preserve EXIF data. - (UIImage *)normalizedImage:(UIImage *)image { if (image.imageOrientation == UIImageOrientationUp) return image; - + UIGraphicsBeginImageContextWithOptions(image.size, NO, image.scale); [image drawInRect:(CGRect){0, 0, image.size}]; UIImage *normalizedImage = UIGraphicsGetImageFromCurrentImageContext(); @@ -194,21 +196,21 @@ - (UIImage *)scaledImage:(UIImage *)image maxHeight:(NSNumber *)maxHeight { double originalWidth = image.size.width; double originalHeight = image.size.height; - + bool hasMaxWidth = maxWidth != (id)[NSNull null]; bool hasMaxHeight = maxHeight != (id)[NSNull null]; - + double width = hasMaxWidth ? MIN([maxWidth doubleValue], originalWidth) : originalWidth; double height = hasMaxHeight ? MIN([maxHeight doubleValue], originalHeight) : originalHeight; - + bool shouldDownscaleWidth = hasMaxWidth && [maxWidth doubleValue] < originalWidth; bool shouldDownscaleHeight = hasMaxHeight && [maxHeight doubleValue] < originalHeight; bool shouldDownscale = shouldDownscaleWidth || shouldDownscaleHeight; - + if (shouldDownscale) { double downscaledWidth = (height / originalHeight) * originalWidth; double downscaledHeight = (width / originalWidth) * originalHeight; - + if (width < height) { if (!hasMaxWidth) { width = downscaledWidth; @@ -229,14 +231,16 @@ - (UIImage *)scaledImage:(UIImage *)image } } } - + UIGraphicsBeginImageContextWithOptions(CGSizeMake(width, height), NO, 1.0); [image drawInRect:CGRectMake(0, 0, width, height)]; - + UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); - + return scaledImage; } @end + + From 06d837e8c1f9153783c6cc260f88f22b5eab13e9 Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Fri, 11 May 2018 11:46:13 -0400 Subject: [PATCH 17/41] Updating Formatting based on Test Fail --- packages/image_picker/ios/Classes/ImagePickerPlugin.m | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/image_picker/ios/Classes/ImagePickerPlugin.m b/packages/image_picker/ios/Classes/ImagePickerPlugin.m index 705137244355..12bb8cbf70b0 100644 --- a/packages/image_picker/ios/Classes/ImagePickerPlugin.m +++ b/packages/image_picker/ios/Classes/ImagePickerPlugin.m @@ -25,7 +25,7 @@ @implementation FLTImagePickerPlugin { + (void)registerWithRegistrar:(NSObject *)registrar { FlutterMethodChannel *channel = [FlutterMethodChannel methodChannelWithName:@"plugins.flutter.io/image_picker" - binaryMessenger:[registrar messenger]]; + binaryMessenger:[registrar messenger]]; UIViewController *viewController = [UIApplication sharedApplication].delegate.window.rootViewController; FLTImagePickerPlugin *instance = @@ -53,7 +53,7 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result if ([@"pickImage" isEqualToString:call.method]) { _imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext; _imagePickerController.delegate = self; - _imagePickerController.mediaTypes = @[ (NSString*)kUTTypeImage ]; + _imagePickerController.mediaTypes = @[ (NSString *)kUTTypeImage ]; _result = result; _arguments = call.arguments; @@ -77,8 +77,8 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result _imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext; _imagePickerController.delegate = self; _imagePickerController.mediaTypes = @[ - (NSString*)kUTTypeMovie, (NSString*)kUTTypeAVIMovie, (NSString*)kUTTypeVideo, - (NSString*)kUTTypeMPEG4 + (NSString *)kUTTypeMovie, (NSString *)kUTTypeAVIMovie, (NSString *)kUTTypeVideo, + (NSString *)kUTTypeMPEG4 ]; _imagePickerController.videoQuality = UIImagePickerControllerQualityTypeHigh; @@ -242,5 +242,3 @@ - (UIImage *)scaledImage:(UIImage *)image } @end - - From 9754383a95684145fa3f15d7c569a9b78f01afc0 Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Fri, 11 May 2018 12:14:57 -0400 Subject: [PATCH 18/41] Working on Fixing Failed Tests --- .../java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java b/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java index b3cc895575c9..3e658a670bef 100644 --- a/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java +++ b/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java @@ -49,8 +49,8 @@ public void onMethodCall(MethodCall call, MethodChannel.Result result) { result.error("no_activity", "image_picker plugin requires a foreground activity.", null); return; } - int imageSource = call.argument("source"); if (call.method.equals("pickImage")) { + int imageSource = call.argument("source"); switch (imageSource) { case SOURCE_GALLERY: delegate.chooseImageFromGallery(call, result); @@ -62,6 +62,7 @@ public void onMethodCall(MethodCall call, MethodChannel.Result result) { throw new IllegalArgumentException("Invalid image source: " + imageSource); } } else if (call.method.equals("pickVideo")) { + int imageSource = call.argument("source"); switch (imageSource) { case SOURCE_GALLERY: delegate.chooseVideoFromGallery(call, result); From ddd770c1a61e0025110cfabdbb31c8f3c9896160 Mon Sep 17 00:00:00 2001 From: Rody Davis <31253215+AppleEducate@users.noreply.github.com> Date: Wed, 16 May 2018 10:32:57 -0400 Subject: [PATCH 19/41] Update main.dart --- packages/image_picker/example/lib/main.dart | 344 ++++++++++++++++++-- 1 file changed, 323 insertions(+), 21 deletions(-) diff --git a/packages/image_picker/example/lib/main.dart b/packages/image_picker/example/lib/main.dart index 4d5d9bfe084f..4bf202509f4b 100755 --- a/packages/image_picker/example/lib/main.dart +++ b/packages/image_picker/example/lib/main.dart @@ -7,18 +7,17 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:image_picker/image_picker.dart'; -import 'package:video_player/video_player.dart'; void main() { - runApp(MyApp()); + runApp(new MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - return MaterialApp( + return new MaterialApp( title: 'Image Picker Demo', - home: MyHomePage(title: 'Image Picker Example'), + home: new MyHomePage(title: 'Image Picker Example'), ); } } @@ -29,7 +28,7 @@ class MyHomePage extends StatefulWidget { final String title; @override - _MyHomePageState createState() => _MyHomePageState(); + _MyHomePageState createState() => new _MyHomePageState(); } class _MyHomePageState extends State { @@ -62,14 +61,18 @@ class _MyHomePageState extends State { @override void deactivate() { - _controller.setVolume(0.0); - _controller.removeListener(listener); + if (_controller != null) { + _controller.setVolume(0.0); + _controller.removeListener(listener); + } super.deactivate(); } @override void dispose() { - _controller.dispose(); + if (_controller != null) { + _controller.dispose(); + } super.dispose(); } @@ -80,23 +83,23 @@ class _MyHomePageState extends State { setState(() {}); }; } - - Widget _previewVideo(VideoPlayerController controller) { + + Widget _previewVideo(VideoPlayerController controller) { if (controller == null) { - return const Text('You have not yet picked a video'); + return const Text( + 'You have not yet picked a video', + textAlign: TextAlign.center, + ); } else if (controller.value.initialized) { return Padding( padding: const EdgeInsets.all(10.0), - child: AspectRatio( - aspectRatio: - controller.value.size.width / controller.value.size.height, - child: VideoPlayer( - controller, - ), - ), + child: AspectRatioVideo(controller), ); } else { - return const Text('Error Loading Video'); + return const Text( + 'Error Loading Video', + textAlign: TextAlign.center, + ); } } @@ -108,9 +111,15 @@ class _MyHomePageState extends State { snapshot.data != null) { return Image.file(snapshot.data); } else if (snapshot.error != null) { - return const Text('Error picking image.'); + return const Text( + 'Error picking image.', + textAlign: TextAlign.center, + ); } else { - return const Text('You have not yet picked an image.'); + return const Text( + 'You have not yet picked an image.', + textAlign: TextAlign.center, + ); } }); } @@ -179,3 +188,296 @@ class _MyHomePageState extends State { ); } } + +class AspectRatioVideo extends StatefulWidget { + final VideoPlayerController controller; + + AspectRatioVideo(this.controller); + + @override + AspectRatioVideoState createState() => new AspectRatioVideoState(); +} + +class AspectRatioVideoState extends State { + VideoPlayerController get controller => widget.controller; + bool initialized = false; + + VoidCallback listener; + + @override + void initState() { + super.initState(); + listener = () { + if (!mounted) { + return; + } + if (initialized != controller.value.initialized) { + initialized = controller.value.initialized; + setState(() {}); + } + }; + controller.addListener(listener); + } + + @override + Widget build(BuildContext context) { + if (initialized) { + final Size size = controller.value.size; + return new Center( + child: new AspectRatio( + aspectRatio: size.width / size.height, + child: new VideoPlayPause(controller), + ), + ); + } else { + return new Container(); + } + } +} + +class VideoPlayPause extends StatefulWidget { + final VideoPlayerController controller; + + VideoPlayPause(this.controller); + + @override + State createState() { + return new _VideoPlayPauseState(); + } +} + +class _VideoPlayPauseState extends State { + FadeAnimation imageFadeAnim = + new FadeAnimation(child: const Icon(Icons.play_arrow, size: 100.0)); + VoidCallback listener; + + _VideoPlayPauseState() { + listener = () { + setState(() {}); + }; + } + + VideoPlayerController get controller => widget.controller; + + @override + void initState() { + super.initState(); + controller.addListener(listener); + controller.setVolume(1.0); + controller.play(); + } + + @override + void deactivate() { + controller.setVolume(0.0); + controller.removeListener(listener); + super.deactivate(); + } + + @override + Widget build(BuildContext context) { + final List children = [ + new GestureDetector( + child: new VideoPlayer(controller), + onTap: () { + if (!controller.value.initialized) { + return; + } + if (controller.value.isPlaying) { + imageFadeAnim = + new FadeAnimation(child: const Icon(Icons.pause, size: 100.0)); + controller.pause(); + } else { + imageFadeAnim = new FadeAnimation( + child: const Icon(Icons.play_arrow, size: 100.0)); + controller.play(); + } + }, + ), + new Align( + alignment: Alignment.bottomCenter, + child: new VideoProgressIndicator( + controller, + allowScrubbing: true, + ), + ), + new Center(child: imageFadeAnim), + ]; + + return new Stack( + fit: StackFit.passthrough, + children: children, + ); + } +} + +class FadeAnimation extends StatefulWidget { + final Widget child; + final Duration duration; + + FadeAnimation({this.child, this.duration: const Duration(milliseconds: 500)}); + + @override + _FadeAnimationState createState() => new _FadeAnimationState(); +} + +class _FadeAnimationState extends State + with SingleTickerProviderStateMixin { + AnimationController animationController; + + @override + void initState() { + super.initState(); + animationController = + new AnimationController(duration: widget.duration, vsync: this); + animationController.addListener(() { + if (mounted) { + setState(() {}); + } + }); + animationController.forward(from: 0.0); + } + + @override + void deactivate() { + animationController.stop(); + super.deactivate(); + } + + @override + void didUpdateWidget(FadeAnimation oldWidget) { + super.didUpdateWidget(oldWidget); + if (oldWidget.child != widget.child) { + animationController.forward(from: 0.0); + } + } + + @override + void dispose() { + animationController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return animationController.isAnimating + ? new Opacity( + opacity: 1.0 - animationController.value, + child: widget.child, + ) + : new Container(); + } +} + +typedef Widget VideoWidgetBuilder( + BuildContext context, VideoPlayerController controller); + +abstract class PlayerLifeCycle extends StatefulWidget { + final VideoWidgetBuilder childBuilder; + final String dataSource; + + PlayerLifeCycle(this.dataSource, this.childBuilder); +} + +/// A widget connecting its life cycle to a [VideoPlayerController] using +/// a data source from the network. +class NetworkPlayerLifeCycle extends PlayerLifeCycle { + NetworkPlayerLifeCycle(String dataSource, VideoWidgetBuilder childBuilder) + : super(dataSource, childBuilder); + + @override + _NetworkPlayerLifeCycleState createState() => + new _NetworkPlayerLifeCycleState(); +} + +/// A widget connecting its life cycle to a [VideoPlayerController] using +/// an asset as data source +class AssetPlayerLifeCycle extends PlayerLifeCycle { + AssetPlayerLifeCycle(String dataSource, VideoWidgetBuilder childBuilder) + : super(dataSource, childBuilder); + + @override + _AssetPlayerLifeCycleState createState() => new _AssetPlayerLifeCycleState(); +} + +abstract class _PlayerLifeCycleState extends State { + VideoPlayerController controller; + + @override + + /// Subclasses should implement [createVideoPlayerController], which is used + /// by this method. + void initState() { + super.initState(); + controller = createVideoPlayerController(); + controller.addListener(() { + if (controller.value.hasError) { + print(controller.value.errorDescription); + } + }); + controller.initialize(); + controller.setLooping(true); + controller.play(); + } + + @override + void deactivate() { + super.deactivate(); + } + + @override + void dispose() { + controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return widget.childBuilder(context, controller); + } + + VideoPlayerController createVideoPlayerController(); +} + +class _NetworkPlayerLifeCycleState extends _PlayerLifeCycleState { + @override + VideoPlayerController createVideoPlayerController() { + return new VideoPlayerController.network(widget.dataSource); + } +} + +class _AssetPlayerLifeCycleState extends _PlayerLifeCycleState { + @override + VideoPlayerController createVideoPlayerController() { + return new VideoPlayerController.asset(widget.dataSource); + } +} + +/// A filler card to show the video in a list of scrolling contents. +Widget buildCard(String title) { + return new Card( + child: new Column( + mainAxisSize: MainAxisSize.min, + children: [ + new ListTile( + leading: const Icon(Icons.airline_seat_flat_angled), + title: new Text(title), + ), + new ButtonTheme.bar( + child: new ButtonBar( + children: [ + new FlatButton( + child: const Text('BUY TICKETS'), + onPressed: () {/* ... */}, + ), + new FlatButton( + child: const Text('SELL TICKETS'), + onPressed: () {/* ... */}, + ), + ], + ), + ), + ], + ), + ); +} From a2ee99da1be2323404c69e9b265023912d059246 Mon Sep 17 00:00:00 2001 From: Rody Davis <31253215+AppleEducate@users.noreply.github.com> Date: Wed, 16 May 2018 10:33:40 -0400 Subject: [PATCH 20/41] Updated Authors --- packages/image_picker/pubspec.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/image_picker/pubspec.yaml b/packages/image_picker/pubspec.yaml index 6cf51d57a373..5396e9d4e334 100755 --- a/packages/image_picker/pubspec.yaml +++ b/packages/image_picker/pubspec.yaml @@ -1,9 +1,11 @@ name: image_picker description: Flutter plugin for selecting images from the Android and iOS image library, and taking new pictures with the camera. -author: Flutter Team +authors: + - Flutter Team + - Rhodes Davis Jr. homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker -version: 0.4.1 +version: 0.4.2 flutter: plugin: From fd38d12240c06f050f69c8d7bdececc31fdbf003 Mon Sep 17 00:00:00 2001 From: Rody Davis <31253215+AppleEducate@users.noreply.github.com> Date: Wed, 16 May 2018 10:34:09 -0400 Subject: [PATCH 21/41] Update CHANGELOG.md --- packages/image_picker/CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/image_picker/CHANGELOG.md b/packages/image_picker/CHANGELOG.md index 803dcb922740..e7ec4fb02ab3 100644 --- a/packages/image_picker/CHANGELOG.md +++ b/packages/image_picker/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.4.2 + +* Added Video Capability with `pickVideo`. +* Updated Example for Preview of Video Captured + ## 0.4.1 * Bugfix: the `pickImage` method will now return null when the user cancels picking the image, instead of hanging indefinitely. From bfc5dc93d8a53f1c190fab02e2ffe9ca93adcd94 Mon Sep 17 00:00:00 2001 From: Rody Davis <31253215+AppleEducate@users.noreply.github.com> Date: Wed, 16 May 2018 10:36:38 -0400 Subject: [PATCH 22/41] Adding Video Player --- packages/image_picker/example/lib/main.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/image_picker/example/lib/main.dart b/packages/image_picker/example/lib/main.dart index 4bf202509f4b..58bff6e99aad 100755 --- a/packages/image_picker/example/lib/main.dart +++ b/packages/image_picker/example/lib/main.dart @@ -7,6 +7,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:image_picker/image_picker.dart'; +import 'package:video_player/video_player.dart'; void main() { runApp(new MyApp()); From 3a2f735310fea3134cb92ae3be4b1ea926fc91a3 Mon Sep 17 00:00:00 2001 From: Rody Davis <31253215+AppleEducate@users.noreply.github.com> Date: Wed, 16 May 2018 10:37:12 -0400 Subject: [PATCH 23/41] Updating Dependencies --- packages/image_picker/example/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/image_picker/example/pubspec.yaml b/packages/image_picker/example/pubspec.yaml index 10c3b713dc2e..8fbf4f47b6ad 100755 --- a/packages/image_picker/example/pubspec.yaml +++ b/packages/image_picker/example/pubspec.yaml @@ -2,7 +2,7 @@ name: image_picker_example description: Demonstrates how to use the image_picker plugin. dependencies: - video_player: "0.5.1" + video_player: "0.5.2" flutter: sdk: flutter image_picker: From 883f99db76acb9253ac5201f38fc11da0f6a260d Mon Sep 17 00:00:00 2001 From: Rody Davis <31253215+AppleEducate@users.noreply.github.com> Date: Wed, 16 May 2018 10:39:00 -0400 Subject: [PATCH 24/41] Updating Stying --- packages/image_picker/example/lib/main.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/image_picker/example/lib/main.dart b/packages/image_picker/example/lib/main.dart index 58bff6e99aad..02bedebbdb44 100755 --- a/packages/image_picker/example/lib/main.dart +++ b/packages/image_picker/example/lib/main.dart @@ -85,7 +85,7 @@ class _MyHomePageState extends State { }; } - Widget _previewVideo(VideoPlayerController controller) { + Widget _previewVideo(VideoPlayerController controller) { if (controller == null) { return const Text( 'You have not yet picked a video', From dd9ef1f1a8dba371c74716289a1046d1cdb26fee Mon Sep 17 00:00:00 2001 From: Rody Davis <31253215+AppleEducate@users.noreply.github.com> Date: Wed, 16 May 2018 10:45:53 -0400 Subject: [PATCH 25/41] Update main.dart --- packages/image_picker/example/lib/main.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/image_picker/example/lib/main.dart b/packages/image_picker/example/lib/main.dart index 02bedebbdb44..c0f20bb0f99a 100755 --- a/packages/image_picker/example/lib/main.dart +++ b/packages/image_picker/example/lib/main.dart @@ -84,7 +84,7 @@ class _MyHomePageState extends State { setState(() {}); }; } - + Widget _previewVideo(VideoPlayerController controller) { if (controller == null) { return const Text( From 111d5688c738ed311136521d4c4b40ad4211a4c4 Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Thu, 24 May 2018 08:06:07 -0400 Subject: [PATCH 26/41] Updating Project with PR Changes --- packages/image_picker/.vscode/launch.json | 14 ----------- packages/image_picker/.vscode/settings.json | 3 --- packages/image_picker/android/.classpath | 6 +++++ packages/image_picker/android/.project | 23 +++++++++++++++++++ .../org.eclipse.buildship.core.prefs | 2 ++ .../image_picker/example/android/.project | 17 ++++++++++++++ .../org.eclipse.buildship.core.prefs | 2 ++ .../example/android/app/.classpath | 6 +++++ .../image_picker/example/android/app/.project | 23 +++++++++++++++++++ .../org.eclipse.buildship.core.prefs | 2 ++ .../ios/Runner.xcodeproj/project.pbxproj | 2 -- .../ios/Classes/ImagePickerPlugin.m | 1 - packages/image_picker/lib/image_picker.dart | 8 +++---- 13 files changed, 85 insertions(+), 24 deletions(-) delete mode 100644 packages/image_picker/.vscode/launch.json delete mode 100644 packages/image_picker/.vscode/settings.json create mode 100644 packages/image_picker/android/.classpath create mode 100644 packages/image_picker/android/.project create mode 100644 packages/image_picker/android/.settings/org.eclipse.buildship.core.prefs create mode 100644 packages/image_picker/example/android/.project create mode 100644 packages/image_picker/example/android/.settings/org.eclipse.buildship.core.prefs create mode 100644 packages/image_picker/example/android/app/.classpath create mode 100644 packages/image_picker/example/android/app/.project create mode 100644 packages/image_picker/example/android/app/.settings/org.eclipse.buildship.core.prefs diff --git a/packages/image_picker/.vscode/launch.json b/packages/image_picker/.vscode/launch.json deleted file mode 100644 index 3b9020740c36..000000000000 --- a/packages/image_picker/.vscode/launch.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Flutter", - "type": "dart", - "request": "launch", - "program": "${workspaceFolder}/example//lib/main.dart" - } - ] -} \ No newline at end of file diff --git a/packages/image_picker/.vscode/settings.json b/packages/image_picker/.vscode/settings.json deleted file mode 100644 index b52fc7b87bda..000000000000 --- a/packages/image_picker/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "dart.promptToUpgradeWorkspace": true -} \ No newline at end of file diff --git a/packages/image_picker/android/.classpath b/packages/image_picker/android/.classpath new file mode 100644 index 000000000000..8d8d85f14359 --- /dev/null +++ b/packages/image_picker/android/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/packages/image_picker/android/.project b/packages/image_picker/android/.project new file mode 100644 index 000000000000..605b6710c6ee --- /dev/null +++ b/packages/image_picker/android/.project @@ -0,0 +1,23 @@ + + + image_picker + Project image_picker created by Buildship. + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.buildship.core.gradleprojectnature + + diff --git a/packages/image_picker/android/.settings/org.eclipse.buildship.core.prefs b/packages/image_picker/android/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 000000000000..9507f7262739 --- /dev/null +++ b/packages/image_picker/android/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1,2 @@ +#Thu May 24 08:04:53 EDT 2018 +connection.project.dir=../example/android diff --git a/packages/image_picker/example/android/.project b/packages/image_picker/example/android/.project new file mode 100644 index 000000000000..3964dd3f5b7f --- /dev/null +++ b/packages/image_picker/example/android/.project @@ -0,0 +1,17 @@ + + + android + Project android created by Buildship. + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + + org.eclipse.buildship.core.gradleprojectnature + + diff --git a/packages/image_picker/example/android/.settings/org.eclipse.buildship.core.prefs b/packages/image_picker/example/android/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 000000000000..cf80293fe780 --- /dev/null +++ b/packages/image_picker/example/android/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1,2 @@ +#Thu May 24 08:04:52 EDT 2018 +connection.project.dir= diff --git a/packages/image_picker/example/android/app/.classpath b/packages/image_picker/example/android/app/.classpath new file mode 100644 index 000000000000..8d8d85f14359 --- /dev/null +++ b/packages/image_picker/example/android/app/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/packages/image_picker/example/android/app/.project b/packages/image_picker/example/android/app/.project new file mode 100644 index 000000000000..ac485d7c3e62 --- /dev/null +++ b/packages/image_picker/example/android/app/.project @@ -0,0 +1,23 @@ + + + app + Project app created by Buildship. + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.buildship.core.gradleprojectnature + + diff --git a/packages/image_picker/example/android/app/.settings/org.eclipse.buildship.core.prefs b/packages/image_picker/example/android/app/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 000000000000..c2b186573e0a --- /dev/null +++ b/packages/image_picker/example/android/app/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1,2 @@ +#Thu May 24 08:04:52 EDT 2018 +connection.project.dir=.. diff --git a/packages/image_picker/example/ios/Runner.xcodeproj/project.pbxproj b/packages/image_picker/example/ios/Runner.xcodeproj/project.pbxproj index 4e39ad7cf662..0e61475aa5c7 100644 --- a/packages/image_picker/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/image_picker/example/ios/Runner.xcodeproj/project.pbxproj @@ -438,7 +438,6 @@ buildSettings = { ARCHS = arm64; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = 9FK3425VTA; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -461,7 +460,6 @@ buildSettings = { ARCHS = arm64; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = 9FK3425VTA; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", diff --git a/packages/image_picker/ios/Classes/ImagePickerPlugin.m b/packages/image_picker/ios/Classes/ImagePickerPlugin.m index 12bb8cbf70b0..e65bf4e48d2b 100644 --- a/packages/image_picker/ios/Classes/ImagePickerPlugin.m +++ b/packages/image_picker/ios/Classes/ImagePickerPlugin.m @@ -1,4 +1,3 @@ - // Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. diff --git a/packages/image_picker/lib/image_picker.dart b/packages/image_picker/lib/image_picker.dart index ad7f8018816e..953fd451f062 100755 --- a/packages/image_picker/lib/image_picker.dart +++ b/packages/image_picker/lib/image_picker.dart @@ -37,11 +37,11 @@ class ImagePicker { assert(source != null); if (maxWidth != null && maxWidth < 0) { - throw new ArgumentError.value(maxWidth, 'maxWidth can\'t be negative'); + throw new ArgumentError.value(maxWidth, 'maxWidth cannot be negative'); } if (maxHeight != null && maxHeight < 0) { - throw new ArgumentError.value(maxHeight, 'maxHeight can\'t be negative'); + throw new ArgumentError.value(maxHeight, 'maxHeight cannot be negative'); } final String path = await _channel.invokeMethod( @@ -64,11 +64,11 @@ class ImagePicker { assert(source != null); if (maxWidth != null && maxWidth < 0) { - throw new ArgumentError.value(maxWidth, 'maxWidth can\'t be negative'); + throw new ArgumentError.value(maxWidth, 'maxWidth cannot be negative'); } if (maxHeight != null && maxHeight < 0) { - throw new ArgumentError.value(maxHeight, 'maxHeight can\'t be negative'); + throw new ArgumentError.value(maxHeight, 'maxHeight cannot be negative'); } final String path = await _channel.invokeMethod( From 16ea63810d08e2cac305b5de6d434a6649c52158 Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Thu, 24 May 2018 08:06:53 -0400 Subject: [PATCH 27/41] Ignoring .vscode files --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 53c12025dc32..4a0163cda5c4 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,6 @@ GeneratedPluginRegistrant.m GeneratedPluginRegistrant.java -.dart_tool \ No newline at end of file +.dart_tool +packages/image_picker/.vscode/launch.json +packages/image_picker/.vscode/settings.json From 2a3028500cafa24d63fab836eb0bee7ba48b0054 Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Thu, 24 May 2018 08:08:58 -0400 Subject: [PATCH 28/41] Removing Comments and Updating Changelog --- packages/image_picker/CHANGELOG.md | 4 ++-- .../io/flutter/plugins/imagepicker/ImagePickerDelegate.java | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/packages/image_picker/CHANGELOG.md b/packages/image_picker/CHANGELOG.md index e7ec4fb02ab3..feac368d66d5 100644 --- a/packages/image_picker/CHANGELOG.md +++ b/packages/image_picker/CHANGELOG.md @@ -1,7 +1,7 @@ ## 0.4.2 -* Added Video Capability with `pickVideo`. -* Updated Example for Preview of Video Captured +* Added support for picking videos. +* Updated example app to show video preview. ## 0.4.1 diff --git a/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java b/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java index 1450cbcaf449..65812d2f7a6c 100644 --- a/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java +++ b/packages/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java @@ -180,8 +180,6 @@ public void onScanCompleted(String path, Uri uri) { this.fileUtils = fileUtils; } - // -- Video -- - // Choose Video From Gallery public void chooseVideoFromGallery(MethodCall methodCall, MethodChannel.Result result) { if (!setPendingMethodCallAndResult(methodCall, result)) { finishWithAlreadyActiveError(); @@ -204,7 +202,6 @@ private void launchPickVideoFromGalleryIntent() { activity.startActivityForResult(pickImageIntent, REQUEST_CODE_CHOOSE_FROM_GALLERY); } - // Take a New Video public void takeVideoWithCamera(MethodCall methodCall, MethodChannel.Result result) { if (!setPendingMethodCallAndResult(methodCall, result)) { finishWithAlreadyActiveError(); @@ -238,8 +235,6 @@ private void launchTakeVideoWithCameraIntent() { activity.startActivityForResult(intent, REQUEST_CODE_TAKE_WITH_CAMERA); } - // -- Photo -- - // Choose Photo from Gallery public void chooseImageFromGallery(MethodCall methodCall, MethodChannel.Result result) { if (!setPendingMethodCallAndResult(methodCall, result)) { finishWithAlreadyActiveError(); @@ -262,7 +257,6 @@ private void launchPickImageFromGalleryIntent() { activity.startActivityForResult(pickImageIntent, REQUEST_CODE_CHOOSE_FROM_GALLERY); } - // Take New Photo public void takeImageWithCamera(MethodCall methodCall, MethodChannel.Result result) { if (!setPendingMethodCallAndResult(methodCall, result)) { finishWithAlreadyActiveError(); From af2d0185c457799590cf8b52a90056d47c600d86 Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Thu, 24 May 2018 08:16:44 -0400 Subject: [PATCH 29/41] Updating Changes for PR --- packages/image_picker/example/lib/main.dart | 12 +++++++----- packages/image_picker/lib/image_picker.dart | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/image_picker/example/lib/main.dart b/packages/image_picker/example/lib/main.dart index c0f20bb0f99a..f1d6cc265f97 100755 --- a/packages/image_picker/example/lib/main.dart +++ b/packages/image_picker/example/lib/main.dart @@ -33,7 +33,7 @@ class MyHomePage extends StatefulWidget { } class _MyHomePageState extends State { - Future _mediaFile; + Future _imageFile; bool isVideo = false; VideoPlayerController _controller; VoidCallback listener; @@ -45,17 +45,19 @@ class _MyHomePageState extends State { _controller.removeListener(listener); } if (isVideo) { - _mediaFile = ImagePicker.pickVideo(source: source).then((File _file) { - _controller = VideoPlayerController.file(_file) + ImagePicker.pickVideo(source: source).then((File file) { + if (file != null) { + _controller = VideoPlayerController.file(file) ..addListener(listener) ..setVolume(1.0) ..initialize() ..setLooping(true) ..play(); setState(() {}); + } }); } else { - _mediaFile = ImagePicker.pickImage(source: source); + _imageFile = ImagePicker.pickImage(source: source); } }); } @@ -106,7 +108,7 @@ class _MyHomePageState extends State { Widget _previewImage() { return FutureBuilder( - future: _mediaFile, + future: _imageFile, builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.connectionState == ConnectionState.done && snapshot.data != null) { diff --git a/packages/image_picker/lib/image_picker.dart b/packages/image_picker/lib/image_picker.dart index 953fd451f062..80f17d717710 100755 --- a/packages/image_picker/lib/image_picker.dart +++ b/packages/image_picker/lib/image_picker.dart @@ -53,7 +53,7 @@ class ImagePicker { }, ); - return path != null ? new File(path) : null; + return path == null ? null : new File(path); } static Future pickVideo({ @@ -79,6 +79,6 @@ class ImagePicker { 'maxHeight': maxHeight, }, ); - return path != null ? new File(path) : null; + return path == null ? null : new File(path); } } From ce609b4eff93af131f4c58d8abce609970303720 Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Thu, 24 May 2018 08:19:21 -0400 Subject: [PATCH 30/41] Fixing Formatting --- packages/image_picker/example/lib/main.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/image_picker/example/lib/main.dart b/packages/image_picker/example/lib/main.dart index f1d6cc265f97..a51e228fe016 100755 --- a/packages/image_picker/example/lib/main.dart +++ b/packages/image_picker/example/lib/main.dart @@ -48,12 +48,12 @@ class _MyHomePageState extends State { ImagePicker.pickVideo(source: source).then((File file) { if (file != null) { _controller = VideoPlayerController.file(file) - ..addListener(listener) - ..setVolume(1.0) - ..initialize() - ..setLooping(true) - ..play(); - setState(() {}); + ..addListener(listener) + ..setVolume(1.0) + ..initialize() + ..setLooping(true) + ..play(); + setState(() {}); } }); } else { From cd7e45ffa3635ff52381796b7a760174e41f441e Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Thu, 24 May 2018 08:25:56 -0400 Subject: [PATCH 31/41] Refactoring for PR --- .../ios/Classes/ImagePickerPlugin.m | 23 ++++++++++--------- packages/image_picker/lib/image_picker.dart | 12 ---------- 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/packages/image_picker/ios/Classes/ImagePickerPlugin.m b/packages/image_picker/ios/Classes/ImagePickerPlugin.m index e65bf4e48d2b..1475f856208c 100644 --- a/packages/image_picker/ios/Classes/ImagePickerPlugin.m +++ b/packages/image_picker/ios/Classes/ImagePickerPlugin.m @@ -129,17 +129,6 @@ - (void)imagePickerController:(UIImagePickerController *)picker NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL]; UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage]; [_imagePickerController dismissViewControllerAnimated:YES completion:nil]; - if (image == nil) { - image = [info objectForKey:UIImagePickerControllerOriginalImage]; - } - image = [self normalizedImage:image]; - - NSNumber *maxWidth = [_arguments objectForKey:@"maxWidth"]; - NSNumber *maxHeight = [_arguments objectForKey:@"maxHeight"]; - - if (maxWidth != (id)[NSNull null] || maxHeight != (id)[NSNull null]) { - image = [self scaledImage:image maxWidth:maxWidth maxHeight:maxHeight]; - } if (videoURL != nil) { NSData *data = [NSData dataWithContentsOfURL:videoURL]; @@ -156,6 +145,18 @@ - (void)imagePickerController:(UIImagePickerController *)picker details:nil]); } } else { + if (image == nil) { + image = [info objectForKey:UIImagePickerControllerOriginalImage]; + } + image = [self normalizedImage:image]; + + NSNumber *maxWidth = [_arguments objectForKey:@"maxWidth"]; + NSNumber *maxHeight = [_arguments objectForKey:@"maxHeight"]; + + if (maxWidth != (id)[NSNull null] || maxHeight != (id)[NSNull null]) { + image = [self scaledImage:image maxWidth:maxWidth maxHeight:maxHeight]; + } + NSData *data = UIImageJPEGRepresentation(image, 1.0); NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; NSString *tmpFile = [NSString stringWithFormat:@"image_picker_%@.jpg", guid]; diff --git a/packages/image_picker/lib/image_picker.dart b/packages/image_picker/lib/image_picker.dart index 80f17d717710..26d09c2c313b 100755 --- a/packages/image_picker/lib/image_picker.dart +++ b/packages/image_picker/lib/image_picker.dart @@ -58,25 +58,13 @@ class ImagePicker { static Future pickVideo({ @required ImageSource source, - double maxWidth, - double maxHeight, }) async { assert(source != null); - if (maxWidth != null && maxWidth < 0) { - throw new ArgumentError.value(maxWidth, 'maxWidth cannot be negative'); - } - - if (maxHeight != null && maxHeight < 0) { - throw new ArgumentError.value(maxHeight, 'maxHeight cannot be negative'); - } - final String path = await _channel.invokeMethod( 'pickVideo', { 'source': source.index, - 'maxWidth': maxWidth, - 'maxHeight': maxHeight, }, ); return path == null ? null : new File(path); From d56aa5a0cc7d44fe8f2cbe1e5d06b8acc98a422b Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Thu, 24 May 2018 08:29:13 -0400 Subject: [PATCH 32/41] Updating Format --- .../ios/Classes/ImagePickerPlugin.m | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/image_picker/ios/Classes/ImagePickerPlugin.m b/packages/image_picker/ios/Classes/ImagePickerPlugin.m index 1475f856208c..a01665995b21 100644 --- a/packages/image_picker/ios/Classes/ImagePickerPlugin.m +++ b/packages/image_picker/ios/Classes/ImagePickerPlugin.m @@ -145,17 +145,17 @@ - (void)imagePickerController:(UIImagePickerController *)picker details:nil]); } } else { - if (image == nil) { - image = [info objectForKey:UIImagePickerControllerOriginalImage]; - } - image = [self normalizedImage:image]; + if (image == nil) { + image = [info objectForKey:UIImagePickerControllerOriginalImage]; + } + image = [self normalizedImage:image]; - NSNumber *maxWidth = [_arguments objectForKey:@"maxWidth"]; - NSNumber *maxHeight = [_arguments objectForKey:@"maxHeight"]; + NSNumber *maxWidth = [_arguments objectForKey:@"maxWidth"]; + NSNumber *maxHeight = [_arguments objectForKey:@"maxHeight"]; - if (maxWidth != (id)[NSNull null] || maxHeight != (id)[NSNull null]) { - image = [self scaledImage:image maxWidth:maxWidth maxHeight:maxHeight]; - } + if (maxWidth != (id)[NSNull null] || maxHeight != (id)[NSNull null]) { + image = [self scaledImage:image maxWidth:maxWidth maxHeight:maxHeight]; + } NSData *data = UIImageJPEGRepresentation(image, 1.0); NSString *guid = [[NSProcessInfo processInfo] globallyUniqueString]; From e4c025ba8f8a12034e89d202435b31c1e34b039f Mon Sep 17 00:00:00 2001 From: Rody Davis <31253215+AppleEducate@users.noreply.github.com> Date: Fri, 25 May 2018 07:33:24 -0400 Subject: [PATCH 33/41] Update .gitignore --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 4a0163cda5c4..598fc745057d 100644 --- a/.gitignore +++ b/.gitignore @@ -13,5 +13,4 @@ GeneratedPluginRegistrant.m GeneratedPluginRegistrant.java .dart_tool -packages/image_picker/.vscode/launch.json -packages/image_picker/.vscode/settings.json +.vscode/ From 5a580bf3389770cd9fe0a429a7292560399279b4 Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Fri, 25 May 2018 07:38:03 -0400 Subject: [PATCH 34/41] Updating Set State --- packages/image_picker/example/lib/main.dart | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/image_picker/example/lib/main.dart b/packages/image_picker/example/lib/main.dart index a51e228fe016..2ede3de5c49a 100755 --- a/packages/image_picker/example/lib/main.dart +++ b/packages/image_picker/example/lib/main.dart @@ -46,14 +46,15 @@ class _MyHomePageState extends State { } if (isVideo) { ImagePicker.pickVideo(source: source).then((File file) { - if (file != null) { - _controller = VideoPlayerController.file(file) - ..addListener(listener) - ..setVolume(1.0) - ..initialize() - ..setLooping(true) - ..play(); - setState(() {}); + if (file != null && mounted) { + setState(() { + _controller = VideoPlayerController.file(file) + ..addListener(listener) + ..setVolume(1.0) + ..initialize() + ..setLooping(true) + ..play(); + }); } }); } else { From 8161e02721abed1bc87662691ab7ea97924aa84e Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Fri, 25 May 2018 07:38:23 -0400 Subject: [PATCH 35/41] Removing .settings .project .classpath --- packages/image_picker/android/.classpath | 6 ----- packages/image_picker/android/.project | 23 ------------------- .../org.eclipse.buildship.core.prefs | 2 -- 3 files changed, 31 deletions(-) delete mode 100644 packages/image_picker/android/.classpath delete mode 100644 packages/image_picker/android/.project delete mode 100644 packages/image_picker/android/.settings/org.eclipse.buildship.core.prefs diff --git a/packages/image_picker/android/.classpath b/packages/image_picker/android/.classpath deleted file mode 100644 index 8d8d85f14359..000000000000 --- a/packages/image_picker/android/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/packages/image_picker/android/.project b/packages/image_picker/android/.project deleted file mode 100644 index 605b6710c6ee..000000000000 --- a/packages/image_picker/android/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - image_picker - Project image_picker created by Buildship. - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.buildship.core.gradleprojectbuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.buildship.core.gradleprojectnature - - diff --git a/packages/image_picker/android/.settings/org.eclipse.buildship.core.prefs b/packages/image_picker/android/.settings/org.eclipse.buildship.core.prefs deleted file mode 100644 index 9507f7262739..000000000000 --- a/packages/image_picker/android/.settings/org.eclipse.buildship.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -#Thu May 24 08:04:53 EDT 2018 -connection.project.dir=../example/android From f8ffc377d52a48ba205f4270cc13609a10ead450 Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Fri, 25 May 2018 08:26:24 -0400 Subject: [PATCH 36/41] Removing Files --- .../image_picker/example/.vscode/launch.json | 19 --------------- .../image_picker/example/android/.project | 17 -------------- .../org.eclipse.buildship.core.prefs | 2 -- .../example/android/app/.classpath | 6 ----- .../image_picker/example/android/app/.project | 23 ------------------- .../org.eclipse.buildship.core.prefs | 2 -- 6 files changed, 69 deletions(-) delete mode 100644 packages/image_picker/example/.vscode/launch.json delete mode 100644 packages/image_picker/example/android/.project delete mode 100644 packages/image_picker/example/android/.settings/org.eclipse.buildship.core.prefs delete mode 100644 packages/image_picker/example/android/app/.classpath delete mode 100644 packages/image_picker/example/android/app/.project delete mode 100644 packages/image_picker/example/android/app/.settings/org.eclipse.buildship.core.prefs diff --git a/packages/image_picker/example/.vscode/launch.json b/packages/image_picker/example/.vscode/launch.json deleted file mode 100644 index 2cdeaef712bf..000000000000 --- a/packages/image_picker/example/.vscode/launch.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Flutter", - "type": "dart", - "request": "launch", - "program": "${workspaceFolder}/lib/main.dart" - }, - { - "name": "Flutter", - "request": "launch", - "type": "dart" - } - ] -} \ No newline at end of file diff --git a/packages/image_picker/example/android/.project b/packages/image_picker/example/android/.project deleted file mode 100644 index 3964dd3f5b7f..000000000000 --- a/packages/image_picker/example/android/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - android - Project android created by Buildship. - - - - - org.eclipse.buildship.core.gradleprojectbuilder - - - - - - org.eclipse.buildship.core.gradleprojectnature - - diff --git a/packages/image_picker/example/android/.settings/org.eclipse.buildship.core.prefs b/packages/image_picker/example/android/.settings/org.eclipse.buildship.core.prefs deleted file mode 100644 index cf80293fe780..000000000000 --- a/packages/image_picker/example/android/.settings/org.eclipse.buildship.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -#Thu May 24 08:04:52 EDT 2018 -connection.project.dir= diff --git a/packages/image_picker/example/android/app/.classpath b/packages/image_picker/example/android/app/.classpath deleted file mode 100644 index 8d8d85f14359..000000000000 --- a/packages/image_picker/example/android/app/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/packages/image_picker/example/android/app/.project b/packages/image_picker/example/android/app/.project deleted file mode 100644 index ac485d7c3e62..000000000000 --- a/packages/image_picker/example/android/app/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - app - Project app created by Buildship. - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.buildship.core.gradleprojectbuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.buildship.core.gradleprojectnature - - diff --git a/packages/image_picker/example/android/app/.settings/org.eclipse.buildship.core.prefs b/packages/image_picker/example/android/app/.settings/org.eclipse.buildship.core.prefs deleted file mode 100644 index c2b186573e0a..000000000000 --- a/packages/image_picker/example/android/app/.settings/org.eclipse.buildship.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -#Thu May 24 08:04:52 EDT 2018 -connection.project.dir=.. From b39d2fa0f61e7d50d120a69a75620eeab246d71c Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Fri, 25 May 2018 08:32:12 -0400 Subject: [PATCH 37/41] Updating Example --- packages/image_picker/example/lib/main.dart | 251 +------------------- 1 file changed, 2 insertions(+), 249 deletions(-) diff --git a/packages/image_picker/example/lib/main.dart b/packages/image_picker/example/lib/main.dart index 2ede3de5c49a..48e120617b97 100755 --- a/packages/image_picker/example/lib/main.dart +++ b/packages/image_picker/example/lib/main.dart @@ -230,258 +230,11 @@ class AspectRatioVideoState extends State { return new Center( child: new AspectRatio( aspectRatio: size.width / size.height, - child: new VideoPlayPause(controller), + child: new VideoPlayer(controller), ), ); } else { return new Container(); } } -} - -class VideoPlayPause extends StatefulWidget { - final VideoPlayerController controller; - - VideoPlayPause(this.controller); - - @override - State createState() { - return new _VideoPlayPauseState(); - } -} - -class _VideoPlayPauseState extends State { - FadeAnimation imageFadeAnim = - new FadeAnimation(child: const Icon(Icons.play_arrow, size: 100.0)); - VoidCallback listener; - - _VideoPlayPauseState() { - listener = () { - setState(() {}); - }; - } - - VideoPlayerController get controller => widget.controller; - - @override - void initState() { - super.initState(); - controller.addListener(listener); - controller.setVolume(1.0); - controller.play(); - } - - @override - void deactivate() { - controller.setVolume(0.0); - controller.removeListener(listener); - super.deactivate(); - } - - @override - Widget build(BuildContext context) { - final List children = [ - new GestureDetector( - child: new VideoPlayer(controller), - onTap: () { - if (!controller.value.initialized) { - return; - } - if (controller.value.isPlaying) { - imageFadeAnim = - new FadeAnimation(child: const Icon(Icons.pause, size: 100.0)); - controller.pause(); - } else { - imageFadeAnim = new FadeAnimation( - child: const Icon(Icons.play_arrow, size: 100.0)); - controller.play(); - } - }, - ), - new Align( - alignment: Alignment.bottomCenter, - child: new VideoProgressIndicator( - controller, - allowScrubbing: true, - ), - ), - new Center(child: imageFadeAnim), - ]; - - return new Stack( - fit: StackFit.passthrough, - children: children, - ); - } -} - -class FadeAnimation extends StatefulWidget { - final Widget child; - final Duration duration; - - FadeAnimation({this.child, this.duration: const Duration(milliseconds: 500)}); - - @override - _FadeAnimationState createState() => new _FadeAnimationState(); -} - -class _FadeAnimationState extends State - with SingleTickerProviderStateMixin { - AnimationController animationController; - - @override - void initState() { - super.initState(); - animationController = - new AnimationController(duration: widget.duration, vsync: this); - animationController.addListener(() { - if (mounted) { - setState(() {}); - } - }); - animationController.forward(from: 0.0); - } - - @override - void deactivate() { - animationController.stop(); - super.deactivate(); - } - - @override - void didUpdateWidget(FadeAnimation oldWidget) { - super.didUpdateWidget(oldWidget); - if (oldWidget.child != widget.child) { - animationController.forward(from: 0.0); - } - } - - @override - void dispose() { - animationController.dispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - return animationController.isAnimating - ? new Opacity( - opacity: 1.0 - animationController.value, - child: widget.child, - ) - : new Container(); - } -} - -typedef Widget VideoWidgetBuilder( - BuildContext context, VideoPlayerController controller); - -abstract class PlayerLifeCycle extends StatefulWidget { - final VideoWidgetBuilder childBuilder; - final String dataSource; - - PlayerLifeCycle(this.dataSource, this.childBuilder); -} - -/// A widget connecting its life cycle to a [VideoPlayerController] using -/// a data source from the network. -class NetworkPlayerLifeCycle extends PlayerLifeCycle { - NetworkPlayerLifeCycle(String dataSource, VideoWidgetBuilder childBuilder) - : super(dataSource, childBuilder); - - @override - _NetworkPlayerLifeCycleState createState() => - new _NetworkPlayerLifeCycleState(); -} - -/// A widget connecting its life cycle to a [VideoPlayerController] using -/// an asset as data source -class AssetPlayerLifeCycle extends PlayerLifeCycle { - AssetPlayerLifeCycle(String dataSource, VideoWidgetBuilder childBuilder) - : super(dataSource, childBuilder); - - @override - _AssetPlayerLifeCycleState createState() => new _AssetPlayerLifeCycleState(); -} - -abstract class _PlayerLifeCycleState extends State { - VideoPlayerController controller; - - @override - - /// Subclasses should implement [createVideoPlayerController], which is used - /// by this method. - void initState() { - super.initState(); - controller = createVideoPlayerController(); - controller.addListener(() { - if (controller.value.hasError) { - print(controller.value.errorDescription); - } - }); - controller.initialize(); - controller.setLooping(true); - controller.play(); - } - - @override - void deactivate() { - super.deactivate(); - } - - @override - void dispose() { - controller.dispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - return widget.childBuilder(context, controller); - } - - VideoPlayerController createVideoPlayerController(); -} - -class _NetworkPlayerLifeCycleState extends _PlayerLifeCycleState { - @override - VideoPlayerController createVideoPlayerController() { - return new VideoPlayerController.network(widget.dataSource); - } -} - -class _AssetPlayerLifeCycleState extends _PlayerLifeCycleState { - @override - VideoPlayerController createVideoPlayerController() { - return new VideoPlayerController.asset(widget.dataSource); - } -} - -/// A filler card to show the video in a list of scrolling contents. -Widget buildCard(String title) { - return new Card( - child: new Column( - mainAxisSize: MainAxisSize.min, - children: [ - new ListTile( - leading: const Icon(Icons.airline_seat_flat_angled), - title: new Text(title), - ), - new ButtonTheme.bar( - child: new ButtonBar( - children: [ - new FlatButton( - child: const Text('BUY TICKETS'), - onPressed: () {/* ... */}, - ), - new FlatButton( - child: const Text('SELL TICKETS'), - onPressed: () {/* ... */}, - ), - ], - ), - ), - ], - ), - ); -} +} \ No newline at end of file From 9f73d2d7796965d795472627ac6f02e6cd524804 Mon Sep 17 00:00:00 2001 From: Rody Davis Date: Fri, 25 May 2018 08:37:01 -0400 Subject: [PATCH 38/41] Adding Line --- packages/image_picker/example/lib/main.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/image_picker/example/lib/main.dart b/packages/image_picker/example/lib/main.dart index 48e120617b97..e0312f9ed660 100755 --- a/packages/image_picker/example/lib/main.dart +++ b/packages/image_picker/example/lib/main.dart @@ -237,4 +237,4 @@ class AspectRatioVideoState extends State { return new Container(); } } -} \ No newline at end of file +} From 1ce00fbdb7a403b7edb381cdd9d40348da7f2ee7 Mon Sep 17 00:00:00 2001 From: Rody Davis <31253215+AppleEducate@users.noreply.github.com> Date: Fri, 25 May 2018 13:07:22 -0400 Subject: [PATCH 39/41] Update .gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5fc1311c6ab4..73ee12395d8a 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,5 @@ gradle-wrapper.jar GeneratedPluginRegistrant.h GeneratedPluginRegistrant.m GeneratedPluginRegistrant.java - build/ .flutter-plugins From f9621308aab87025024ce55561633b3a7f084a8e Mon Sep 17 00:00:00 2001 From: Rody Davis <31253215+AppleEducate@users.noreply.github.com> Date: Fri, 25 May 2018 13:11:27 -0400 Subject: [PATCH 40/41] Update main.dart --- packages/image_picker/example/lib/main.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/image_picker/example/lib/main.dart b/packages/image_picker/example/lib/main.dart index e0312f9ed660..a4f5ccbc25a4 100755 --- a/packages/image_picker/example/lib/main.dart +++ b/packages/image_picker/example/lib/main.dart @@ -238,3 +238,4 @@ class AspectRatioVideoState extends State { } } } + From 494de6330266f1c72016a4e1cdc3ab7eb7fc0aa8 Mon Sep 17 00:00:00 2001 From: Rody Davis <31253215+AppleEducate@users.noreply.github.com> Date: Fri, 25 May 2018 13:19:24 -0400 Subject: [PATCH 41/41] Update main.dart --- packages/image_picker/example/lib/main.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/image_picker/example/lib/main.dart b/packages/image_picker/example/lib/main.dart index a4f5ccbc25a4..e0312f9ed660 100755 --- a/packages/image_picker/example/lib/main.dart +++ b/packages/image_picker/example/lib/main.dart @@ -238,4 +238,3 @@ class AspectRatioVideoState extends State { } } } -