https://github.com/7wilightxdev/gallery_asset_picker
Gallery Asset Picker
https://github.com/7wilightxdev/gallery_asset_picker
asset-picker camera flutter-package gallery-images
Last synced: 4 months ago
JSON representation
Gallery Asset Picker
- Host: GitHub
- URL: https://github.com/7wilightxdev/gallery_asset_picker
- Owner: 7wilightxdev
- License: other
- Created: 2023-06-13T13:16:40.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-22T07:25:57.000Z (almost 2 years ago)
- Last Synced: 2025-05-18T05:16:05.970Z (5 months ago)
- Topics: asset-picker, camera, flutter-package, gallery-images
- Language: Dart
- Homepage:
- Size: 3.99 MB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](#screenshot)
- [Install](#install)
- [Setup](#setup)
- [Usage](#usage)
- [Bugs or Requests](#bugs-or-requests)---
## Screenshot
| Collapse Mode | Expand Mode
| :----------------------------------------------: | :----------------------------------------------:
|  | ---
## Install
### 1. Add dependency
Add this to your package's `pubspec.yaml` file:
```yaml
dependencies:
gallery_asset_picker: ^latest_version
```### 2. Import it
Now in your `Dart` code, you can use:
```dart
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.
```gradle
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.
```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](https://sjudd.github.io/glide/doc/generatedapi.html).### 2. iOS
Add following content to `info.plist`.
```xml
NSPhotoLibraryUsageDescription
Replace with your permission description..
NSCameraUsageDescription
Replace with your permission description..
```---
## Usage
- Use `GalleryAssetPicker.initialize` to config for the gallery
```dart
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
```dart
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
```dart
...
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](https://github.com/haonguyenuet/gallery_asset_picker/issues/new?template=bug_report.md). If you feel the library is missing a feature, please raise a [ticket](https://github.com/haonguyenuet/gallery_asset_picker/issues/new?template=feature_request.md) on GitHub and I'll look into it. Pull request are also welcome.