mirror of
https://github.com/Iconica-Development/flutter_image_picker.git
synced 2025-05-18 19:53:45 +02:00
Compare commits
15 commits
Author | SHA1 | Date | |
---|---|---|---|
|
d8e824191a | ||
|
a6f50c54d8 | ||
|
004f0067a4 | ||
|
204e375cb8 | ||
6221ed816f | |||
e208c5031c | |||
|
a80bf1fb87 | ||
|
b3aa961e92 | ||
|
9131a82501 | ||
|
c7114d56ca | ||
|
39f5e82a48 | ||
|
75f3aac3f2 | ||
|
27d8fcd609 | ||
|
f0bac29e7f | ||
|
fdc556c476 |
16 changed files with 167 additions and 167 deletions
14
.github/workflows/component-documentation.yml
vendored
Normal file
14
.github/workflows/component-documentation.yml
vendored
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
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
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -31,3 +31,7 @@ build/
|
||||||
coverage/
|
coverage/
|
||||||
/.flutter-plugins
|
/.flutter-plugins
|
||||||
/.flutter-plugins-dependencies
|
/.flutter-plugins-dependencies
|
||||||
|
|
||||||
|
# FVM Version Cache
|
||||||
|
.fvm/
|
||||||
|
.fvmrc
|
||||||
|
|
16
CHANGELOG.md
16
CHANGELOG.md
|
@ -32,3 +32,19 @@
|
||||||
## 1.0.5 - February 7th 2024
|
## 1.0.5 - February 7th 2024
|
||||||
|
|
||||||
- Added CI and linter
|
- 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`.
|
||||||
|
|
|
@ -11,7 +11,9 @@ void main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ImagePickerExample extends StatelessWidget {
|
class ImagePickerExample extends StatelessWidget {
|
||||||
const ImagePickerExample({Key? key}) : super(key: key);
|
const ImagePickerExample({
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -27,8 +29,10 @@ class ImagePickerExample extends StatelessWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ImagePickerExampleHomePage extends StatefulWidget {
|
class ImagePickerExampleHomePage extends StatefulWidget {
|
||||||
const ImagePickerExampleHomePage({Key? key, required this.title})
|
const ImagePickerExampleHomePage({
|
||||||
: super(key: key);
|
required this.title,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
final String title;
|
final String title;
|
||||||
|
|
||||||
|
@ -112,7 +116,13 @@ 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) => const ImagePicker());
|
builder: (BuildContext context) => 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,6 +6,10 @@
|
||||||
|
|
||||||
#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,6 +3,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
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,6 +5,8 @@
|
||||||
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"))
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
|
|
||||||
#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,6 +3,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
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
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
///
|
///
|
||||||
library flutter_image_picker;
|
library flutter_image_picker;
|
||||||
|
|
||||||
export 'src/models/image_picker_config.dart';
|
export "src/models/image_picker_config.dart";
|
||||||
export 'src/models/image_picker_theme.dart';
|
export "src/models/image_picker_theme.dart";
|
||||||
export 'src/services/image_picker_service.dart';
|
export "src/services/image_picker_service.dart";
|
||||||
export 'src/ui/image_picker.dart';
|
export "src/ui/image_picker.dart";
|
||||||
|
|
|
@ -2,65 +2,32 @@
|
||||||
//
|
//
|
||||||
// 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 a Picture',
|
this.makePhotoText = "TAKE PICTURE",
|
||||||
this.selectImageIcon,
|
this.selectImageIcon,
|
||||||
this.selectImageText = 'Select File',
|
this.selectImageText = "UPLOAD FILE",
|
||||||
this.closeButtonText = 'Close',
|
this.iconTextStyle,
|
||||||
this.closeButtonTextSize = 15,
|
this.closeButtonBuilder,
|
||||||
this.closeButtonTextColor = Colors.white,
|
this.title = "Do you want to upload a file or take a picture?",
|
||||||
this.closeButtonWidth = 300,
|
this.titleStyle,
|
||||||
this.closeButtonHeight = 40,
|
this.titleAlignment = TextAlign.center,
|
||||||
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;
|
||||||
|
|
||||||
|
@ -79,24 +46,13 @@ class ImagePickerTheme {
|
||||||
/// icon.
|
/// icon.
|
||||||
final String selectImageText;
|
final String selectImageText;
|
||||||
|
|
||||||
/// The text that is shown on the 'Close Dialog' button at the bottom of the
|
final TextStyle? iconTextStyle;
|
||||||
/// Image Picker Dialog.
|
|
||||||
final String closeButtonText;
|
|
||||||
|
|
||||||
/// The fontsize of the text of the close button of the Image Picker Dialog.
|
final Widget Function(Function() onTap)? closeButtonBuilder;
|
||||||
final double closeButtonTextSize;
|
|
||||||
|
|
||||||
/// The color of the text of the close button of the Image Picker Dialog.
|
final String title;
|
||||||
final Color closeButtonTextColor;
|
|
||||||
|
|
||||||
/// The width of the 'Close Dialog' button at the bottom of the Image Picker
|
final TextStyle? titleStyle;
|
||||||
/// Dialog.
|
|
||||||
final double closeButtonWidth;
|
|
||||||
|
|
||||||
/// The height of the 'Close Dialog' button at the bottom of the Image Picker
|
final TextAlign titleAlignment;
|
||||||
/// Dialog.
|
|
||||||
final double closeButtonHeight;
|
|
||||||
|
|
||||||
/// The color of the close button of the Image Picker Dialog.
|
|
||||||
final Color closeButtonBackgroundColor;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
//
|
//
|
||||||
// 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.
|
||||||
|
|
|
@ -2,9 +2,10 @@
|
||||||
//
|
//
|
||||||
// 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_image_picker/flutter_image_picker.dart';
|
import "package:flutter/services.dart";
|
||||||
import 'package:image_picker/image_picker.dart';
|
import "package:flutter_image_picker/flutter_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
|
/// displayed in your application. If you call the class you can give it 4
|
||||||
|
@ -18,98 +19,94 @@ import 'package:image_picker/image_picker.dart';
|
||||||
/// 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.imagePickerTheme = const ImagePickerTheme(),
|
this.theme = const ImagePickerTheme(),
|
||||||
this.imagePickerConfig = const ImagePickerConfig(),
|
this.config = const ImagePickerConfig(),
|
||||||
this.imagePickerService,
|
this.service,
|
||||||
this.customButton,
|
this.onError,
|
||||||
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 imagePickerTheme;
|
final ImagePickerTheme theme;
|
||||||
|
|
||||||
/// 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 Image Picker Dialog can have a custom button if you want to.
|
|
||||||
final Widget? customButton;
|
|
||||||
|
|
||||||
/// The ImagePickerService can be used if you want to use your own
|
/// 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
|
/// 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.
|
/// add more features. If null the current implementation will be used.
|
||||||
final ImagePickerService? imagePickerService;
|
final ImagePickerService? service;
|
||||||
|
|
||||||
|
final Function(PlatformException error)? onError;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => SingleChildScrollView(
|
Widget build(BuildContext context) => SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
ListTile(
|
ListTile(
|
||||||
tileColor: imagePickerTheme.titleBackgroundColor,
|
|
||||||
title: Text(
|
title: Text(
|
||||||
textAlign: imagePickerTheme.titleAlignment,
|
theme.title,
|
||||||
imagePickerTheme.title,
|
style:
|
||||||
style: TextStyle(
|
theme.titleStyle ?? Theme.of(context).textTheme.titleMedium,
|
||||||
fontFamily: imagePickerTheme.font,
|
textAlign: theme.titleAlignment,
|
||||||
fontSize: imagePickerTheme.titleTextSize,
|
|
||||||
color: imagePickerTheme.titleColor,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
_generateIconButtonWithText(
|
_generateIconButtonWithText(
|
||||||
context,
|
context,
|
||||||
imagePickerTheme.selectImageIcon,
|
theme.selectImageIcon,
|
||||||
imagePickerTheme,
|
theme,
|
||||||
Icons.image,
|
Icons.image,
|
||||||
ImageSource.gallery,
|
ImageSource.gallery,
|
||||||
imagePickerTheme.selectImageText,
|
theme.selectImageText,
|
||||||
|
onError,
|
||||||
),
|
),
|
||||||
if (imagePickerConfig.cameraOption ?? true) ...[
|
if (config.cameraOption ?? true) ...[
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: imagePickerTheme.spaceBetweenIcons,
|
width: theme.spaceBetweenIcons,
|
||||||
),
|
),
|
||||||
_generateIconButtonWithText(
|
_generateIconButtonWithText(
|
||||||
context,
|
context,
|
||||||
imagePickerTheme.makePhotoIcon,
|
theme.makePhotoIcon,
|
||||||
imagePickerTheme,
|
theme,
|
||||||
Icons.camera_alt_rounded,
|
Icons.camera_alt_rounded,
|
||||||
ImageSource.camera,
|
ImageSource.camera,
|
||||||
imagePickerTheme.makePhotoText,
|
theme.makePhotoText,
|
||||||
|
onError,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
if (theme.closeButtonBuilder != null) ...[
|
||||||
Row(
|
theme.closeButtonBuilder!.call(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
() => Navigator.of(context).pop(),
|
||||||
children: [
|
),
|
||||||
SizedBox(
|
] else ...[
|
||||||
width: imagePickerTheme.closeButtonWidth,
|
const SizedBox(height: 30),
|
||||||
height: imagePickerTheme.closeButtonHeight,
|
Center(
|
||||||
child: customButton ??
|
child: SizedBox(
|
||||||
ElevatedButton(
|
width: 300,
|
||||||
style: ElevatedButton.styleFrom(
|
height: 40,
|
||||||
backgroundColor:
|
child: ElevatedButton(
|
||||||
imagePickerTheme.closeButtonBackgroundColor,
|
style: ElevatedButton.styleFrom(
|
||||||
),
|
backgroundColor: Colors.black,
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
),
|
||||||
child: Text(
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
imagePickerTheme.closeButtonText,
|
child: const Text(
|
||||||
style: TextStyle(
|
"Close",
|
||||||
fontFamily: imagePickerTheme.font,
|
style: TextStyle(
|
||||||
fontSize: imagePickerTheme.closeButtonTextSize,
|
fontSize: 15,
|
||||||
color: imagePickerTheme.closeButtonTextColor,
|
color: Colors.white,
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
const SizedBox(height: 30),
|
||||||
const SizedBox(height: 30),
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -134,6 +131,7 @@ class ImagePicker extends StatelessWidget {
|
||||||
IconData icon,
|
IconData icon,
|
||||||
ImageSource imageSource,
|
ImageSource imageSource,
|
||||||
String bottomText,
|
String bottomText,
|
||||||
|
Function(PlatformException error)? onError,
|
||||||
) =>
|
) =>
|
||||||
Column(
|
Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
@ -142,9 +140,14 @@ class ImagePicker extends StatelessWidget {
|
||||||
key: Key(bottomText),
|
key: Key(bottomText),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
var navigator = Navigator.of(context);
|
var navigator = Navigator.of(context);
|
||||||
var image =
|
Uint8List? image;
|
||||||
await (imagePickerService ?? ImagePickerServiceDefault())
|
try {
|
||||||
.pickImage(imageSource, config: imagePickerConfig);
|
image = await (service ?? ImagePickerServiceDefault())
|
||||||
|
.pickImage(imageSource, config: config);
|
||||||
|
} on PlatformException catch (e) {
|
||||||
|
debugPrint("image_picker_error: $e");
|
||||||
|
onError?.call(e);
|
||||||
|
}
|
||||||
navigator.pop(image);
|
navigator.pop(image);
|
||||||
},
|
},
|
||||||
child: customIcon ??
|
child: customIcon ??
|
||||||
|
@ -156,13 +159,8 @@ class ImagePicker extends StatelessWidget {
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
bottomText,
|
bottomText,
|
||||||
style: TextStyle(
|
style: theme.iconTextStyle,
|
||||||
fontFamily: imagePickerTheme.font,
|
|
||||||
fontSize: imagePickerTheme.iconTextSize,
|
|
||||||
color: imagePickerTheme.textColor,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
12
pubspec.yaml
12
pubspec.yaml
|
@ -1,16 +1,18 @@
|
||||||
name: flutter_image_picker
|
name: flutter_image_picker
|
||||||
description: A Flutter Image Picking package.
|
description: A Flutter Image Picking package.
|
||||||
version: 1.0.5
|
version: 4.1.0
|
||||||
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: ">=2.17.6 <3.0.0"
|
sdk: ">=3.0.0 <4.0.0"
|
||||||
flutter: ">=1.17.0"
|
flutter: ">=1.17.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
image_picker: ^1.0.7
|
image_picker: ^1.1.2
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
@ -19,6 +21,4 @@ dev_dependencies:
|
||||||
flutter_iconica_analysis:
|
flutter_iconica_analysis:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/Iconica-Development/flutter_iconica_analysis
|
url: https://github.com/Iconica-Development/flutter_iconica_analysis
|
||||||
ref: 6.0.0
|
ref: 7.0.0
|
||||||
|
|
||||||
flutter:
|
|
||||||
|
|
|
@ -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: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: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);
|
var cameraImage = Uint8List(10);
|
||||||
var 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(
|
||||||
const MaterialApp(
|
const MaterialApp(
|
||||||
home: Material(
|
home: Material(
|
||||||
|
@ -26,18 +26,14 @@ void main() {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
var titleFinder =
|
|
||||||
find.text(const iconica_image_picker.ImagePickerTheme().title);
|
|
||||||
var makePhotoIconFinder = find.byIcon(Icons.camera_alt_rounded);
|
var makePhotoIconFinder = find.byIcon(Icons.camera_alt_rounded);
|
||||||
var makePhotoTextFinder =
|
var makePhotoTextFinder =
|
||||||
find.text(const iconica_image_picker.ImagePickerTheme().makePhotoText);
|
find.text(const iconica_image_picker.ImagePickerTheme().makePhotoText);
|
||||||
var selectImageIconFinder = find.byIcon(Icons.image);
|
var selectImageIconFinder = find.byIcon(Icons.image);
|
||||||
var selectImageTextFinder = find
|
var selectImageTextFinder = find
|
||||||
.text(const iconica_image_picker.ImagePickerTheme().selectImageText);
|
.text(const iconica_image_picker.ImagePickerTheme().selectImageText);
|
||||||
var closebuttonTextFinder = find
|
var closebuttonTextFinder = find.text("Close");
|
||||||
.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);
|
||||||
|
@ -46,7 +42,7 @@ 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();
|
var serviceMock = ImagePickerServiceMock();
|
||||||
|
|
||||||
|
@ -57,7 +53,7 @@ void main() {
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
home: Material(
|
home: Material(
|
||||||
child: iconica_image_picker.ImagePicker(
|
child: iconica_image_picker.ImagePicker(
|
||||||
imagePickerService: serviceMock,
|
service: serviceMock,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -74,7 +70,7 @@ 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();
|
var serviceMock = ImagePickerServiceMock();
|
||||||
|
|
||||||
|
@ -85,7 +81,7 @@ void main() {
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
home: Material(
|
home: Material(
|
||||||
child: iconica_image_picker.ImagePicker(
|
child: iconica_image_picker.ImagePicker(
|
||||||
imagePickerService: serviceMock,
|
service: serviceMock,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -101,47 +97,42 @@ void main() {
|
||||||
.called(1);
|
.called(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Image Picker Shows With Custom Theme', (tester) async {
|
testWidgets("Image Picker Shows With Custom Theme", (tester) async {
|
||||||
var 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';
|
var 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';
|
var selectImageText = "seleeeeect image";
|
||||||
var closeButtonText = 'Close Dialog!';
|
var closeButtonText = "Close";
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
home: Material(
|
home: Material(
|
||||||
child: iconica_image_picker.ImagePicker(
|
child: iconica_image_picker.ImagePicker(
|
||||||
imagePickerTheme: iconica_image_picker.ImagePickerTheme(
|
theme: iconica_image_picker.ImagePickerTheme(
|
||||||
title: title,
|
|
||||||
makePhotoIcon: makePhotoIcon,
|
makePhotoIcon: makePhotoIcon,
|
||||||
makePhotoText: makePhotoText,
|
makePhotoText: makePhotoText,
|
||||||
selectImageIcon: selectImageIcon,
|
selectImageIcon: selectImageIcon,
|
||||||
selectImageText: selectImageText,
|
selectImageText: selectImageText,
|
||||||
closeButtonText: closeButtonText,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
var titleFinder = find.text(title);
|
|
||||||
var makePhotoIconFinder = find.byWidget(makePhotoIcon);
|
var makePhotoIconFinder = find.byWidget(makePhotoIcon);
|
||||||
var makePhotoTextFinder = find.text(makePhotoText);
|
var makePhotoTextFinder = find.text(makePhotoText);
|
||||||
var selectImageIconFinder = find.byWidget(selectImageIcon);
|
var selectImageIconFinder = find.byWidget(selectImageIcon);
|
||||||
var selectImageTextFinder = find.text(selectImageText);
|
var selectImageTextFinder = find.text(selectImageText);
|
||||||
var closebuttonTextFinder = find.text(closeButtonText);
|
var 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