reusable_image_widget
Reusable Flutter widgets and utilities for picking, cropping, compressing, and displaying images with easy configuration.
Features
- Pick images from the gallery or camera
- Crop images with custom aspect ratio presets
- Compress picked images
- Display images from assets, files, or network URLs
- Fullscreen image viewer with zooming
- Circular avatar widgets
- Image placeholders and error handling
Installation
Add this to your pubspec.yaml
:
reusable_image_widget: ^0.0.2
Then run:
flutter pub get
Usage
Pick and Crop Image
final XFile? pickedImage = await pickImage(source: ImageSource.gallery);
if (pickedImage != null) {
final XFile croppedImage = await cropImage(pickedFile: pickedImage, context: context);
}
Compress Image
final XFile compressedImage = await compressImage(pickedImage);
Display Image
BuildAvatarImage(
imageSource: 'https://example.com/image.jpg',
)
or from an asset:
BuildAvatarImage(
imageSource: 'assets/images/profile_pic.jpeg',
)
Use AppCircleAvatar
AppCircleAvatar(
imageSource: 'https://example.com/profile.jpg',
radius: 40,
)
Full Screen Viewer
AvatarImageViewer(
image: pickedFile,
imageSource: 'https://example.com/image.jpg',
)
Pick Image with Cubit
AppImagePicker(
onChanged: (file) {
// Do something with the picked image
},
)
Show Network Image with Fallback
CachedImage(
'https://example.com/image.jpg',
radius: 50,
isRound: true,
)
Dependencies
flutter
image_picker
image_cropper
flutter_image_compress
cached_network_image
photo_view
flutter_bloc
Example
A complete usage example can be found in the example/
directory.
License
MIT License
Author
reusable_image_widget developed and maintained by Shohidul Islam
Feel free to contribute, open issues, and submit pull requests!
Libraries
- app_circle_avatar
- app_image_picker
- app_image_provider
- app_image_viewer
- app_rectangle_avatar
- avatar_image_picker
- avatar_image_viewer
- avater_with_title
- cached_image
- circle_avatar_with_online_indicator
- constants/default_image_path
- full_screen_image_viewer
- image_source_item_selector
- image_source_selector
- image_style_constant
- reusable_image_widget
- utils/build_avatar_image
- utils/comprass_image
- utils/crop_image
- utils/image_source_type_checker
- utils/picked_image
- view_models_image_picker/image_picker_cubit