diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index 25b0139..80303ae 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"image_picker_ios","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker_ios-0.8.5+6\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"flutter_plugin_android_lifecycle","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-2.0.7\\\\","native_build":true,"dependencies":[]},{"name":"image_picker_android","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker_android-0.8.5+2\\\\","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"]}],"macos":[],"linux":[],"windows":[],"web":[{"name":"image_picker_for_web","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker_for_web-2.1.8\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"image_picker","dependencies":["image_picker_android","image_picker_for_web","image_picker_ios"]},{"name":"image_picker_android","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"image_picker_for_web","dependencies":[]},{"name":"image_picker_ios","dependencies":[]}],"date_created":"2022-08-30 16:05:56.456110","version":"3.0.5"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"image_picker_ios","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker_ios-0.8.5+6\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"flutter_plugin_android_lifecycle","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-2.0.7\\\\","native_build":true,"dependencies":[]},{"name":"image_picker_android","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker_android-0.8.5+2\\\\","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"]}],"macos":[],"linux":[],"windows":[],"web":[{"name":"image_picker_for_web","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker_for_web-2.1.8\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"image_picker","dependencies":["image_picker_android","image_picker_for_web","image_picker_ios"]},{"name":"image_picker_android","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"image_picker_for_web","dependencies":[]},{"name":"image_picker_ios","dependencies":[]}],"date_created":"2022-08-31 11:35:04.576524","version":"3.0.5"} \ No newline at end of file diff --git a/example/lib/main.dart b/example/lib/main.dart index fc44533..14b280b 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -37,6 +37,7 @@ class ImagePickerExampleHomePage extends StatefulWidget { class _ImagePickerExampleHomePageState extends State { Uint8List? image; + ImagePicker imagePicker = ImagePicker(); @override Widget build(BuildContext context) { @@ -61,7 +62,7 @@ class _ImagePickerExampleHomePageState 'Pick or make an Image/Photo!', ), ElevatedButton( - onPressed: onPressed, child: const Text('Pick Image')) + onPressed: pickImage, child: const Text('Pick Image')) ], ), ), @@ -69,8 +70,7 @@ class _ImagePickerExampleHomePageState ); } - void onPressed() async { - ImagePicker imagePicker = ImagePicker(); + void pickImage() async { Uint8List? imageInBytes = await imagePicker.showPickImageDialog(context); if (imageInBytes != null) { setState(() { diff --git a/lib/src/screens/image_picker_ui.dart b/lib/src/screens/image_picker_ui.dart index 2634350..bcfd382 100644 --- a/lib/src/screens/image_picker_ui.dart +++ b/lib/src/screens/image_picker_ui.dart @@ -6,41 +6,52 @@ import 'package:image_picker/image_picker.dart'; class ImagePickerUI { final ImagePickerService _imagePickerService = ImagePickerService(); + final double iconSize = 125; Future pickImageDialog(BuildContext context) async { - return await showDialog( + return await showModalBottomSheet( context: context, - barrierDismissible: true, builder: (BuildContext context) { - return AlertDialog( - title: const Text('Image Picker'), - content: SingleChildScrollView( - child: ListBody( - children: const [ - Text( - 'Do you want to choose an existing image or make a new picture with the camera?'), - ], - ), + return Row(mainAxisAlignment: MainAxisAlignment.center, children: [ + Column( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + icon: const Icon(Icons.image), + tooltip: 'Choose Image From Gallery', + iconSize: iconSize, + onPressed: () => + _imagePickerService.pickImage(ImageSource.gallery, context), + ), + const Text("Select file"), + ], ), - actions: [ - ElevatedButton( - onPressed: () => - _imagePickerService.pickImage(ImageSource.gallery, context), - child: const Text('Pick image from Gallery'), - ), - ElevatedButton( - onPressed: () => - _imagePickerService.pickImage(ImageSource.camera, context), - child: const Text('Make picture with Camera'), - ), - TextButton( - child: const Text('Close Dialog'), - onPressed: () async { - Navigator.of(context).pop(); - }, - ), - ], - ); + + Column( + mainAxisSize: MainAxisSize.min, + children: [ + IconButton( + icon: const Icon(Icons.camera_alt_rounded), + tooltip: 'Make Image With Camera', + iconSize: iconSize, + onPressed: () => + _imagePickerService.pickImage(ImageSource.camera, context), + ), + const Text("Take a picture"), + ], + ), + // ElevatedButton( + // onPressed: () => + // _imagePickerService.pickImage(ImageSource.gallery, context), + // child: const Text('Gallery'), + // ), + // const SizedBox(width: 10), + // ElevatedButton( + // onPressed: () => + // _imagePickerService.pickImage(ImageSource.camera, context), + // child: const Text('Camera'), + // ), + ]); }, ); }