Gallery Asset Picker
A gallery picker and camera in one package. The Gallery and Camera views can both be utilized as Flutter widgets
Table of contents
Screenshot
Collapse Mode | Expand Mode |
---|---|
Install
1. Add dependency
Add this to your package's pubspec.yaml
file:
dependencies:
gallery_asset_picker: ^latest_version
2. Import it
Now in your Dart
code, you can use:
import 'package:gallery_asset_picker/gallery_asset_picker.dart';
Setup
For more details (if needed) you can go through Photo Manager and Camera readme section as well.
1. Android
- Change the minimum Android sdk version to 21 (or higher) in your
android/app/build.gradle
file.
minSdkVersion 21
-
Required permissions:
READ_EXTERNAL_STORAGE
,WRITE_EXTERNAL_STORAGE
,ACCESS_MEDIA_LOCATION
. -
Glide
Android native use glide to create image thumb bytes, version is 4.11.0.
If your other android library use the library, and version is not same, then you need edit your android project's build.gradle.
rootProject.allprojects {
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.github.bumptech.glide'
&& details.requested.name.contains('glide')) {
details.useVersion '4.11.0'
}
}
}
}
}
If you found some warning logs with Glide
appearing,
then the main project needs an implementation of AppGlideModule
.
See Generated API.
2. iOS
Add following content to info.plist
.
<key>NSPhotoLibraryUsageDescription</key>
<string>Replace with your permission description..</string>
<key>NSCameraUsageDescription</key>
<string>Replace with your permission description..</string>
Usage
- Use
GalleryAssetPicker.initialize
to config for the gallery
GalleryAssetPicker.initialize(GalleryConfig(
enableCamera: true,
crossAxisCount: 3,
colorScheme: const ColorScheme.light(primary: Colors.blue),
onReachMaximum: () {
Fluttertoast.showToast(
msg: "You have reached the allowed number of images",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER,
textColor: Colors.white,
fontSize: 16.0,
);
},
textTheme: const TextTheme(
bodyMedium: TextStyle(fontSize: 16),
titleMedium: TextStyle(fontSize: 14, fontWeight: FontWeight.w700),
titleSmall: TextStyle(fontSize: 14, fontWeight: FontWeight.w500),
),
));
- To make the gallery view sliding, use the
SlidableGalleryOverlay
; otherwise, ignore it
class SlidableGalleryDemo extends StatelessWidget {
late final GalleryController galleryController;
...
@override
Widget build(BuildContext context) {
return SlidableGalleryOverlay(
controller: galleryController,
child: Scaffold(
body: ...
),
);
}
}
- Using
GalleryAssetPicker.pick()
to pick assets
...
onPressed : () async {
final _selectedAssets = await GalleryAssetPicker.pick(
context,
maxCount: 5,
requestType: RequestType.image,
);
}
...
- You can use other widgets included in the package, and for a more thorough implementation and modification, browse the example app
Bugs or Requests
If you encounter any problems feel free to open an issue. If you feel the library is missing a feature, please raise a ticket on GitHub and I'll look into it. Pull request are also welcome.
Libraries
- configs/camera_config
- configs/configs
- configs/gallery_config
- configs/slide_sheet_config
- entities/gallery_asset
- features/camera/camera
- features/camera/camera_page
- features/camera/controllers/camera_controller
- features/camera/controllers/controllers
- features/camera/exceptions/camera_exceptions
- features/camera/values/camera_value
- features/camera/values/values
- features/camera/widgets/camera_builder
- features/camera/widgets/raw_camera_view
- features/camera/widgets/widgets
- features/features
- features/gallery/controllers/album_controller
- features/gallery/controllers/album_list_controller
- features/gallery/controllers/controllers
- features/gallery/controllers/gallery_controller
- features/gallery/enums/fetch_state
- features/gallery/gallery
- features/gallery/values/album_list_value
- features/gallery/values/album_value
- features/gallery/values/gallery_value
- features/gallery/values/values
- features/gallery/widgets/album_list_view
- features/gallery/widgets/builder/album_builder
- features/gallery/widgets/builder/album_list_builder
- features/gallery/widgets/builder/gallery_builder
- features/gallery/widgets/gallery_asset_thumbnail
- features/gallery/widgets/gallery_assets_grid_view
- features/gallery/widgets/gallery_controller_provider
- features/gallery/widgets/gallery_full_screen_page
- features/gallery/widgets/gallery_header
- features/gallery/widgets/gallery_view
- features/gallery/widgets/slidable_gallery_overlay
- features/gallery/widgets/widgets
- gallery_asset_picker
- utils/const
- utils/gallery_manager
- utils/system_utils
- utils/utils
- widgets/animations/page_route
- widgets/gallery_permission_view
- widgets/keyboard_visibility
- widgets/lazy_load_scroll_view
- widgets/slide_sheet/builder/slide_sheet_size_builder
- widgets/slide_sheet/builder/slide_sheet_value_builder
- widgets/slide_sheet/builder/slide_sheet_value_listener
- widgets/slide_sheet/slide_sheet
- widgets/widgets