image_and_file_picker_utility

Creator: coderz1093

Last updated:

0 purchases

TODO
Add to Cart

Description:

image and file picker utility

Introduction #
This Flutter package simplifies the process of picking images from both the camera and gallery, with
built-in permission handling, image cropping, saving picked camera images, image compression, and
file picking functionality. It aims to provide an easy-to-use solution for handling images and files
in your Flutter applications.
Features #

Pick images from camera and gallery with permission handling
Permission handling for camera and storage
Image cropping functionality
Save picked camera images to the device
Image compression for optimized storage usage
File picking with permission handling

Flutter Compatibility #



Package version
Flutter version




0.0.7
3.16.0 - 3.19.3



Getting Started #
To integrate the package into your Flutter project, follow these steps:
Step 1: Add Dependency #
Add the following dependency to your pubspec.yaml file:
dependencies:
image_and_file_picker_utility: ^0.0.7

copied to clipboard
Then run:
flutter pub get

copied to clipboard
Step 2: Android Setup #
Add Permissions to AndroidManifest.xml:
<uses-permission android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>

copied to clipboard
Add activity to the application tag for crop image:
<application>
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:exported="true"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
</activity>
</application>

copied to clipboard
Step 3: IOS Setup #
Add permission to the Podfile like below:
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
'PERMISSION_CAMERA=1',
'PERMISSION_PHOTOS=1',
]
end

end
end

copied to clipboard
Add permission usage to the info.plist file:
<key>NSPhotoLibraryUsageDescription</key>
<string>Our application needs permission to access photos</string>
<key>NSCameraUsageDescription</key>
<string>Our application needs permission to capture photo</string>
copied to clipboard
Usage #
Image:
Image picking with bottom sheet:
await ImagePickerUtil().showImagePickerBottomSheet(
context: context,
isCropImage: true,
savePickedCameraImageToStorage: true,
pickImageImageQuality: 100,
onImageSelection: (File? pickedImage) {},
);

copied to clipboard
Image picking from camera:
File? file = await getFromCameraWithPermissionCheck(
context: context,
permissionDescriptionText: "Permission required to access camera",
isCrop: true,
saveCameraImage: true,
);

copied to clipboard
Image picking from gallery:
File? file = await getFromGalleryWithPermissionCheck(
context: context,
permissionDescriptionText: 'Permission required to access gallery',
isCrop: true,
);

copied to clipboard
Image cropping
import 'package:image_cropper/image_cropper.dart';
copied to clipboard
File? file = await cropImage(
file: File("path"),
context: context,
);

copied to clipboard
File:
import 'package:file_picker/file_picker.dart';
copied to clipboard
final List<File>? pickedFileList = await FilePickerUtil().getFilePicker(
allowMultiple: true,
allowCompression: true,
fileType: FileType.any,
context: context,
/// When you want to pick specific extensions files then choose type as FileType.custom and pass the extensions using allowedExtensions parameter
// fileType:FileType.custom,
// allowedExtensions: ['jpg', 'pdf', 'doc'],
);

copied to clipboard
Permission Handling:
Storage permission:
bool isPermissionGranted = await PermissionHandler().getStoragePermission(
context: context,
permissionDescriptionText: "Permission is required to access files",
);

copied to clipboard
Camera permission:
bool isPermissionGranted = await PermissionHandler().getCameraPermission(
context: context,
permissionDescriptionText: "Permission required to access camera",
);

copied to clipboard
Photos permission (For IOS only):
bool isPermissionGranted = await PermissionHandler().getPhotosPermission(
context: context,
permissionDescriptionText: "Permission required to access photos",
);

copied to clipboard
Open settings for denied permission:
await PermissionHandler().openSettings();
copied to clipboard
ScreenShots #

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files:

Customer Reviews

There are no reviews.