mirror of
https://github.com/Iconica-Development/flutter_image_picker.git
synced 2025-05-18 11:43:44 +02:00
fix: add ci and linter
This commit is contained in:
parent
829574e5f6
commit
455fc691a2
13 changed files with 267 additions and 516 deletions
14
.github/workflows/component-ci.yml
vendored
Normal file
14
.github/workflows/component-ci.yml
vendored
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
name: Iconica Standard Component CI Workflow
|
||||||
|
# Workflow Caller version: 2.0.0
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
call-global-iconica-workflow:
|
||||||
|
uses: Iconica-Development/.github/.github/workflows/component-ci.yml@master
|
||||||
|
secrets: inherit
|
||||||
|
permissions: write-all
|
||||||
|
with:
|
||||||
|
subfolder: "." # add optional subfolder to run workflow in
|
32
.github/workflows/flutter.yml
vendored
32
.github/workflows/flutter.yml
vendored
|
@ -1,32 +0,0 @@
|
||||||
name: CI
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ master ]
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
- feature/*
|
|
||||||
- bugfix/*
|
|
||||||
- hotfix/*
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
lint:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.gradle/wrapper
|
|
||||||
/opt/hostedtoolcache/flutter
|
|
||||||
key: ${{ runner.OS }}-flutter-install-cache
|
|
||||||
- uses: subosito/flutter-action@v2
|
|
||||||
with:
|
|
||||||
channel: 'stable'
|
|
||||||
- name: Flutter pub get
|
|
||||||
run: flutter pub get
|
|
||||||
- name: Flutter format
|
|
||||||
run: flutter format -o none --set-exit-if-changed .
|
|
||||||
- name: Flutter analyze
|
|
||||||
run: flutter analyze
|
|
|
@ -28,3 +28,7 @@
|
||||||
## 1.0.4 - April 4th 2023
|
## 1.0.4 - April 4th 2023
|
||||||
|
|
||||||
- Make camera option optional
|
- Make camera option optional
|
||||||
|
|
||||||
|
## 1.0.5 - February 7th 2024
|
||||||
|
|
||||||
|
- Added CI and linter
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
include: package:flutter_lints/flutter.yaml
|
include: package:flutter_iconica_analysis/analysis_options.yaml
|
||||||
|
|
||||||
# Additional information about this file can be found at
|
# Possible to overwrite the rules from the package
|
||||||
# https://dart.dev/guides/language/analysis-options
|
|
||||||
|
analyzer:
|
||||||
|
exclude:
|
||||||
|
|
||||||
|
linter:
|
||||||
|
rules:
|
1
example/.gitignore
vendored
1
example/.gitignore
vendored
|
@ -31,6 +31,7 @@ migrate_working_dir/
|
||||||
.pub-cache/
|
.pub-cache/
|
||||||
.pub/
|
.pub/
|
||||||
/build/
|
/build/
|
||||||
|
pubspec.lock
|
||||||
|
|
||||||
# Web related
|
# Web related
|
||||||
lib/generated_plugin_registrant.dart
|
lib/generated_plugin_registrant.dart
|
||||||
|
|
|
@ -1,289 +0,0 @@
|
||||||
# Generated by pub
|
|
||||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
|
||||||
packages:
|
|
||||||
async:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: async
|
|
||||||
sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.10.0"
|
|
||||||
boolean_selector:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: boolean_selector
|
|
||||||
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.1.1"
|
|
||||||
characters:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: characters
|
|
||||||
sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.2.1"
|
|
||||||
clock:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: clock
|
|
||||||
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.1.1"
|
|
||||||
collection:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: collection
|
|
||||||
sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.17.0"
|
|
||||||
cross_file:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: cross_file
|
|
||||||
sha256: "7632a2bcddc8cef4afde3c6f80e69b29a7060e176f01119c229fe4eb3a2a3d4f"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.3.3+1"
|
|
||||||
cupertino_icons:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: cupertino_icons
|
|
||||||
sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.0.5"
|
|
||||||
fake_async:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: fake_async
|
|
||||||
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.3.1"
|
|
||||||
flutter:
|
|
||||||
dependency: "direct main"
|
|
||||||
description: flutter
|
|
||||||
source: sdk
|
|
||||||
version: "0.0.0"
|
|
||||||
flutter_image_picker:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
path: ".."
|
|
||||||
relative: true
|
|
||||||
source: path
|
|
||||||
version: "1.0.4"
|
|
||||||
flutter_lints:
|
|
||||||
dependency: "direct dev"
|
|
||||||
description:
|
|
||||||
name: flutter_lints
|
|
||||||
sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.0.1"
|
|
||||||
flutter_plugin_android_lifecycle:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: flutter_plugin_android_lifecycle
|
|
||||||
sha256: "60fc7b78455b94e6de2333d2f95196d32cf5c22f4b0b0520a628804cb463503b"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.0.7"
|
|
||||||
flutter_test:
|
|
||||||
dependency: "direct dev"
|
|
||||||
description: flutter
|
|
||||||
source: sdk
|
|
||||||
version: "0.0.0"
|
|
||||||
flutter_web_plugins:
|
|
||||||
dependency: transitive
|
|
||||||
description: flutter
|
|
||||||
source: sdk
|
|
||||||
version: "0.0.0"
|
|
||||||
http:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: http
|
|
||||||
sha256: "6aa2946395183537c8b880962d935877325d6a09a2867c3970c05c0fed6ac482"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.13.5"
|
|
||||||
http_parser:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: http_parser
|
|
||||||
sha256: db3060f22889f3d9d55f6a217565486737037eec3609f7f3eca4d0c67ee0d8a0
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "4.0.1"
|
|
||||||
image_picker:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: image_picker
|
|
||||||
sha256: a8f2f0aed50c03230ab37e93ca2905c50b6c4097245345956eb24a88f45328cd
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.8.6"
|
|
||||||
image_picker_android:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: image_picker_android
|
|
||||||
sha256: "8243d3324e28806671feb358e3756528bae6f63dacafaecf896e6b45b167def9"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.8.5+2"
|
|
||||||
image_picker_for_web:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: image_picker_for_web
|
|
||||||
sha256: "60f306ffbdcada4bc8b2691acc420258a1b758e102c87c4f94fb568d640f0e0e"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.1.8"
|
|
||||||
image_picker_ios:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: image_picker_ios
|
|
||||||
sha256: "1768087441bd69ca632249d212c26fa8d530552d37b4896a4dd8d6781435c147"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.8.6+1"
|
|
||||||
image_picker_platform_interface:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: image_picker_platform_interface
|
|
||||||
sha256: cedb2650709f066ee83fd65a1d99b6ff33e5adf98cea376426dd33c2b22bf6ad
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.6.1"
|
|
||||||
js:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: js
|
|
||||||
sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.6.5"
|
|
||||||
lints:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: lints
|
|
||||||
sha256: "5cfd6509652ff5e7fe149b6df4859e687fca9048437857cb2e65c8d780f396e3"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.0.0"
|
|
||||||
matcher:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: matcher
|
|
||||||
sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.12.13"
|
|
||||||
material_color_utilities:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: material_color_utilities
|
|
||||||
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.2.0"
|
|
||||||
meta:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: meta
|
|
||||||
sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.8.0"
|
|
||||||
path:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: path
|
|
||||||
sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.8.2"
|
|
||||||
plugin_platform_interface:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: plugin_platform_interface
|
|
||||||
sha256: "075f927ebbab4262ace8d0b283929ac5410c0ac4e7fc123c76429564facfb757"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.1.2"
|
|
||||||
sky_engine:
|
|
||||||
dependency: transitive
|
|
||||||
description: flutter
|
|
||||||
source: sdk
|
|
||||||
version: "0.0.99"
|
|
||||||
source_span:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: source_span
|
|
||||||
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.9.1"
|
|
||||||
stack_trace:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: stack_trace
|
|
||||||
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.11.0"
|
|
||||||
stream_channel:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: stream_channel
|
|
||||||
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.1.1"
|
|
||||||
string_scanner:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: string_scanner
|
|
||||||
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.2.0"
|
|
||||||
term_glyph:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: term_glyph
|
|
||||||
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.2.1"
|
|
||||||
test_api:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: test_api
|
|
||||||
sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.4.16"
|
|
||||||
typed_data:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: typed_data
|
|
||||||
sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.3.1"
|
|
||||||
vector_math:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: vector_math
|
|
||||||
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "2.1.4"
|
|
||||||
sdks:
|
|
||||||
dart: ">=2.18.0 <3.0.0"
|
|
||||||
flutter: ">=2.10.0"
|
|
|
@ -1,10 +1,10 @@
|
||||||
// SPDX-FileCopyrightText: 2022 Iconica
|
// SPDX-FileCopyrightText: 2022 Iconica
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
///
|
||||||
library flutter_image_picker;
|
library flutter_image_picker;
|
||||||
|
|
||||||
export 'src/services/image_picker_service.dart';
|
|
||||||
export 'src/models/image_picker_theme.dart';
|
|
||||||
export 'src/models/image_picker_config.dart';
|
export 'src/models/image_picker_config.dart';
|
||||||
|
export 'src/models/image_picker_theme.dart';
|
||||||
|
export 'src/services/image_picker_service.dart';
|
||||||
export 'src/ui/image_picker.dart';
|
export 'src/ui/image_picker.dart';
|
||||||
|
|
|
@ -10,11 +10,12 @@ class ImagePickerConfig {
|
||||||
/// If specified, the image will be at most `maxWidth` wide and
|
/// If specified, the image will be at most `maxWidth` wide and
|
||||||
/// `maxHeight` tall. Otherwise the image will be returned at it's
|
/// `maxHeight` tall. Otherwise the image will be returned at it's
|
||||||
/// original width and height.
|
/// original width and height.
|
||||||
/// The `imageQuality` argument modifies the quality of the image, ranging from 0-100
|
/// The `imageQuality` argument modifies the quality of the image, ranging
|
||||||
/// where 100 is the original/max quality. If `imageQuality` is null, the image with
|
/// from 0-100 where 100 is the original/max quality. If `imageQuality` is null, the image with
|
||||||
/// the original quality will be returned. Compression is only supported for certain
|
/// the original quality will be returned. Compression is only supported
|
||||||
/// image types such as JPEG and on Android PNG and WebP, too. If compression is not supported for the image that is picked,
|
/// for certain image types such as JPEG and on Android PNG and WebP, too.
|
||||||
/// a warning message will be logged.
|
/// If compression is not supported for the image that is picked, a warning
|
||||||
|
/// message will be logged.
|
||||||
final double? maxWidth;
|
final double? maxWidth;
|
||||||
final double? maxHeight;
|
final double? maxHeight;
|
||||||
final int? imageQuality;
|
final int? imageQuality;
|
||||||
|
|
|
@ -8,8 +8,8 @@ class ImagePickerTheme {
|
||||||
/// The [ImagePickerTheme] is used to style the [ImagePicker].
|
/// The [ImagePickerTheme] is used to style the [ImagePicker].
|
||||||
|
|
||||||
const ImagePickerTheme({
|
const ImagePickerTheme({
|
||||||
this.font = "Roboto",
|
this.font = 'Roboto',
|
||||||
this.title = "Upload Image",
|
this.title = 'Upload Image',
|
||||||
this.titleTextSize = 20,
|
this.titleTextSize = 20,
|
||||||
this.titleColor = Colors.black,
|
this.titleColor = Colors.black,
|
||||||
this.titleBackgroundColor = Colors.white,
|
this.titleBackgroundColor = Colors.white,
|
||||||
|
@ -20,10 +20,10 @@ class ImagePickerTheme {
|
||||||
this.iconTextSize = 15,
|
this.iconTextSize = 15,
|
||||||
this.spaceBetweenIcons = 30,
|
this.spaceBetweenIcons = 30,
|
||||||
this.makePhotoIcon,
|
this.makePhotoIcon,
|
||||||
this.makePhotoText = "Take a Picture",
|
this.makePhotoText = 'Take a Picture',
|
||||||
this.selectImageIcon,
|
this.selectImageIcon,
|
||||||
this.selectImageText = "Select File",
|
this.selectImageText = 'Select File',
|
||||||
this.closeButtonText = "Close",
|
this.closeButtonText = 'Close',
|
||||||
this.closeButtonTextSize = 15,
|
this.closeButtonTextSize = 15,
|
||||||
this.closeButtonTextColor = Colors.white,
|
this.closeButtonTextColor = Colors.white,
|
||||||
this.closeButtonWidth = 300,
|
this.closeButtonWidth = 300,
|
||||||
|
@ -64,19 +64,23 @@ class ImagePickerTheme {
|
||||||
/// The size of the space between the two icons in the Image Picker Dialog.
|
/// The size of the space between the two icons in the Image Picker Dialog.
|
||||||
final double spaceBetweenIcons;
|
final double spaceBetweenIcons;
|
||||||
|
|
||||||
/// The icon that is displayed for the 'Make Photo' functionality of the Image Picker Dialog.
|
/// The icon that is displayed for the 'Make Photo' functionality of the
|
||||||
|
/// Image Picker Dialog.
|
||||||
final Widget? makePhotoIcon;
|
final Widget? makePhotoIcon;
|
||||||
|
|
||||||
/// The text that is displayed underneath the 'Make Photo' icon.
|
/// The text that is displayed underneath the 'Make Photo' icon.
|
||||||
final String makePhotoText;
|
final String makePhotoText;
|
||||||
|
|
||||||
/// The icon that is displayed for the 'Select Image From Gallery' functionality of the Image Picker Dialog.
|
/// The icon that is displayed for the 'Select Image From Gallery'
|
||||||
|
/// functionality of the Image Picker Dialog.
|
||||||
final Widget? selectImageIcon;
|
final Widget? selectImageIcon;
|
||||||
|
|
||||||
/// The text that is displayed underneath the 'Select Image From Gallery' icon.
|
/// The text that is displayed underneath the 'Select Image From Gallery'
|
||||||
|
/// icon.
|
||||||
final String selectImageText;
|
final String selectImageText;
|
||||||
|
|
||||||
/// The text that is shown on the 'Close Dialog' button at the bottom of the Image Picker Dialog.
|
/// The text that is shown on the 'Close Dialog' button at the bottom of the
|
||||||
|
/// Image Picker Dialog.
|
||||||
final String closeButtonText;
|
final String closeButtonText;
|
||||||
|
|
||||||
/// The fontsize of the text of the close button of the Image Picker Dialog.
|
/// The fontsize of the text of the close button of the Image Picker Dialog.
|
||||||
|
@ -85,10 +89,12 @@ class ImagePickerTheme {
|
||||||
/// The color of the text of the close button of the Image Picker Dialog.
|
/// The color of the text of the close button of the Image Picker Dialog.
|
||||||
final Color closeButtonTextColor;
|
final Color closeButtonTextColor;
|
||||||
|
|
||||||
/// The width of the 'Close Dialog' button at the bottom of the Image Picker Dialog.
|
/// The width of the 'Close Dialog' button at the bottom of the Image Picker
|
||||||
|
/// Dialog.
|
||||||
final double closeButtonWidth;
|
final double closeButtonWidth;
|
||||||
|
|
||||||
/// The height of the 'Close Dialog' button at the bottom of the Image Picker Dialog.
|
/// The height of the 'Close Dialog' button at the bottom of the Image Picker
|
||||||
|
/// Dialog.
|
||||||
final double closeButtonHeight;
|
final double closeButtonHeight;
|
||||||
|
|
||||||
/// The color of the close button of the Image Picker Dialog.
|
/// The color of the close button of the Image Picker Dialog.
|
||||||
|
|
|
@ -6,10 +6,13 @@ import 'dart:typed_data';
|
||||||
import 'package:flutter_image_picker/src/models/image_picker_config.dart';
|
import 'package:flutter_image_picker/src/models/image_picker_config.dart';
|
||||||
import 'package:image_picker/image_picker.dart';
|
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.
|
/// The Image Picker Service class is the functionality of the Image Picker
|
||||||
/// If you have your own implementation of the Image Picker you can add it to the constructor when creating the class.
|
/// package which uses the Image Picker package to choose an image.
|
||||||
abstract class ImagePickerService {
|
/// If you have your own implementation of the Image Picker you can add it to
|
||||||
/// [pickImage] is the function that picks the image and returns it as a [Uint8List].
|
/// the constructor when creating the class.
|
||||||
|
mixin ImagePickerService {
|
||||||
|
/// [pickImage] is the function that picks the image and returns it as a
|
||||||
|
/// [Uint8List].
|
||||||
/// The function requires [source], an [ImageSource]
|
/// The function requires [source], an [ImageSource]
|
||||||
Future<Uint8List?> pickImage(
|
Future<Uint8List?> pickImage(
|
||||||
ImageSource source, {
|
ImageSource source, {
|
||||||
|
@ -17,16 +20,21 @@ abstract class ImagePickerService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The ImagePickerServiceDefault is the default implementation of the ImagePickerService.
|
/// The ImagePickerServiceDefault is the default implementation of the
|
||||||
/// It uses the Image Picker package to pick an image and returns it as a [Uint8List].
|
/// ImagePickerService.
|
||||||
|
/// It uses the Image Picker package to pick an image and returns it as a
|
||||||
|
/// [Uint8List].
|
||||||
class ImagePickerServiceDefault implements ImagePickerService {
|
class ImagePickerServiceDefault implements ImagePickerService {
|
||||||
ImagePickerServiceDefault({this.imagePicker});
|
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.
|
/// 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;
|
ImagePicker? imagePicker;
|
||||||
|
|
||||||
/// [pickImage] is the function that picks the image and returns it as a [Uint8List].
|
/// [pickImage] is the function that picks the image and returns it as a
|
||||||
/// The function requires [source], an [ImageSource] that's the method of how the image needs to be picked, for example gallery or camera.
|
/// [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
|
@override
|
||||||
Future<Uint8List?> pickImage(
|
Future<Uint8List?> pickImage(
|
||||||
ImageSource source, {
|
ImageSource source, {
|
||||||
|
|
|
@ -6,10 +6,15 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_image_picker/flutter_image_picker.dart';
|
import 'package:flutter_image_picker/flutter_image_picker.dart';
|
||||||
import 'package:image_picker/image_picker.dart';
|
import 'package:image_picker/image_picker.dart';
|
||||||
|
|
||||||
/// The Image Picker class generates the Image Picker Widget which can be displayed in your application. If you call the class you can give it 4 optional variables:
|
/// The Image Picker class generates the Image Picker Widget which can be
|
||||||
/// The first one is the [ImagePickerTheme] which can be used to change the UI of the widget.
|
/// displayed in your application. If you call the class you can give it 4
|
||||||
/// The second one is the [ImagePickerConfig] which can be used to configure the behaviour of the image picker.
|
/// optional variables:
|
||||||
/// The third one is your own implementation of the ImagePickerService. Which can be used in testing for example.
|
/// The first one is the [ImagePickerTheme] which can be used to change the UI
|
||||||
|
/// of the widget.
|
||||||
|
/// The second one is the [ImagePickerConfig] which can be used to configure the
|
||||||
|
/// behaviour of the image picker.
|
||||||
|
/// The third one is your own implementation of the ImagePickerService. Which
|
||||||
|
/// can be used in testing for example.
|
||||||
/// The fourth one is a custom Button widget.
|
/// The fourth one is a custom Button widget.
|
||||||
class ImagePicker extends StatelessWidget {
|
class ImagePicker extends StatelessWidget {
|
||||||
const ImagePicker({
|
const ImagePicker({
|
||||||
|
@ -23,18 +28,20 @@ class ImagePicker extends StatelessWidget {
|
||||||
/// ImagePickerTheme can be used to change the UI of the Image Picker Widget to change the text/icons to your liking.
|
/// ImagePickerTheme can be used to change the UI of the Image Picker Widget to change the text/icons to your liking.
|
||||||
final ImagePickerTheme imagePickerTheme;
|
final ImagePickerTheme imagePickerTheme;
|
||||||
|
|
||||||
/// ImagePickerConfig can be used to define the size and quality for the uploaded image.
|
/// ImagePickerConfig can be used to define the size and quality for the
|
||||||
|
/// uploaded image.
|
||||||
final ImagePickerConfig imagePickerConfig;
|
final ImagePickerConfig imagePickerConfig;
|
||||||
|
|
||||||
/// The Image Picker Dialog can have a custom button if you want to.
|
/// The Image Picker Dialog can have a custom button if you want to.
|
||||||
final Widget? 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.
|
/// 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;
|
final ImagePickerService? imagePickerService;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) => SingleChildScrollView(
|
||||||
return SingleChildScrollView(
|
|
||||||
child: Column(
|
child: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
ListTile(
|
ListTile(
|
||||||
|
@ -73,7 +80,7 @@ class ImagePicker extends StatelessWidget {
|
||||||
ImageSource.camera,
|
ImageSource.camera,
|
||||||
imagePickerTheme.makePhotoText,
|
imagePickerTheme.makePhotoText,
|
||||||
),
|
),
|
||||||
]
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
|
@ -99,21 +106,26 @@ class ImagePicker extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 30),
|
const SizedBox(height: 30),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
/// The [_generateIconButtonWithText] function returns a column that includes an [IconButton] and [Text].
|
/// The [_generateIconButtonWithText] function returns a column that includes
|
||||||
/// The function requires the following parameters to be able to generate an icon with text:
|
/// an [IconButton] and [Text].
|
||||||
/// [context] The build context that is required to make the [pickImage] function in [_imagePickerService] work.
|
/// The function requires the following parameters to be able to generate an
|
||||||
/// [imagePickerTheme] The ImagePickerTheme that includes all default values for the Image Picker Dialog.
|
/// icon with text:
|
||||||
/// [icon] The icon that needs to be displayed, requires an [IconData] as value to be used.
|
/// [context] The build context that is required to make the [pickImage]
|
||||||
/// [imageSource] The type of [ImageSource] to be used to pick an image when pressed on the icon.
|
/// function in [_imagePickerService] work.
|
||||||
|
/// [imagePickerTheme] The ImagePickerTheme that includes all default values
|
||||||
|
/// for the Image Picker Dialog.
|
||||||
|
/// [icon] The icon that needs to be displayed, requires an [IconData] as
|
||||||
|
///value to be used.
|
||||||
|
/// [imageSource] The type of [ImageSource] to be used to pick an image when
|
||||||
|
/// pressed on the icon.
|
||||||
/// [bottomText] The text that's displayed underneath the icon.
|
/// [bottomText] The text that's displayed underneath the icon.
|
||||||
Column _generateIconButtonWithText(
|
Column _generateIconButtonWithText(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
|
@ -121,14 +133,15 @@ class ImagePicker extends StatelessWidget {
|
||||||
ImagePickerTheme imagePickerTheme,
|
ImagePickerTheme imagePickerTheme,
|
||||||
IconData icon,
|
IconData icon,
|
||||||
ImageSource imageSource,
|
ImageSource imageSource,
|
||||||
String bottomText) {
|
String bottomText,
|
||||||
return Column(
|
) =>
|
||||||
|
Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
InkWell(
|
InkWell(
|
||||||
key: Key(bottomText),
|
key: Key(bottomText),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final navigator = Navigator.of(context);
|
var navigator = Navigator.of(context);
|
||||||
var image =
|
var image =
|
||||||
await (imagePickerService ?? ImagePickerServiceDefault())
|
await (imagePickerService ?? ImagePickerServiceDefault())
|
||||||
.pickImage(imageSource, config: imagePickerConfig);
|
.pickImage(imageSource, config: imagePickerConfig);
|
||||||
|
@ -153,4 +166,3 @@ class ImagePicker extends StatelessWidget {
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: flutter_image_picker
|
name: flutter_image_picker
|
||||||
description: A Flutter Image Picking package.
|
description: A Flutter Image Picking package.
|
||||||
version: 1.0.4
|
version: 1.0.5
|
||||||
repository: https://github.com/Iconica-Development/flutter_image_picker
|
repository: https://github.com/Iconica-Development/flutter_image_picker
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
|
@ -15,7 +15,10 @@ dependencies:
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
flutter_lints: ^2.0.0
|
|
||||||
mocktail: ^0.3.0
|
mocktail: ^0.3.0
|
||||||
|
flutter_iconica_analysis:
|
||||||
|
git:
|
||||||
|
url: https://github.com/Iconica-Development/flutter_iconica_analysis
|
||||||
|
ref: 6.0.0
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
|
|
|
@ -7,15 +7,15 @@ import 'dart:typed_data';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_image_picker/flutter_image_picker.dart'
|
import 'package:flutter_image_picker/flutter_image_picker.dart'
|
||||||
as iconica_image_picker;
|
as iconica_image_picker;
|
||||||
import 'package:image_picker/image_picker.dart' as image_picker;
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:image_picker/image_picker.dart' as image_picker;
|
||||||
import 'package:mocktail/mocktail.dart';
|
import 'package:mocktail/mocktail.dart';
|
||||||
|
|
||||||
import 'mocks/image_picker_service_mock.dart';
|
import 'mocks/image_picker_service_mock.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
Uint8List cameraImage = Uint8List(10);
|
var cameraImage = Uint8List(10);
|
||||||
Uint8List galleryImage = Uint8List(44);
|
var galleryImage = Uint8List(44);
|
||||||
|
|
||||||
testWidgets('Image Picker Shows With Normal Theme', (tester) async {
|
testWidgets('Image Picker Shows With Normal Theme', (tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
|
@ -26,15 +26,15 @@ void main() {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
final titleFinder =
|
var titleFinder =
|
||||||
find.text(const iconica_image_picker.ImagePickerTheme().title);
|
find.text(const iconica_image_picker.ImagePickerTheme().title);
|
||||||
final makePhotoIconFinder = find.byIcon(Icons.camera_alt_rounded);
|
var makePhotoIconFinder = find.byIcon(Icons.camera_alt_rounded);
|
||||||
final makePhotoTextFinder =
|
var makePhotoTextFinder =
|
||||||
find.text(const iconica_image_picker.ImagePickerTheme().makePhotoText);
|
find.text(const iconica_image_picker.ImagePickerTheme().makePhotoText);
|
||||||
final selectImageIconFinder = find.byIcon(Icons.image);
|
var selectImageIconFinder = find.byIcon(Icons.image);
|
||||||
final selectImageTextFinder = find
|
var selectImageTextFinder = find
|
||||||
.text(const iconica_image_picker.ImagePickerTheme().selectImageText);
|
.text(const iconica_image_picker.ImagePickerTheme().selectImageText);
|
||||||
final closebuttonTextFinder = find
|
var closebuttonTextFinder = find
|
||||||
.text(const iconica_image_picker.ImagePickerTheme().closeButtonText);
|
.text(const iconica_image_picker.ImagePickerTheme().closeButtonText);
|
||||||
|
|
||||||
expect(titleFinder, findsOneWidget);
|
expect(titleFinder, findsOneWidget);
|
||||||
|
@ -48,18 +48,24 @@ void main() {
|
||||||
testWidgets(
|
testWidgets(
|
||||||
'Image Picker Calls Function Correctly When ImageSource Is Gallery',
|
'Image Picker Calls Function Correctly When ImageSource Is Gallery',
|
||||||
(tester) async {
|
(tester) async {
|
||||||
ImagePickerServiceMock serviceMock = ImagePickerServiceMock();
|
var serviceMock = ImagePickerServiceMock();
|
||||||
|
|
||||||
when(() => serviceMock.pickImage(image_picker.ImageSource.gallery))
|
when(() => serviceMock.pickImage(image_picker.ImageSource.gallery))
|
||||||
.thenAnswer((_) => Future.value(galleryImage));
|
.thenAnswer((_) => Future.value(galleryImage));
|
||||||
|
|
||||||
await tester.pumpWidget(MaterialApp(
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
home: Material(
|
home: Material(
|
||||||
child: iconica_image_picker.ImagePicker(
|
child: iconica_image_picker.ImagePicker(
|
||||||
imagePickerService: serviceMock))));
|
imagePickerService: serviceMock,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
Finder finder = find.byKey(
|
var finder = find.byKey(
|
||||||
Key(const iconica_image_picker.ImagePickerTheme().selectImageText));
|
Key(const iconica_image_picker.ImagePickerTheme().selectImageText),
|
||||||
|
);
|
||||||
|
|
||||||
await tester.tap(finder);
|
await tester.tap(finder);
|
||||||
|
|
||||||
|
@ -70,18 +76,24 @@ void main() {
|
||||||
testWidgets(
|
testWidgets(
|
||||||
'Image Picker Calls Function Correctly When ImageSource Is Camera',
|
'Image Picker Calls Function Correctly When ImageSource Is Camera',
|
||||||
(tester) async {
|
(tester) async {
|
||||||
ImagePickerServiceMock serviceMock = ImagePickerServiceMock();
|
var serviceMock = ImagePickerServiceMock();
|
||||||
|
|
||||||
when(() => serviceMock.pickImage(image_picker.ImageSource.camera))
|
when(() => serviceMock.pickImage(image_picker.ImageSource.camera))
|
||||||
.thenAnswer((_) => Future.value(cameraImage));
|
.thenAnswer((_) => Future.value(cameraImage));
|
||||||
|
|
||||||
await tester.pumpWidget(MaterialApp(
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
home: Material(
|
home: Material(
|
||||||
child: iconica_image_picker.ImagePicker(
|
child: iconica_image_picker.ImagePicker(
|
||||||
imagePickerService: serviceMock))));
|
imagePickerService: serviceMock,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
Finder finder = find.byKey(
|
var finder = find.byKey(
|
||||||
Key(const iconica_image_picker.ImagePickerTheme().makePhotoText));
|
Key(const iconica_image_picker.ImagePickerTheme().makePhotoText),
|
||||||
|
);
|
||||||
|
|
||||||
await tester.tap(finder);
|
await tester.tap(finder);
|
||||||
|
|
||||||
|
@ -90,22 +102,23 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Image Picker Shows With Custom Theme', (tester) async {
|
testWidgets('Image Picker Shows With Custom Theme', (tester) async {
|
||||||
String title = "title";
|
var title = 'title';
|
||||||
Widget makePhotoIcon = Container(
|
Widget makePhotoIcon = Container(
|
||||||
height: 125,
|
height: 125,
|
||||||
width: 125,
|
width: 125,
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
);
|
);
|
||||||
String makePhotoText = "taaaake image";
|
var makePhotoText = 'taaaake image';
|
||||||
Widget selectImageIcon = Container(
|
Widget selectImageIcon = Container(
|
||||||
height: 125,
|
height: 125,
|
||||||
width: 125,
|
width: 125,
|
||||||
color: Colors.blue,
|
color: Colors.blue,
|
||||||
);
|
);
|
||||||
String selectImageText = "seleeeeect image";
|
var selectImageText = 'seleeeeect image';
|
||||||
String closeButtonText = "Close Dialog!";
|
var closeButtonText = 'Close Dialog!';
|
||||||
|
|
||||||
await tester.pumpWidget(MaterialApp(
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
home: Material(
|
home: Material(
|
||||||
child: iconica_image_picker.ImagePicker(
|
child: iconica_image_picker.ImagePicker(
|
||||||
imagePickerTheme: iconica_image_picker.ImagePickerTheme(
|
imagePickerTheme: iconica_image_picker.ImagePickerTheme(
|
||||||
|
@ -114,14 +127,19 @@ void main() {
|
||||||
makePhotoText: makePhotoText,
|
makePhotoText: makePhotoText,
|
||||||
selectImageIcon: selectImageIcon,
|
selectImageIcon: selectImageIcon,
|
||||||
selectImageText: selectImageText,
|
selectImageText: selectImageText,
|
||||||
closeButtonText: closeButtonText)))));
|
closeButtonText: closeButtonText,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
final titleFinder = find.text(title);
|
var titleFinder = find.text(title);
|
||||||
final makePhotoIconFinder = find.byWidget(makePhotoIcon);
|
var makePhotoIconFinder = find.byWidget(makePhotoIcon);
|
||||||
final makePhotoTextFinder = find.text(makePhotoText);
|
var makePhotoTextFinder = find.text(makePhotoText);
|
||||||
final selectImageIconFinder = find.byWidget(selectImageIcon);
|
var selectImageIconFinder = find.byWidget(selectImageIcon);
|
||||||
final selectImageTextFinder = find.text(selectImageText);
|
var selectImageTextFinder = find.text(selectImageText);
|
||||||
final closebuttonTextFinder = find.text(closeButtonText);
|
var closebuttonTextFinder = find.text(closeButtonText);
|
||||||
|
|
||||||
expect(titleFinder, findsOneWidget);
|
expect(titleFinder, findsOneWidget);
|
||||||
expect(makePhotoIconFinder, findsOneWidget);
|
expect(makePhotoIconFinder, findsOneWidget);
|
||||||
|
|
Loading…
Reference in a new issue