mirror of
https://github.com/Iconica-Development/flutter_image_picker.git
synced 2025-05-19 04:03:44 +02:00
Compare commits
No commits in common. "master" and "1.0.4" have entirely different histories.
23 changed files with 597 additions and 351 deletions
14
.github/workflows/component-ci.yml
vendored
14
.github/workflows/component-ci.yml
vendored
|
@ -1,14 +0,0 @@
|
||||||
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
|
|
14
.github/workflows/component-documentation.yml
vendored
14
.github/workflows/component-documentation.yml
vendored
|
@ -1,14 +0,0 @@
|
||||||
name: Iconica Standard Component Documentation Workflow
|
|
||||||
# Workflow Caller version: 1.0.0
|
|
||||||
|
|
||||||
on:
|
|
||||||
release:
|
|
||||||
types: [published]
|
|
||||||
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
call-iconica-component-documentation-workflow:
|
|
||||||
uses: Iconica-Development/.github/.github/workflows/component-documentation.yml@master
|
|
||||||
secrets: inherit
|
|
||||||
permissions: write-all
|
|
32
.github/workflows/flutter.yml
vendored
Normal file
32
.github/workflows/flutter.yml
vendored
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
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
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -31,7 +31,3 @@ build/
|
||||||
coverage/
|
coverage/
|
||||||
/.flutter-plugins
|
/.flutter-plugins
|
||||||
/.flutter-plugins-dependencies
|
/.flutter-plugins-dependencies
|
||||||
|
|
||||||
# FVM Version Cache
|
|
||||||
.fvm/
|
|
||||||
.fvmrc
|
|
||||||
|
|
20
CHANGELOG.md
20
CHANGELOG.md
|
@ -28,23 +28,3 @@
|
||||||
## 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
|
|
||||||
|
|
||||||
## 2.0.0 - February 22nd 2024
|
|
||||||
|
|
||||||
- Simplified the ImagePickerTheme
|
|
||||||
|
|
||||||
# 3.0.0 - February 22nd 2024
|
|
||||||
|
|
||||||
- Removed customButton from ImagePicker.
|
|
||||||
|
|
||||||
# 4.0.0
|
|
||||||
* Added title options to theme.
|
|
||||||
* updated iconica_analysis dependency.
|
|
||||||
* Updated default theme.
|
|
||||||
|
|
||||||
# 4.1.0
|
|
||||||
* Added support for handling errors when calling `pickImage`.
|
|
||||||
|
|
|
@ -6,9 +6,6 @@ Image Picker that can be used to pick an image from storage or make a picture wi
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Figma Design that defines this component (only accessible for Iconica developers): https://www.figma.com/file/4WkjwynOz5wFeFBRqTHPeP/Iconica-Design-System?type=design&node-id=357%3A3354&mode=design&t=XulkAJNPQ32ARxWh-1
|
|
||||||
Figma clickable prototype that demonstrates this component (only accessible for Iconica developers): https://www.figma.com/proto/4WkjwynOz5wFeFBRqTHPeP/Iconica-Design-System?type=design&node-id=340-611&viewport=188%2C-512%2C0.05&t=XulkAJNPQ32ARxWh-0&scaling=min-zoom&starting-point-node-id=516%3A2544&show-proto-sidebar=1
|
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
To use this package, add `flutter_image_picker` as a dependency in your pubspec.yaml file.
|
To use this package, add `flutter_image_picker` as a dependency in your pubspec.yaml file.
|
||||||
|
|
|
@ -1,9 +1,4 @@
|
||||||
include: package:flutter_iconica_analysis/analysis_options.yaml
|
include: package:flutter_lints/flutter.yaml
|
||||||
|
|
||||||
# Possible to overwrite the rules from the package
|
# Additional information about this file can be found at
|
||||||
|
# https://dart.dev/guides/language/analysis-options
|
||||||
analyzer:
|
|
||||||
exclude:
|
|
||||||
|
|
||||||
linter:
|
|
||||||
rules:
|
|
||||||
|
|
1
example/.gitignore
vendored
1
example/.gitignore
vendored
|
@ -31,7 +31,6 @@ 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
|
||||||
|
|
|
@ -11,9 +11,7 @@ void main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ImagePickerExample extends StatelessWidget {
|
class ImagePickerExample extends StatelessWidget {
|
||||||
const ImagePickerExample({
|
const ImagePickerExample({Key? key}) : super(key: key);
|
||||||
super.key,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -29,10 +27,8 @@ class ImagePickerExample extends StatelessWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ImagePickerExampleHomePage extends StatefulWidget {
|
class ImagePickerExampleHomePage extends StatefulWidget {
|
||||||
const ImagePickerExampleHomePage({
|
const ImagePickerExampleHomePage({Key? key, required this.title})
|
||||||
required this.title,
|
: super(key: key);
|
||||||
super.key,
|
|
||||||
});
|
|
||||||
|
|
||||||
final String title;
|
final String title;
|
||||||
|
|
||||||
|
@ -116,13 +112,7 @@ class ImagePickerExampleHomePageState
|
||||||
Uint8List? imageInBytes = await showModalBottomSheet<Uint8List?>(
|
Uint8List? imageInBytes = await showModalBottomSheet<Uint8List?>(
|
||||||
context: context,
|
context: context,
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
builder: (BuildContext context) => ImagePicker(
|
builder: (BuildContext context) => const ImagePicker());
|
||||||
onError: (error) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(content: Text(error.message ?? "An error occurred")),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
));
|
|
||||||
if (imageInBytes != null) {
|
if (imageInBytes != null) {
|
||||||
if (!listEquals(uploadedImage, imageInBytes)) {
|
if (!listEquals(uploadedImage, imageInBytes)) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|
|
@ -6,10 +6,6 @@
|
||||||
|
|
||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
#include <file_selector_linux/file_selector_plugin.h>
|
|
||||||
|
|
||||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||||
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
|
|
||||||
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
|
|
||||||
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
list(APPEND FLUTTER_PLUGIN_LIST
|
list(APPEND FLUTTER_PLUGIN_LIST
|
||||||
file_selector_linux
|
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
import FlutterMacOS
|
import FlutterMacOS
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
import file_selector_macos
|
|
||||||
|
|
||||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
|
|
||||||
}
|
}
|
||||||
|
|
289
example/pubspec.lock
Normal file
289
example/pubspec.lock
Normal file
|
@ -0,0 +1,289 @@
|
||||||
|
# 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"
|
|
@ -6,9 +6,6 @@
|
||||||
|
|
||||||
#include "generated_plugin_registrant.h"
|
#include "generated_plugin_registrant.h"
|
||||||
|
|
||||||
#include <file_selector_windows/file_selector_windows.h>
|
|
||||||
|
|
||||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||||
FileSelectorWindowsRegisterWithRegistrar(
|
|
||||||
registry->GetRegistrarForPlugin("FileSelectorWindows"));
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
list(APPEND FLUTTER_PLUGIN_LIST
|
list(APPEND FLUTTER_PLUGIN_LIST
|
||||||
file_selector_windows
|
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||||
|
|
|
@ -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/models/image_picker_config.dart";
|
export 'src/services/image_picker_service.dart';
|
||||||
export "src/models/image_picker_theme.dart";
|
export 'src/models/image_picker_theme.dart';
|
||||||
export "src/services/image_picker_service.dart";
|
export 'src/models/image_picker_config.dart';
|
||||||
export "src/ui/image_picker.dart";
|
export 'src/ui/image_picker.dart';
|
||||||
|
|
|
@ -10,12 +10,11 @@ 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
|
/// The `imageQuality` argument modifies the quality of the image, ranging from 0-100
|
||||||
/// from 0-100 where 100 is the original/max quality. If `imageQuality` is null, the image with
|
/// where 100 is the original/max quality. If `imageQuality` is null, the image with
|
||||||
/// the original quality will be returned. Compression is only supported
|
/// the original quality will be returned. Compression is only supported for certain
|
||||||
/// for certain image types such as JPEG and on Android PNG and WebP, too.
|
/// image types such as JPEG and on Android PNG and WebP, too. If compression is not supported for the image that is picked,
|
||||||
/// If compression is not supported for the image that is picked, a warning
|
/// a warning message will be logged.
|
||||||
/// message will be logged.
|
|
||||||
final double? maxWidth;
|
final double? maxWidth;
|
||||||
final double? maxHeight;
|
final double? maxHeight;
|
||||||
final int? imageQuality;
|
final int? imageQuality;
|
||||||
|
|
|
@ -2,57 +2,95 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
import "package:flutter/material.dart";
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class ImagePickerTheme {
|
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.title = "Upload Image",
|
||||||
|
this.titleTextSize = 20,
|
||||||
|
this.titleColor = Colors.black,
|
||||||
|
this.titleBackgroundColor = Colors.white,
|
||||||
|
this.titleAlignment = TextAlign.left,
|
||||||
|
this.textColor = Colors.black,
|
||||||
this.iconColor = Colors.black,
|
this.iconColor = Colors.black,
|
||||||
this.iconSize = 125,
|
this.iconSize = 125,
|
||||||
|
this.iconTextSize = 15,
|
||||||
this.spaceBetweenIcons = 30,
|
this.spaceBetweenIcons = 30,
|
||||||
this.makePhotoIcon,
|
this.makePhotoIcon,
|
||||||
this.makePhotoText = "TAKE PICTURE",
|
this.makePhotoText = "Take a Picture",
|
||||||
this.selectImageIcon,
|
this.selectImageIcon,
|
||||||
this.selectImageText = "UPLOAD FILE",
|
this.selectImageText = "Select File",
|
||||||
this.iconTextStyle,
|
this.closeButtonText = "Close",
|
||||||
this.closeButtonBuilder,
|
this.closeButtonTextSize = 15,
|
||||||
this.title = "Do you want to upload a file or take a picture?",
|
this.closeButtonTextColor = Colors.white,
|
||||||
this.titleStyle,
|
this.closeButtonWidth = 300,
|
||||||
this.titleAlignment = TextAlign.center,
|
this.closeButtonHeight = 40,
|
||||||
|
this.closeButtonBackgroundColor = Colors.black,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/// The font that's used in the Image Picker
|
||||||
|
final String font;
|
||||||
|
|
||||||
|
/// The title displayed at the top of the Image Picker Dialog.
|
||||||
|
final String title;
|
||||||
|
|
||||||
|
/// The font size of the title mentioned above.
|
||||||
|
final double titleTextSize;
|
||||||
|
|
||||||
|
/// The color of the title text.
|
||||||
|
final Color titleColor;
|
||||||
|
|
||||||
|
/// The color of the title background.
|
||||||
|
final Color titleBackgroundColor;
|
||||||
|
|
||||||
|
/// The alignment of the title text.
|
||||||
|
final TextAlign titleAlignment;
|
||||||
|
|
||||||
/// The color of the icons
|
/// The color of the icons
|
||||||
final Color iconColor;
|
final Color iconColor;
|
||||||
|
|
||||||
|
/// The color of the text in the Image Picker Dialog
|
||||||
|
final Color textColor;
|
||||||
|
|
||||||
/// The size of the icons that are visible in the Image Picker Dialog.
|
/// The size of the icons that are visible in the Image Picker Dialog.
|
||||||
final double iconSize;
|
final double iconSize;
|
||||||
|
|
||||||
|
/// The font size of the text underneath the icon buttons.
|
||||||
|
final double iconTextSize;
|
||||||
|
|
||||||
/// 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
|
/// The icon that is displayed for the 'Make Photo' functionality of the Image Picker Dialog.
|
||||||
/// 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'
|
/// The icon that is displayed for the 'Select Image From Gallery' functionality of the Image Picker Dialog.
|
||||||
/// functionality of the Image Picker Dialog.
|
|
||||||
final Widget? selectImageIcon;
|
final Widget? selectImageIcon;
|
||||||
|
|
||||||
/// The text that is displayed underneath the 'Select Image From Gallery'
|
/// The text that is displayed underneath the 'Select Image From Gallery' icon.
|
||||||
/// icon.
|
|
||||||
final String selectImageText;
|
final String selectImageText;
|
||||||
|
|
||||||
final TextStyle? iconTextStyle;
|
/// The text that is shown on the 'Close Dialog' button at the bottom of the Image Picker Dialog.
|
||||||
|
final String closeButtonText;
|
||||||
|
|
||||||
final Widget Function(Function() onTap)? closeButtonBuilder;
|
/// The fontsize of the text of the close button of the Image Picker Dialog.
|
||||||
|
final double closeButtonTextSize;
|
||||||
|
|
||||||
final String title;
|
/// The color of the text of the close button of the Image Picker Dialog.
|
||||||
|
final Color closeButtonTextColor;
|
||||||
|
|
||||||
final TextStyle? titleStyle;
|
/// The width of the 'Close Dialog' button at the bottom of the Image Picker Dialog.
|
||||||
|
final double closeButtonWidth;
|
||||||
|
|
||||||
final TextAlign titleAlignment;
|
/// The height of the 'Close Dialog' button at the bottom of the Image Picker Dialog.
|
||||||
|
final double closeButtonHeight;
|
||||||
|
|
||||||
|
/// The color of the close button of the Image Picker Dialog.
|
||||||
|
final Color closeButtonBackgroundColor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,17 +2,14 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
import "dart:typed_data";
|
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
|
/// The Image Picker Service class is the functionality of the Image Picker package which uses the Image Picker package to choose an image.
|
||||||
/// 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.
|
||||||
/// If you have your own implementation of the Image Picker you can add it to
|
abstract class ImagePickerService {
|
||||||
/// the constructor when creating the class.
|
/// [pickImage] is the function that picks the image and returns it as a [Uint8List].
|
||||||
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, {
|
||||||
|
@ -20,21 +17,16 @@ mixin ImagePickerService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The ImagePickerServiceDefault is the default implementation of the
|
/// The ImagePickerServiceDefault is the default implementation of the ImagePickerService.
|
||||||
/// ImagePickerService.
|
/// It uses the Image Picker package to pick an image and returns it as a [Uint8List].
|
||||||
/// 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
|
/// It's possible to have your own implementation for the Image Picker if you don't want to use the Image Picker Package.
|
||||||
/// 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
|
/// [pickImage] is the function that picks the image and returns it as a [Uint8List].
|
||||||
/// [Uint8List].
|
/// The function requires [source], an [ImageSource] that's the method of how the image needs to be picked, for example gallery or camera.
|
||||||
/// 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, {
|
||||||
|
|
|
@ -2,165 +2,155 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
import "package:flutter/material.dart";
|
import 'package:flutter/material.dart';
|
||||||
import "package:flutter/services.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
|
/// 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:
|
||||||
/// displayed in your application. If you call the class you can give it 4
|
/// The first one is the [ImagePickerTheme] which can be used to change the UI of the widget.
|
||||||
/// optional variables:
|
/// The second one is the [ImagePickerConfig] which can be used to configure the behaviour of the image picker.
|
||||||
/// The first one is the [ImagePickerTheme] which can be used to change the UI
|
/// The third one is your own implementation of the ImagePickerService. Which can be used in testing for example.
|
||||||
/// 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({
|
||||||
this.theme = const ImagePickerTheme(),
|
this.imagePickerTheme = const ImagePickerTheme(),
|
||||||
this.config = const ImagePickerConfig(),
|
this.imagePickerConfig = const ImagePickerConfig(),
|
||||||
this.service,
|
this.imagePickerService,
|
||||||
this.onError,
|
this.customButton,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// 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 theme;
|
final ImagePickerTheme imagePickerTheme;
|
||||||
|
|
||||||
/// ImagePickerConfig can be used to define the size and quality for the
|
/// ImagePickerConfig can be used to define the size and quality for the uploaded image.
|
||||||
/// uploaded image.
|
final ImagePickerConfig imagePickerConfig;
|
||||||
final ImagePickerConfig config;
|
|
||||||
|
|
||||||
/// The ImagePickerService can be used if you want to use your own
|
/// The Image Picker Dialog can have a custom button if you want to.
|
||||||
/// implementation of the Image Service if you want to use it for testing or
|
final Widget? customButton;
|
||||||
/// add more features. If null the current implementation will be used.
|
|
||||||
final ImagePickerService? service;
|
|
||||||
|
|
||||||
final Function(PlatformException error)? onError;
|
/// 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;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => SingleChildScrollView(
|
Widget build(BuildContext context) {
|
||||||
child: Column(
|
return SingleChildScrollView(
|
||||||
children: <Widget>[
|
child: Column(
|
||||||
ListTile(
|
children: <Widget>[
|
||||||
title: Text(
|
ListTile(
|
||||||
theme.title,
|
tileColor: imagePickerTheme.titleBackgroundColor,
|
||||||
style:
|
title: Text(
|
||||||
theme.titleStyle ?? Theme.of(context).textTheme.titleMedium,
|
textAlign: imagePickerTheme.titleAlignment,
|
||||||
textAlign: theme.titleAlignment,
|
imagePickerTheme.title,
|
||||||
|
style: TextStyle(
|
||||||
|
fontFamily: imagePickerTheme.font,
|
||||||
|
fontSize: imagePickerTheme.titleTextSize,
|
||||||
|
color: imagePickerTheme.titleColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Row(
|
),
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
const SizedBox(height: 20),
|
||||||
children: [
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
_generateIconButtonWithText(
|
||||||
|
context,
|
||||||
|
imagePickerTheme.selectImageIcon,
|
||||||
|
imagePickerTheme,
|
||||||
|
Icons.image,
|
||||||
|
ImageSource.gallery,
|
||||||
|
imagePickerTheme.selectImageText,
|
||||||
|
),
|
||||||
|
if (imagePickerConfig.cameraOption ?? true) ...[
|
||||||
|
SizedBox(
|
||||||
|
width: imagePickerTheme.spaceBetweenIcons,
|
||||||
|
),
|
||||||
_generateIconButtonWithText(
|
_generateIconButtonWithText(
|
||||||
context,
|
context,
|
||||||
theme.selectImageIcon,
|
imagePickerTheme.makePhotoIcon,
|
||||||
theme,
|
imagePickerTheme,
|
||||||
Icons.image,
|
Icons.camera_alt_rounded,
|
||||||
ImageSource.gallery,
|
ImageSource.camera,
|
||||||
theme.selectImageText,
|
imagePickerTheme.makePhotoText,
|
||||||
onError,
|
|
||||||
),
|
),
|
||||||
if (config.cameraOption ?? true) ...[
|
]
|
||||||
SizedBox(
|
],
|
||||||
width: theme.spaceBetweenIcons,
|
),
|
||||||
),
|
const SizedBox(height: 10),
|
||||||
_generateIconButtonWithText(
|
Row(
|
||||||
context,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
theme.makePhotoIcon,
|
children: [
|
||||||
theme,
|
SizedBox(
|
||||||
Icons.camera_alt_rounded,
|
width: imagePickerTheme.closeButtonWidth,
|
||||||
ImageSource.camera,
|
height: imagePickerTheme.closeButtonHeight,
|
||||||
theme.makePhotoText,
|
child: customButton ??
|
||||||
onError,
|
ElevatedButton(
|
||||||
),
|
style: ElevatedButton.styleFrom(
|
||||||
],
|
backgroundColor:
|
||||||
],
|
imagePickerTheme.closeButtonBackgroundColor,
|
||||||
),
|
),
|
||||||
if (theme.closeButtonBuilder != null) ...[
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
theme.closeButtonBuilder!.call(
|
child: Text(
|
||||||
() => Navigator.of(context).pop(),
|
imagePickerTheme.closeButtonText,
|
||||||
),
|
style: TextStyle(
|
||||||
] else ...[
|
fontFamily: imagePickerTheme.font,
|
||||||
const SizedBox(height: 30),
|
fontSize: imagePickerTheme.closeButtonTextSize,
|
||||||
Center(
|
color: imagePickerTheme.closeButtonTextColor,
|
||||||
child: SizedBox(
|
),
|
||||||
width: 300,
|
|
||||||
height: 40,
|
|
||||||
child: ElevatedButton(
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
backgroundColor: Colors.black,
|
|
||||||
),
|
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
|
||||||
child: const Text(
|
|
||||||
"Close",
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 15,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 30),
|
|
||||||
],
|
],
|
||||||
],
|
),
|
||||||
),
|
const SizedBox(height: 30),
|
||||||
);
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// The [_generateIconButtonWithText] function returns a column that includes
|
/// The [_generateIconButtonWithText] function returns a column that includes an [IconButton] and [Text].
|
||||||
/// an [IconButton] and [Text].
|
/// The function requires the following parameters to be able to generate an icon with text:
|
||||||
/// The function requires the following parameters to be able to generate an
|
/// [context] The build context that is required to make the [pickImage] function in [_imagePickerService] work.
|
||||||
/// icon with text:
|
/// [imagePickerTheme] The ImagePickerTheme that includes all default values for the Image Picker Dialog.
|
||||||
/// [context] The build context that is required to make the [pickImage]
|
/// [icon] The icon that needs to be displayed, requires an [IconData] as value to be used.
|
||||||
/// function in [_imagePickerService] work.
|
/// [imageSource] The type of [ImageSource] to be used to pick an image when pressed on the icon.
|
||||||
/// [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,
|
||||||
Widget? customIcon,
|
Widget? customIcon,
|
||||||
ImagePickerTheme imagePickerTheme,
|
ImagePickerTheme imagePickerTheme,
|
||||||
IconData icon,
|
IconData icon,
|
||||||
ImageSource imageSource,
|
ImageSource imageSource,
|
||||||
String bottomText,
|
String bottomText) {
|
||||||
Function(PlatformException error)? onError,
|
return Column(
|
||||||
) =>
|
mainAxisSize: MainAxisSize.min,
|
||||||
Column(
|
children: <Widget>[
|
||||||
mainAxisSize: MainAxisSize.min,
|
InkWell(
|
||||||
children: <Widget>[
|
key: Key(bottomText),
|
||||||
InkWell(
|
onTap: () async {
|
||||||
key: Key(bottomText),
|
final navigator = Navigator.of(context);
|
||||||
onTap: () async {
|
var image =
|
||||||
var navigator = Navigator.of(context);
|
await (imagePickerService ?? ImagePickerServiceDefault())
|
||||||
Uint8List? image;
|
.pickImage(imageSource, config: imagePickerConfig);
|
||||||
try {
|
navigator.pop(image);
|
||||||
image = await (service ?? ImagePickerServiceDefault())
|
},
|
||||||
.pickImage(imageSource, config: config);
|
child: customIcon ??
|
||||||
} on PlatformException catch (e) {
|
Icon(
|
||||||
debugPrint("image_picker_error: $e");
|
icon,
|
||||||
onError?.call(e);
|
size: imagePickerTheme.iconSize,
|
||||||
}
|
color: imagePickerTheme.iconColor,
|
||||||
navigator.pop(image);
|
),
|
||||||
},
|
),
|
||||||
child: customIcon ??
|
Text(
|
||||||
Icon(
|
bottomText,
|
||||||
icon,
|
style: TextStyle(
|
||||||
size: imagePickerTheme.iconSize,
|
fontFamily: imagePickerTheme.font,
|
||||||
color: imagePickerTheme.iconColor,
|
fontSize: imagePickerTheme.iconTextSize,
|
||||||
),
|
color: imagePickerTheme.textColor,
|
||||||
),
|
),
|
||||||
Text(
|
),
|
||||||
bottomText,
|
const SizedBox(height: 20),
|
||||||
style: theme.iconTextStyle,
|
],
|
||||||
),
|
);
|
||||||
],
|
}
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
17
pubspec.yaml
17
pubspec.yaml
|
@ -1,24 +1,21 @@
|
||||||
name: flutter_image_picker
|
name: flutter_image_picker
|
||||||
description: A Flutter Image Picking package.
|
description: A Flutter Image Picking package.
|
||||||
version: 4.1.0
|
version: 1.0.4
|
||||||
repository: https://github.com/Iconica-Development/flutter_image_picker
|
repository: https://github.com/Iconica-Development/flutter_image_picker
|
||||||
|
|
||||||
publish_to: https://forgejo.internal.iconica.nl/api/packages/internal/pub
|
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=3.0.0 <4.0.0"
|
sdk: ">=2.17.6 <3.0.0"
|
||||||
flutter: ">=1.17.0"
|
flutter: ">=1.17.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
image_picker: ^1.1.2
|
image_picker: ^0.8.6
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
mocktail: ^1.0.3
|
flutter_lints: ^2.0.0
|
||||||
flutter_iconica_analysis:
|
mocktail: ^0.3.0
|
||||||
git:
|
|
||||||
url: https://github.com/Iconica-Development/flutter_iconica_analysis
|
flutter:
|
||||||
ref: 7.0.0
|
|
||||||
|
|
|
@ -2,22 +2,22 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
import "dart:typed_data";
|
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:flutter_test/flutter_test.dart";
|
import 'package:image_picker/image_picker.dart' as image_picker;
|
||||||
import "package:image_picker/image_picker.dart" as image_picker;
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
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() {
|
||||||
var cameraImage = Uint8List(10);
|
Uint8List cameraImage = Uint8List(10);
|
||||||
var galleryImage = Uint8List(44);
|
Uint8List 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(
|
||||||
const MaterialApp(
|
const MaterialApp(
|
||||||
home: Material(
|
home: Material(
|
||||||
|
@ -26,14 +26,18 @@ void main() {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
var makePhotoIconFinder = find.byIcon(Icons.camera_alt_rounded);
|
final titleFinder =
|
||||||
var makePhotoTextFinder =
|
find.text(const iconica_image_picker.ImagePickerTheme().title);
|
||||||
|
final makePhotoIconFinder = find.byIcon(Icons.camera_alt_rounded);
|
||||||
|
final makePhotoTextFinder =
|
||||||
find.text(const iconica_image_picker.ImagePickerTheme().makePhotoText);
|
find.text(const iconica_image_picker.ImagePickerTheme().makePhotoText);
|
||||||
var selectImageIconFinder = find.byIcon(Icons.image);
|
final selectImageIconFinder = find.byIcon(Icons.image);
|
||||||
var selectImageTextFinder = find
|
final selectImageTextFinder = find
|
||||||
.text(const iconica_image_picker.ImagePickerTheme().selectImageText);
|
.text(const iconica_image_picker.ImagePickerTheme().selectImageText);
|
||||||
var closebuttonTextFinder = find.text("Close");
|
final closebuttonTextFinder = find
|
||||||
|
.text(const iconica_image_picker.ImagePickerTheme().closeButtonText);
|
||||||
|
|
||||||
|
expect(titleFinder, findsOneWidget);
|
||||||
expect(makePhotoIconFinder, findsOneWidget);
|
expect(makePhotoIconFinder, findsOneWidget);
|
||||||
expect(makePhotoTextFinder, findsOneWidget);
|
expect(makePhotoTextFinder, findsOneWidget);
|
||||||
expect(selectImageIconFinder, findsOneWidget);
|
expect(selectImageIconFinder, findsOneWidget);
|
||||||
|
@ -42,26 +46,20 @@ 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 {
|
||||||
var serviceMock = ImagePickerServiceMock();
|
ImagePickerServiceMock 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(
|
await tester.pumpWidget(MaterialApp(
|
||||||
MaterialApp(
|
|
||||||
home: Material(
|
home: Material(
|
||||||
child: iconica_image_picker.ImagePicker(
|
child: iconica_image_picker.ImagePicker(
|
||||||
service: serviceMock,
|
imagePickerService: serviceMock))));
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
var finder = find.byKey(
|
Finder 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,26 +68,20 @@ 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 {
|
||||||
var serviceMock = ImagePickerServiceMock();
|
ImagePickerServiceMock 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(
|
await tester.pumpWidget(MaterialApp(
|
||||||
MaterialApp(
|
|
||||||
home: Material(
|
home: Material(
|
||||||
child: iconica_image_picker.ImagePicker(
|
child: iconica_image_picker.ImagePicker(
|
||||||
service: serviceMock,
|
imagePickerService: serviceMock))));
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
var finder = find.byKey(
|
Finder 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);
|
||||||
|
|
||||||
|
@ -97,42 +89,41 @@ void main() {
|
||||||
.called(1);
|
.called(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets("Image Picker Shows With Custom Theme", (tester) async {
|
testWidgets('Image Picker Shows With Custom Theme', (tester) async {
|
||||||
|
String title = "title";
|
||||||
Widget makePhotoIcon = Container(
|
Widget makePhotoIcon = Container(
|
||||||
height: 125,
|
height: 125,
|
||||||
width: 125,
|
width: 125,
|
||||||
color: Colors.red,
|
color: Colors.red,
|
||||||
);
|
);
|
||||||
var makePhotoText = "taaaake image";
|
String makePhotoText = "taaaake image";
|
||||||
Widget selectImageIcon = Container(
|
Widget selectImageIcon = Container(
|
||||||
height: 125,
|
height: 125,
|
||||||
width: 125,
|
width: 125,
|
||||||
color: Colors.blue,
|
color: Colors.blue,
|
||||||
);
|
);
|
||||||
var selectImageText = "seleeeeect image";
|
String selectImageText = "seleeeeect image";
|
||||||
var closeButtonText = "Close";
|
String closeButtonText = "Close Dialog!";
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(MaterialApp(
|
||||||
MaterialApp(
|
|
||||||
home: Material(
|
home: Material(
|
||||||
child: iconica_image_picker.ImagePicker(
|
child: iconica_image_picker.ImagePicker(
|
||||||
theme: iconica_image_picker.ImagePickerTheme(
|
imagePickerTheme: iconica_image_picker.ImagePickerTheme(
|
||||||
makePhotoIcon: makePhotoIcon,
|
title: title,
|
||||||
makePhotoText: makePhotoText,
|
makePhotoIcon: makePhotoIcon,
|
||||||
selectImageIcon: selectImageIcon,
|
makePhotoText: makePhotoText,
|
||||||
selectImageText: selectImageText,
|
selectImageIcon: selectImageIcon,
|
||||||
),
|
selectImageText: selectImageText,
|
||||||
),
|
closeButtonText: closeButtonText)))));
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
var makePhotoIconFinder = find.byWidget(makePhotoIcon);
|
final titleFinder = find.text(title);
|
||||||
var makePhotoTextFinder = find.text(makePhotoText);
|
final makePhotoIconFinder = find.byWidget(makePhotoIcon);
|
||||||
var selectImageIconFinder = find.byWidget(selectImageIcon);
|
final makePhotoTextFinder = find.text(makePhotoText);
|
||||||
var selectImageTextFinder = find.text(selectImageText);
|
final selectImageIconFinder = find.byWidget(selectImageIcon);
|
||||||
var closebuttonTextFinder = find.text(closeButtonText);
|
final selectImageTextFinder = find.text(selectImageText);
|
||||||
|
final closebuttonTextFinder = find.text(closeButtonText);
|
||||||
|
|
||||||
|
expect(titleFinder, findsOneWidget);
|
||||||
expect(makePhotoIconFinder, findsOneWidget);
|
expect(makePhotoIconFinder, findsOneWidget);
|
||||||
expect(makePhotoTextFinder, findsOneWidget);
|
expect(makePhotoTextFinder, findsOneWidget);
|
||||||
expect(selectImageIconFinder, findsOneWidget);
|
expect(selectImageIconFinder, findsOneWidget);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
import "package:flutter_image_picker/src/services/image_picker_service.dart";
|
import 'package:flutter_image_picker/src/services/image_picker_service.dart';
|
||||||
import "package:mocktail/mocktail.dart";
|
import 'package:mocktail/mocktail.dart';
|
||||||
|
|
||||||
class ImagePickerServiceMock extends Mock implements ImagePickerService {}
|
class ImagePickerServiceMock extends Mock implements ImagePickerService {}
|
||||||
|
|
Loading…
Reference in a new issue