Skip to content

Commit

Permalink
feat: adjust image_picker_plus to flutter 3.16.7
Browse files Browse the repository at this point in the history
Migrated from `image_picker` to `image_picker_plus`.

Completely reworked, refactored and adjusted `image_picker_plus` to the latest flutter version `3.16.7`. Now compatible both on Android and iOS.
  • Loading branch information
itsezlife committed Jan 18, 2024
1 parent 29b435c commit 7e79f60
Show file tree
Hide file tree
Showing 56 changed files with 4,187 additions and 314 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
namespace "com.emilzulufov.flutter_instagram_offline_first_clone"
compileSdkVersion flutter.compileSdkVersion
compileSdkVersion 34
ndkVersion flutter.ndkVersion

compileOptions {
Expand Down
3 changes: 2 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ package="com.emilzulufov.flutter_instagram_offline_first_clone">
<application
android:label="${appName}"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
android:icon="@mipmap/ic_launcher"
android:requestLegacyExternalStorage="true">
<activity
android:name=".MainActivity"
android:exported="true"
Expand Down
90 changes: 32 additions & 58 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,9 @@ PODS:
- AppAuth/Core (1.6.2)
- AppAuth/ExternalUserAgent (1.6.2):
- AppAuth/Core
- DKImagePickerController/Core (4.3.4):
- DKImagePickerController/ImageDataManager
- DKImagePickerController/Resource
- DKImagePickerController/ImageDataManager (4.3.4)
- DKImagePickerController/PhotoGallery (4.3.4):
- DKImagePickerController/Core
- DKPhotoGallery
- DKImagePickerController/Resource (4.3.4)
- DKPhotoGallery (0.0.17):
- DKPhotoGallery/Core (= 0.0.17)
- DKPhotoGallery/Model (= 0.0.17)
- DKPhotoGallery/Preview (= 0.0.17)
- DKPhotoGallery/Resource (= 0.0.17)
- SDWebImage
- SwiftyGif
- DKPhotoGallery/Core (0.0.17):
- DKPhotoGallery/Model
- DKPhotoGallery/Preview
- SDWebImage
- SwiftyGif
- DKPhotoGallery/Model (0.0.17):
- SDWebImage
- SwiftyGif
- DKPhotoGallery/Preview (0.0.17):
- DKPhotoGallery/Model
- DKPhotoGallery/Resource
- SDWebImage
- SwiftyGif
- DKPhotoGallery/Resource (0.0.17):
- SDWebImage
- SwiftyGif
- file_picker (0.0.1):
- DKImagePickerController/PhotoGallery
- blurhash (0.0.1):
- Flutter
- camera_avfoundation (0.0.1):
- Flutter
- Firebase/CoreOnly (10.18.0):
- FirebaseCore (= 10.18.0)
Expand All @@ -60,15 +30,15 @@ PODS:
- Firebase/RemoteConfig (= 10.18.0)
- firebase_core
- Flutter
- FirebaseABTesting (10.19.0):
- FirebaseABTesting (10.20.0):
- FirebaseCore (~> 10.0)
- FirebaseCore (10.18.0):
- FirebaseCoreInternal (~> 10.0)
- GoogleUtilities/Environment (~> 7.12)
- GoogleUtilities/Logger (~> 7.12)
- FirebaseCoreInternal (10.19.0):
- FirebaseCoreInternal (10.20.0):
- "GoogleUtilities/NSData+zlib (~> 7.8)"
- FirebaseInstallations (10.19.0):
- FirebaseInstallations (10.20.0):
- FirebaseCore (~> 10.0)
- GoogleUtilities/Environment (~> 7.8)
- GoogleUtilities/UserDefaults (~> 7.8)
Expand All @@ -89,7 +59,7 @@ PODS:
- FirebaseSharedSwift (~> 10.0)
- GoogleUtilities/Environment (~> 7.8)
- "GoogleUtilities/NSData+zlib (~> 7.8)"
- FirebaseSharedSwift (10.19.0)
- FirebaseSharedSwift (10.20.0)
- Flutter (1.0.0)
- flutter_image_compress_common (1.0.0):
- Flutter
Expand Down Expand Up @@ -168,10 +138,10 @@ PODS:
- Flutter
- FlutterMacOS
- PromisesObjC (2.3.1)
- SDWebImage (5.18.3):
- SDWebImage/Core (= 5.18.3)
- SDWebImage/Core (5.18.3)
- SDWebImageWebPCoder (0.14.0):
- SDWebImage (5.18.10):
- SDWebImage/Core (= 5.18.10)
- SDWebImage/Core (5.18.10)
- SDWebImageWebPCoder (0.14.2):
- libwebp (~> 1.0)
- SDWebImage/Core (~> 5.17)
- shared_preferences_foundation (0.0.1):
Expand All @@ -195,17 +165,20 @@ PODS:
- sqlite3/fts5
- sqlite3/perf-threadsafe
- sqlite3/rtree
- SwiftyGif (5.4.4)
- Toast (4.1.0)
- url_launcher_ios (0.0.1):
- Flutter
- video_player_avfoundation (0.0.1):
- Flutter
- FlutterMacOS
- video_thumbnail (0.0.1):
- Flutter
- libwebp

DEPENDENCIES:
- app_links (from `.symlinks/plugins/app_links/ios`)
- file_picker (from `.symlinks/plugins/file_picker/ios`)
- blurhash (from `.symlinks/plugins/blurhash/ios`)
- camera_avfoundation (from `.symlinks/plugins/camera_avfoundation/ios`)
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
- firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`)
- firebase_remote_config (from `.symlinks/plugins/firebase_remote_config/ios`)
Expand All @@ -223,12 +196,11 @@ DEPENDENCIES:
- sqlite3_flutter_libs (from `.symlinks/plugins/sqlite3_flutter_libs/ios`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
- video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/darwin`)
- video_thumbnail (from `.symlinks/plugins/video_thumbnail/ios`)

SPEC REPOS:
trunk:
- AppAuth
- DKImagePickerController
- DKPhotoGallery
- Firebase
- FirebaseABTesting
- FirebaseCore
Expand All @@ -250,14 +222,15 @@ SPEC REPOS:
- SDWebImage
- SDWebImageWebPCoder
- sqlite3
- SwiftyGif
- Toast

EXTERNAL SOURCES:
app_links:
:path: ".symlinks/plugins/app_links/ios"
file_picker:
:path: ".symlinks/plugins/file_picker/ios"
blurhash:
:path: ".symlinks/plugins/blurhash/ios"
camera_avfoundation:
:path: ".symlinks/plugins/camera_avfoundation/ios"
firebase_core:
:path: ".symlinks/plugins/firebase_core/ios"
firebase_messaging:
Expand Down Expand Up @@ -292,24 +265,25 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/url_launcher_ios/ios"
video_player_avfoundation:
:path: ".symlinks/plugins/video_player_avfoundation/darwin"
video_thumbnail:
:path: ".symlinks/plugins/video_thumbnail/ios"

SPEC CHECKSUMS:
app_links: 5ef33d0d295a89d9d16bb81b0e3b0d5f70d6c875
AppAuth: 3bb1d1cd9340bd09f5ed189fb00b1cc28e1e8570
DKImagePickerController: b512c28220a2b8ac7419f21c491fc8534b7601ac
DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179
file_picker: 15fd9539e4eb735dc54bae8c0534a7a9511a03de
blurhash: 7f29ee116e0c2674e0a765b5df1f9767239bc279
camera_avfoundation: 8b8d780bcfb6a4a02b0fbe2b4bd17b5b71946e68
Firebase: 414ad272f8d02dfbf12662a9d43f4bba9bec2a06
firebase_core: 0af4a2b24f62071f9bf283691c0ee41556dcb3f5
firebase_messaging: 90e8a6db84b6e1e876cebce4f30f01dc495e7014
firebase_remote_config: 14ad7a3c99810d373ba1ad4a754a8cf26c91d476
FirebaseABTesting: bfa3b384b68cee10a89183649c64cd7998a37a12
FirebaseABTesting: 1d5d49804bcfc5fa782bc2491a8c1364e2cf7241
FirebaseCore: 2322423314d92f946219c8791674d2f3345b598f
FirebaseCoreInternal: b444828ea7cfd594fca83046b95db98a2be4f290
FirebaseInstallations: 033d199474164db20c8350736842a94fe717b960
FirebaseCoreInternal: efeeb171ac02d623bdaefe121539939821e10811
FirebaseInstallations: 558b1da7d65afeb996fd5c814332f013234ece4e
FirebaseMessaging: 9bc34a98d2e0237e1b121915120d4d48ddcf301e
FirebaseRemoteConfig: bbd42790a4e84fde6aab7eae810b608e7b5c0bf6
FirebaseSharedSwift: f34eeb7d3ea87a34497629b6ca41657beadef76a
FirebaseSharedSwift: 2fbf73618288b7a36b2014b957745dcdd781389e
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_image_compress_common: ec1d45c362c9d30a3f6a0426c297f47c52007e3e
fluttertoast: 31b00dabfa7fb7bacd9e7dbee580d7a2ff4bf265
Expand All @@ -329,16 +303,16 @@ SPEC CHECKSUMS:
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
photo_manager: 4f6810b7dfc4feb03b461ac1a70dacf91fba7604
PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4
SDWebImage: 96e0c18ef14010b7485210e92fac888587ebb958
SDWebImageWebPCoder: 3027af94522d94df79c21c070894c8a2128927ff
SDWebImage: fc8f2d48bbfd72ef39d70e981bd24a3f3be53fec
SDWebImageWebPCoder: 633b813fca24f1de5e076bcd7f720c038b23892b
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695
sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a
sqlite3: 6e2d4a4879854d0ec86b476bf3c3e30870bac273
sqlite3_flutter_libs: eb769059df0356dc52ddda040f09cacc9391a7cf
SwiftyGif: 93a1cc87bf3a51916001cf8f3d63835fb64c819f
Toast: ec33c32b8688982cecc6348adeae667c1b9938da
url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812
video_player_avfoundation: 02011213dab73ae3687df27ce441fbbcc82b5579
video_thumbnail: c4e2a3c539e247d4de13cd545344fd2d26ffafd1

PODFILE CHECKSUM: 0805b11bfb13bd44fc55fe52946ce14f22a2998e

Expand Down
2 changes: 2 additions & 0 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>FLTEnableImpeller</key>
<false />
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
Expand Down
12 changes: 3 additions & 9 deletions lib/auth/components/signup/components/signup_button.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:io';
import 'dart:typed_data';

import 'package:app_ui/app_ui.dart';
import 'package:flutter/material.dart';
Expand All @@ -9,12 +8,10 @@ import 'package:flutter_instagram_offline_first_clone/auth/components/signup/cub
class SignupButton extends StatelessWidget {
const SignupButton({
super.key,
this.imageBytes,
this.file,
this.avatarFile,
});

final Uint8List? imageBytes;
final File? file;
final File? avatarFile;

@override
Widget build(BuildContext context) {
Expand All @@ -36,10 +33,7 @@ class SignupButton extends StatelessWidget {
}
return AppButton.auth(
'Sign up',
() => context.read<SignupCubit>().onSubmit(
imageBytes: imageBytes,
file: file,
),
() => context.read<SignupCubit>().onSubmit(avatarFile: avatarFile),
style: style,
outlined: true,
);
Expand Down
46 changes: 20 additions & 26 deletions lib/auth/components/signup/cubit/signup_cubit.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:io';
import 'dart:typed_data';

import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
Expand Down Expand Up @@ -191,8 +190,7 @@ class SignupCubit extends Cubit<SignupState> {
/// Defines method to submit form. It is used to check if all inputs are valid
/// and if so, it is used to signup user.
Future<void> onSubmit({
Uint8List? imageBytes,
File? file,
File? avatarFile,
}) async {
final email = Email.validated(state.email.value);
final password = Password.validated(state.password.value);
Expand All @@ -214,32 +212,28 @@ class SignupCubit extends Cubit<SignupState> {
if (!isFormValid) return;

try {
final imageFile = await PickImage.imageWithXImagePicker(
source: ImageSource.gallery,
maxHeight: 820,
maxWidth: 820,
);
final imageBytes =
await PickImage.imageBytes(file: File(imageFile!.path));
final avatarsStorage = Supabase.instance.client.storage.from('avatars');

final fileExt = imageFile.path.split('.').last;
final fileName = '${DateTime.now().toIso8601String()}.$fileExt';
final filePath = fileName;
await avatarsStorage.uploadBinary(
filePath,
imageBytes,
fileOptions: FileOptions(contentType: imageFile.mimeType),
);
final imageUrlResponse = await avatarsStorage.createSignedUrl(
filePath,
60 * 60 * 24 * 365 * 10,
);
String? imageUrlResponse;
if (avatarFile != null) {
final imageBytes =
await PickImage.imageBytes(file: File(avatarFile.path));
final avatarsStorage = Supabase.instance.client.storage.from('avatars');

final fileExt = avatarFile.path.split('.').last.toLowerCase();
final fileName = '${DateTime.now().toIso8601String()}.$fileExt';
final filePath = fileName;
await avatarsStorage.uploadBinary(
filePath,
imageBytes,
fileOptions: FileOptions(contentType: 'image/$fileExt'),
);
imageUrlResponse = await avatarsStorage.createSignedUrl(
filePath,
60 * 60 * 24 * 365 * 10,
);
}

final pushToken = await _notificationsClient.getToken();

logD(pushToken);

await _userRepository.signUpWithPassword(
email: email.value,
password: password.value,
Expand Down
7 changes: 3 additions & 4 deletions lib/auth/components/signup/view/signup_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SignupView extends StatefulWidget {

class _SignupViewState extends State<SignupView> {
Uint8List? _imageBytes;
File? _file;
File? _avatarFile;

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -54,7 +54,7 @@ class _SignupViewState extends State<SignupView> {
onUpload: (imageBytes, file) {
setState(() {
_imageBytes = imageBytes;
_file = file;
_avatarFile = file;
});
},
),
Expand All @@ -64,8 +64,7 @@ class _SignupViewState extends State<SignupView> {
Padding(
padding: const EdgeInsets.symmetric(vertical: 24),
child: SignupButton(
imageBytes: _imageBytes,
file: _file,
avatarFile: _avatarFile,
),
),
],
Expand Down
Loading

0 comments on commit 7e79f60

Please sign in to comment.