photos_native

Last updated:

0 purchases

photos_native Image
photos_native Images
Add to Cart

Description:

photos native

photos_native #
A Flutter native plugin for photo library.
1. Getting Started #
photos_native is high performance, yet easy to use photo library plugin, working on Android and iOS. It can load albums, load image/thumnail, save, share... photo images.



iOS
Android









Install #


With Flutter:
$ flutter pub add photos_native
copied to clipboard


YAML
dependencies:
photos_native: ^0.0.1
copied to clipboard


Working with library #
Set up your project #
This library depends on flutter-permission-handler, so you need to set up correct permission before using.
While the permissions are being requested during runtime, you'll still need to tell the OS which permissions your app might potentially use. That requires adding permission configuration to Android- and iOS-specific files.

Android
You don't need to setup anything if you target SDK 30 or above.
If your compileSdkVersion/targetSdkVersion is 29, you can consider adding android:requestLegacyExternalStorage="true"
to your AndroidManifest.xml in order to obtain resources:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.your_package">

<application android:label="{appName}"
android:icon="@mipmap/ic_launcher"
android:requestLegacyExternalStorage="true">
</application>
</manifest>
copied to clipboard


iOS
1. Add the following to your `Podfile` file:
post_install do |installer|
installer.pods_project.targets.each do |target|
... # Here are some configurations automatically generated by flutter

# Start of the permission_handler configuration
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',

## dart: PermissionGroup.photos
'PERMISSION_PHOTOS=1',
]

end
# End of the permission_handler configuration
end
end
copied to clipboard

Config plist file
Add key NSPhotoLibraryUsageDescription to the the ios/Runner/Info.plist:

<key>NSPhotoLibraryUsageDescription</key>
<string>App needs access to photo library</string>
copied to clipboard

Usage #
Basic Concepts #
PHItem is a photo item on device, PHItem has an photo ID exclusively or file URI.
PHAlbum is abstract version of MediaStore bucket on Android, or PHAssetCollection on iOS. PHAlbum can contains multiple PHItems.
PHGallery contains all photo albums on the device.
Default album is All Photos which contains all photos in gallery (user can select any name to default albums)
PHImageDescriptor is a image descriptor, PHImageDescriptor contain pixel bytes, width and height of the image.
Request permission #
Request permission for photo library
await PhotosNative.requestPermissions();
copied to clipboard
Get photo gallery #
final gallery = await PhotosNative.loadGallery(title: 'All Photos');
copied to clipboard
See PHGallery for more details
Get thumbnail image descriptor #
Return thumbnail image descriptor
final descriptor = await PhotosNative.getThumbnail(200, 200, 'id');

// or load from uri

final descriptor = await PhotosNative.getThumbnail(200, 200, 'image uri');
copied to clipboard
See class PHImageDescriptor for more details
Get image descriptor #
Return image descriptor of a photo
final descriptor = await PhotosNative.getPixels('photo_id');
copied to clipboard
See class PHImageDescriptor for more details
Delete images #
Return the number of deleted images
await PhotosNative.delete(['photo_id', 'photo_id2']);
copied to clipboard
Save image #
Save image to a path/directory ...
await PhotosNative.save(bytes, width, height, path: path);
copied to clipboard
Share image #
Share image with other apps
await PhotosNative.share(bytes, width, height);
copied to clipboard
Experiment #
Working with Flutter backend texture. Read Flutter Texture for more details. You can experiment these features to check if it can improve your app performance.
Load image texture #
int textureId = await PhotosNative.acquireTexture(id, width, height);

// usage
Container(child: Texture(textureId: textureId));
copied to clipboard
Release image texture #
await PhotosNative.releaseTexture(id);
copied to clipboard
Author #
This photo plugin for Flutter is developed by Annotium 👈.
Contact us at email

License:

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

Files In This Product:

Customer Reviews

There are no reviews.