reusable_editor
A flexible and modular file management package for Flutter, supporting both Firestore and REST API-based storage systems. This package includes file upload/delete operations, state management using Cubits, and various utilities for file/image handling and selection.
Features
- Abstract interfaces for clean architecture
- File upload and delete operations
- Support for Firebase Firestore and custom REST API
- Cubits for managing form states (e.g. image, switch, dropdown, text field)
- Extensions for asset loading as
FileandUint8List - Enum-based dropdown with icon and label support
Getting Started
Installation
Add the following to your pubspec.yaml:
dependencies:
reusable_editor: <latest_version>
Import
import 'package:reusable_editor/reusable_editor.dart';
Usage
File Upload and Delete
final repository = FileRepositoryFireStorageDataSourceImpl(
iFireStorageService: YourFireStorageService(),
);
final uploadUseCase = UploadFile(repository);
final deleteUseCase = DeleteFile(repository);
final result = await uploadUseCase.call(fileEntity);
Dropdown with Enum
enum FileSourceType { firebase, server }
final dropdown = EnumOptionDropDownMenuFormField<FileSourceType>(
selectedValue: selectedOption,
onChanged: (value) => print(value?.type),
hint: 'Select file source',
dropdownItems: [
EnumOptionEntity(type: FileSourceType.firebase, icon: Icons.cloud, label: 'Firebase'),
EnumOptionEntity(type: FileSourceType.server, icon: Icons.storage, label: 'Server'),
],
);
Load Asset as File
final file = await 'assets/image.png'.loadAsFile();
Load Asset as Bytes
final bytes = await 'assets/image.png'.loadAssetImage();
State Management Cubits
DateTimeCubit- Manages date selectionImageCrudCubit- Handles image pick logic and validationSelectionCubit<T>- Generic selection for enum dropdownSwitchCubit- Toggle logicTextFieldCubit- Text field validation
Interfaces
IFileRepository- Upload/Delete abstractionIFileDiConst- Dependency constant keysIFileDiFactory- Abstract DI factory
Contributions
Feel free to open issues or pull requests.
License
MIT License
Libraries
- application/manager/image_form_manager
- config/bloc_provider/register_reusable_editor_bloc_provider
- config/dependency_injection/register_input_fields_get_it_di
- domain/entities/enum_option_entity
- enums/file_data_source_type
- extensions/asset_image_to_file
- extensions/image_loader
- reusable_editor
- view_models/date_time_cubit/date_time_cubit
- view_models/image_field_cubit/image_field_cubit
- view_models/selection_cubit/selection_cubit
- view_models/switch_cubit/switch_cubit
- view_models/text_field_cubit/text_field_cubit