Skip to content

Commit

Permalink
Default Images Support Added (0.0.7)
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham16g committed Dec 19, 2022
1 parent f329817 commit cd186a2
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .flutter-plugins
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This is a generated file; do not edit or check into version control.
file_picker=C:\\src\\flutter\\.pub-cache\\hosted\\pub.dartlang.org\\file_picker-5.0.1\\
file_picker=C:\\src\\flutter\\.pub-cache\\hosted\\pub.dartlang.org\\file_picker-5.2.4\\
flutter_plugin_android_lifecycle=C:\\src\\flutter\\.pub-cache\\hosted\\pub.dartlang.org\\flutter_plugin_android_lifecycle-2.0.7\\
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"file_picker","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\file_picker-5.0.1\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"file_picker","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\file_picker-5.0.1\\\\","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-2.0.7\\\\","native_build":true,"dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[{"name":"file_picker","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\file_picker-5.0.1\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"file_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]}],"date_created":"2022-08-29 15:23:49.001503","version":"3.0.1"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"file_picker","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\file_picker-5.2.4\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"file_picker","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\file_picker-5.2.4\\\\","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-2.0.7\\\\","native_build":true,"dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[{"name":"file_picker","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\file_picker-5.2.4\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"file_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]}],"date_created":"2022-12-19 18:52:42.318585","version":"3.3.2"}
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.0.7
- Added support for default images (pre selected images)

## 0.0.6
- 🪲 Fixed some bugs
- Fixed example publishing
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ OR
final controller = MultiImagePickerController(
maxImages: 15,
allowedImageTypes: ['png', 'jpg', 'jpeg'],
images: <ImageFile>[] // array of pre/default selected images
);
```

Expand Down Expand Up @@ -90,6 +91,11 @@ controller.reOrderImage(oldIndex, newIndex); // reorder the image

![custom](https://user-images.githubusercontent.com/55009858/178099563-72e26aea-0a06-43c2-8315-25c7a0d039fb.gif)

## Contributors

<a href="https://github.com/shubham-gupta-16/multi_image_picker_view/graphs/contributors">
<img src="https://contrib.rocks/image?repo=shubham-gupta-16/multi_image_picker_view" />
</a>

## Contributing

Expand Down
31 changes: 12 additions & 19 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.8.2"
version: "2.9.0"
boolean_selector:
dependency: transitive
description:
Expand All @@ -21,21 +21,14 @@ packages:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
version: "1.2.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
collection:
dependency: transitive
description:
Expand Down Expand Up @@ -63,7 +56,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.3.1"
ffi:
dependency: transitive
description:
Expand Down Expand Up @@ -134,21 +127,21 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.11"
version: "0.12.12"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4"
version: "0.1.5"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.0"
multi_image_picker_view:
dependency: "direct main"
description:
Expand All @@ -162,7 +155,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.8.2"
plugin_platform_interface:
dependency: transitive
description:
Expand All @@ -181,7 +174,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.2"
version: "1.9.0"
stack_trace:
dependency: transitive
description:
Expand All @@ -202,21 +195,21 @@ packages:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.1.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.2.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.9"
version: "0.4.12"
vector_math:
dependency: transitive
description:
Expand Down
29 changes: 16 additions & 13 deletions lib/src/multi_image_picker_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ class MultiImagePickerController with ChangeNotifier {
final List<String> allowedImageTypes;
final int maxImages;

MultiImagePickerController({this.allowedImageTypes = const ['png', 'jpeg', 'jpg'], this.maxImages = 10, Iterable<ImageFile>? images}) {
MultiImagePickerController(
{this.allowedImageTypes = const ['png', 'jpeg', 'jpg'],
this.maxImages = 10,
Iterable<ImageFile>? images}) {
if (images != null) {
_images = List.from(images);
} else {
_images = [];
}
print('init');
}

late final List<ImageFile> _images;
Expand All @@ -30,11 +32,20 @@ class MultiImagePickerController with ChangeNotifier {
/// this method open Image picking window.
/// It returns [Future] of [bool], true if user has selected images.
Future<bool> pickImages() async {
FilePickerResult? result = await FilePicker.platform.pickFiles(allowMultiple: true, type: FileType.custom, allowedExtensions: allowedImageTypes);
FilePickerResult? result = await FilePicker.platform.pickFiles(
allowMultiple: true,
type: FileType.custom,
allowedExtensions: allowedImageTypes);
if (result != null && result.files.isNotEmpty) {
_addImages(result.files
.where((e) => e.extension != null && allowedImageTypes.contains(e.extension?.toLowerCase()))
.map((e) => ImageFile(name: e.name, extension: e.extension!, bytes: e.bytes, path: !kIsWeb ? e.path : null)));
.where((e) =>
e.extension != null &&
allowedImageTypes.contains(e.extension?.toLowerCase()))
.map((e) => ImageFile(
name: e.name,
extension: e.extension!,
bytes: e.bytes,
path: !kIsWeb ? e.path : null)));
notifyListeners();
return true;
}
Expand Down Expand Up @@ -64,12 +75,4 @@ class MultiImagePickerController with ChangeNotifier {
_images.remove(imageFile);
notifyListeners();
}

@override
void dispose() {
print(_images);
print('dispose');
super.dispose();
print(_images);
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: multi_image_picker_view
description: A complete widget which can easily pick multiple images from device and display them in UI. Also picked image can be re-ordered and removed easily.
version: 0.0.6
version: 0.0.7
homepage: https://github.com/shubham-gupta-16/multi_image_picker_view
repository: https://github.com/shubham-gupta-16/multi_image_picker_view
issue_tracker: https://github.com/shubham-gupta-16/multi_image_picker_view/issues
Expand Down

0 comments on commit cd186a2

Please sign in to comment.