A robust and extensible Dart/Flutter package that simplifies image and file upload handling across platforms using SOLID principles and clean architecture. This package provides a foundation to manage file conversions, categorization, and streamlined upload/delete operations with support for multiple file types like XFile, File, and PlatformFile.
- ✅ Platform-agnostic file support (
XFile,File,PlatformFile) - 📦 Convert file data to standardized
UploadFileformat - 🧱 Enum-based file categorization (
image,video,document,audio,other) - 🧩 Extension-based conversion utilities
- 📄 MIME type detection and content type resolution
- 🧪 Functional error handling using
Either<IFailure, TResult>fromdartz - 🔁 Optional toast notification messages on success
flutter pub add image_coreConverts a XFile into a standardized UploadFile.
Converts a PlatformFile from file_picker to UploadFile.
Converts a regular Dart File to an UploadFile.
Generates a fallback file name based on timestamp if null or empty.
Extracts the file extension from a filename or path.
class UploadFile {
final Uint8List bytes;
final String? name;
final String? mimeType;
final String? collectionPath;
final String? uploadingToastTxt;
final Map<String, String>? metadata;
final String? contentDisposition;
final FileCategory category;
...
}The FileCategory enum includes:
imagevideodocumentaudioother
Resolved based on MIME type via FileCategoryResolver.
dartz: Functional programming support (Either)exception_type: CommonIFailureinterfacei_tdd: Toast or UI feedback handler withhandleReport()cross_file,file_picker,mime: Platform and file type support
MIT License. See LICENSE file for details.
Feel free to open issues, suggest features, or submit PRs. Contributions are welcome!
firebase_storage_managerfile_pickerfluttertoastimage_picker
You want to upload an image picked via image_picker:
final XFile? file = await ImagePicker().pickImage(source: ImageSource.gallery);
final UploadFile uploadFile = await file.toUploadFileFromXFile(
collectionPath: 'profiles/$id/images',
);
image_core Developed with ❤️ by Shohidul Islam