fire_storage_impl
A lightweight Dart/Flutter package for simplified Firebase Storage file uploading and deletion, supporting both mobile and web platforms. It includes toast notifications and localized error messages via a translator service.
Features
- Upload files with
XFile
(cross‑platform) - Delete uploaded files from Firebase Storage
- Toast message integration using
app_toast
- Context-free localization support via
.translateWithoutContext()
- Automatic file name generation when not provided
- Upload progress tracking via
onProgress
callback - Safe storage path building with
StoragePathExtensions
Installation
Add this to your pubspec.yaml
:
dependencies:
fire_storage_impl: <latest_version>
Then run:
flutter pub get
Usage
Upload a File with XFile
final fireStorage = FireStorageServiceImpl();
final file = XFile('/path/to/image.jpg');
final url = await fireStorage.uploadFile(
file: file,
category: 'images',
collectionPath: 'user_uploads',
onProgress: (progress) {
print('Upload progress: $progress');
},
);
Delete a File
final success = await fireStorage.deleteFile(
imgUrl: url!,
successTxt: 'Deleted successfully!',
);
Build Safe Storage Path
final fullPath = StoragePathExtensions.buildStoragePath(
category: 'images',
collectionPath: 'profile_pics',
fullName: 'avatar.png',
);
Requirements
- Firebase Core & Firebase Storage setup
- Add
app_toast
andtranslator
dependencies - Internet permission (mobile)
Dependencies
- firebase_storage
- cross_file
- app_toast
- translator (custom)
License
This README.md
provides installation instructions, basic usage examples, error handling, and additional features. Make sure to replace the version placeholder with the actual version number when you publish it on pub.flutter-io.cn
.
Developed and Maintained with ❤️ by Shohidul Islam / GenieCoder. Contributions welcome!
Libraries
- constants/fire_storage_txt_const
- data/data_sources/fire_storage_service_impl
- data/data_sources/i_data_sources/i_fire_storage_service
- extensions/file_name_generator
- extensions/image_uploader
- extensions/path_extensions
- extensions/string_file_extension_ext
- fire_storage_impl
- typedefs/progress_callback
- utils/content_type_util
- utils/firebase_platform_exception_handler