From 9402136b5d81ccf333641fd66056ac205948d8f8 Mon Sep 17 00:00:00 2001 From: Stein Milder Date: Fri, 30 Sep 2022 09:27:02 +0200 Subject: [PATCH 1/4] fix: stateful or stateless widget as customButton --- lib/src/ui/image_picker.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/ui/image_picker.dart b/lib/src/ui/image_picker.dart index 39030e7..ccca601 100644 --- a/lib/src/ui/image_picker.dart +++ b/lib/src/ui/image_picker.dart @@ -20,7 +20,7 @@ class ImagePicker extends StatelessWidget { final ImagePickerTheme imagePickerTheme; /// The Image Picker Dialog can have a custom button if you want to. - final StatelessWidget? customButton; + final Widget? customButton; /// The ImagePickerService can be used if you want to use your own implementation of the Image Service if you want to use it for testing or add more features. If null the current implementation will be used. final ImagePickerService? imagePickerService; From c8a837b2499b7a72d7dc10c58023fb464407ac3c Mon Sep 17 00:00:00 2001 From: commitimpush Date: Fri, 7 Oct 2022 09:12:03 +0200 Subject: [PATCH 2/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0359618..557ba6c 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ Please file any issues, bugs or feature request as an issue on our [GitHub](http ## Want to contribute -If you would like to contribute to the plugin (e.g. by improving the documentation, solving a bug or adding a cool new feature), please carefully review our [contribution guide](../CONTRIBUTING.md) and send us your [pull request](URL TO PULL REQUEST TAB IN REPO). +If you would like to contribute to the plugin (e.g. by improving the documentation, solving a bug or adding a cool new feature), please carefully review our [contribution guide](../CONTRIBUTING.md) and send us your [pull request](https://github.com/Iconica-Development/flutter_image_picker/pulls). ## Author From ae2cc3347939c29723dd7aab0eb827ef741276bf Mon Sep 17 00:00:00 2001 From: Freek van de Ven Date: Fri, 21 Oct 2022 16:21:06 +0200 Subject: [PATCH 3/4] feat: added ImagePickerService interface --- CHANGELOG.md | 4 +++ example/pubspec.lock | 2 +- lib/flutter_image_picker.dart | 1 + lib/src/services/image_picker_service.dart | 13 +++++-- lib/src/ui/image_picker.dart | 17 ++++----- pubspec.yaml | 40 ++-------------------- 6 files changed, 29 insertions(+), 48 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8394762..39b5d78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,3 +20,7 @@ ## 1.0.0 - September 26th 2022 - Icons can be changed by Widgets instead of IconData. + +## 1.0.2 - Oktober 21st 2022 + +- ImagePickerService can be correctly injected into the widget. \ No newline at end of file diff --git a/example/pubspec.lock b/example/pubspec.lock index 3c87037..cc1a00f 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -68,7 +68,7 @@ packages: path: ".." relative: true source: path - version: "1.0.0" + version: "1.0.3" flutter_lints: dependency: "direct dev" description: diff --git a/lib/flutter_image_picker.dart b/lib/flutter_image_picker.dart index f503bfd..160c0e7 100644 --- a/lib/flutter_image_picker.dart +++ b/lib/flutter_image_picker.dart @@ -1,4 +1,5 @@ library flutter_image_picker; +export 'src/services/image_picker_service.dart'; export 'src/models/image_picker_theme.dart'; export 'src/ui/image_picker.dart'; diff --git a/lib/src/services/image_picker_service.dart b/lib/src/services/image_picker_service.dart index a4c1670..c37d9b9 100644 --- a/lib/src/services/image_picker_service.dart +++ b/lib/src/services/image_picker_service.dart @@ -4,14 +4,23 @@ import 'package:image_picker/image_picker.dart'; /// The Image Picker Service class is the functionality of the Image Picker package which uses the Image Picker package to choose an image. /// If you have your own implementation of the Image Picker you can add it to the constructor when creating the class. -class ImagePickerService { - ImagePickerService({this.imagePicker}); +abstract class ImagePickerService { + /// [pickImage] is the function that picks the image and returns it as a [Uint8List]. + /// The function requires [source], an [ImageSource] + Future pickImage(ImageSource source); +} + +/// The ImagePickerServiceDefault is the default implementation of the ImagePickerService. +/// It uses the Image Picker package to pick an image and returns it as a [Uint8List]. +class ImagePickerServiceDefault implements ImagePickerService { + ImagePickerServiceDefault({this.imagePicker}); /// It's possible to have your own implementation for the Image Picker if you don't want to use the Image Picker Package. ImagePicker? imagePicker; /// [pickImage] is the function that picks the image and returns it as a [Uint8List]. /// The function requires [source], an [ImageSource] that's the method of how the image needs to be picked, for example gallery or camera. + @override Future pickImage(ImageSource source) async { var image = await (await (imagePicker ?? ImagePicker()).pickImage(source: source)) diff --git a/lib/src/ui/image_picker.dart b/lib/src/ui/image_picker.dart index ccca601..d22e39c 100644 --- a/lib/src/ui/image_picker.dart +++ b/lib/src/ui/image_picker.dart @@ -9,12 +9,12 @@ import '../models/image_picker_theme.dart'; /// The second one is your own implementation of the ImagePickerService. Which can be used in testing for example. /// The third one is a custom Button widget. class ImagePicker extends StatelessWidget { - const ImagePicker( - {Key? key, - this.imagePickerTheme = const ImagePickerTheme(), - this.imagePickerService, - this.customButton}) - : super(key: key); + const ImagePicker({ + this.imagePickerTheme = const ImagePickerTheme(), + this.imagePickerService, + this.customButton, + super.key, + }); /// ImagePickerTheme can be used to change the UI of the Image Picker Widget to change the text/icons to your liking. final ImagePickerTheme imagePickerTheme; @@ -119,8 +119,9 @@ class ImagePicker extends StatelessWidget { key: Key(bottomText), onTap: () async { final navigator = Navigator.of(context); - var image = await (imagePickerService ?? ImagePickerService()) - .pickImage(imageSource); + var image = + await (imagePickerService ?? ImagePickerServiceDefault()) + .pickImage(imageSource); navigator.pop(image); }, child: customIcon ?? diff --git a/pubspec.yaml b/pubspec.yaml index 2871c75..790e63c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: flutter_image_picker -description: A new Flutter package project. -version: 1.0.0 -homepage: https://github.com/Iconica-Development/flutter_image_picker +description: A Flutter Image Picking package. +version: 1.0.3 +repository: https://github.com/Iconica-Development/flutter_image_picker environment: sdk: ">=2.17.6 <3.0.0" @@ -18,38 +18,4 @@ dev_dependencies: flutter_lints: ^2.0.0 mocktail: ^0.3.0 -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter packages. flutter: - # To add assets to your package, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # - # For details regarding assets in packages, see - # https://flutter.dev/assets-and-images/#from-packages - # - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware - - # To add custom fonts to your package, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts in packages, see - # https://flutter.dev/custom-fonts/#from-packages From 437bf79385229cb613422c525682d641011978dd Mon Sep 17 00:00:00 2001 From: Bart Ribbers Date: Tue, 1 Nov 2022 08:24:41 +0100 Subject: [PATCH 4/4] Add BSD-3-Clause license --- LICENSE | 9 +++++++++ example/lib/main.dart | 4 ++++ lib/flutter_image_picker.dart | 4 ++++ lib/src/models/image_picker_theme.dart | 4 ++++ lib/src/services/image_picker_service.dart | 4 ++++ lib/src/ui/image_picker.dart | 4 ++++ test/image_picker_ui_test.dart | 4 ++++ test/mocks/image_picker_service_mock.dart | 4 ++++ 8 files changed, 37 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fe891f8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +Copyright (c) 2022 Iconica, All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/example/lib/main.dart b/example/lib/main.dart index 7f2c28e..66f03b1 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2022 Iconica +// +// SPDX-License-Identifier: BSD-3-Clause + import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_image_picker/flutter_image_picker.dart'; diff --git a/lib/flutter_image_picker.dart b/lib/flutter_image_picker.dart index 160c0e7..4f063af 100644 --- a/lib/flutter_image_picker.dart +++ b/lib/flutter_image_picker.dart @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2022 Iconica +// +// SPDX-License-Identifier: BSD-3-Clause + library flutter_image_picker; export 'src/services/image_picker_service.dart'; diff --git a/lib/src/models/image_picker_theme.dart b/lib/src/models/image_picker_theme.dart index e7aac6d..91e2dbc 100644 --- a/lib/src/models/image_picker_theme.dart +++ b/lib/src/models/image_picker_theme.dart @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2022 Iconica +// +// SPDX-License-Identifier: BSD-3-Clause + import 'package:flutter/material.dart'; class ImagePickerTheme { diff --git a/lib/src/services/image_picker_service.dart b/lib/src/services/image_picker_service.dart index c37d9b9..8d8f1b3 100644 --- a/lib/src/services/image_picker_service.dart +++ b/lib/src/services/image_picker_service.dart @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2022 Iconica +// +// SPDX-License-Identifier: BSD-3-Clause + import 'dart:typed_data'; import 'package:image_picker/image_picker.dart'; diff --git a/lib/src/ui/image_picker.dart b/lib/src/ui/image_picker.dart index d22e39c..bc85db7 100644 --- a/lib/src/ui/image_picker.dart +++ b/lib/src/ui/image_picker.dart @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2022 Iconica +// +// SPDX-License-Identifier: BSD-3-Clause + import 'package:flutter/material.dart'; import 'package:flutter_image_picker/src/services/image_picker_service.dart'; import 'package:image_picker/image_picker.dart'; diff --git a/test/image_picker_ui_test.dart b/test/image_picker_ui_test.dart index 985d25c..c977a12 100644 --- a/test/image_picker_ui_test.dart +++ b/test/image_picker_ui_test.dart @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2022 Iconica +// +// SPDX-License-Identifier: BSD-3-Clause + import 'dart:typed_data'; import 'package:flutter/material.dart'; diff --git a/test/mocks/image_picker_service_mock.dart b/test/mocks/image_picker_service_mock.dart index 31b7722..1f16e5c 100644 --- a/test/mocks/image_picker_service_mock.dart +++ b/test/mocks/image_picker_service_mock.dart @@ -1,3 +1,7 @@ +// SPDX-FileCopyrightText: 2022 Iconica +// +// SPDX-License-Identifier: BSD-3-Clause + import 'package:flutter_image_picker/src/services/image_picker_service.dart'; import 'package:mocktail/mocktail.dart';