reusable_editor 1.3.0
reusable_editor: ^1.3.0 copied to clipboard
A modular form and file editor package for Flutter with support for Form widgets. Includes Cubit-based state management, form field validation, and UI input widgets.
reusable_editor #
A flexible and modular file management and form handling package for Flutter, supporting both Firestore and REST API-based storage systems along with comprehensive form field management. This package includes file operations, form state management using Cubits, and a collection of reusable form field widgets.
Features #
- Abstract interfaces for clean architecture
- Cubits for managing form states (e.g., image, switch, dropdown, text field, multi-select)
- Complete set of reusable form field widgets
- Extensions for asset loading as
FileandUint8List - Enum-based dropdown and multi-select checkbox groups 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';
📘 Documentation #
Full usage guides available at: 👉 https://geniecodersrc.github.io/reusable_editor/
Usage #
Form Field Management #
// Create cubit for a field
final textFieldCubit = TextFieldCubit(
initialValue: 'Default',
validator: RequiredValidator(),
);
// Use with AppTextField
AppTextField(cubit: textFieldCubit, label: 'Name');
// Toggle field example
final toggleCubit = ToggleCubit(initialValue: false);
AppSwitch(cubit: toggleCubit);
Available Form Widgets #
AppCheckbox- Checkbox with label and validationAppDatePicker- Date selection fieldAppDropdown- Custom dropdown fieldAppFilePicker- File selection widgetAppRadioGroup- Radio button groupAppRangeSlider- Range slider inputAppSlider- Slider inputAppSwitch- Toggle switchAppTimePicker- Time selection fieldAppTextField- Text input fieldEnumOptionDropDownMenuFormField- Dropdown for Enum valuesEnumMultiOptionCheckboxGroup- Multi-select checkbox group for Enums
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'),
],
);
Multi Select Enum (MultiEnumOptionCubit) #
enum ReactionType {
like,
love,
laugh,
wow,
sad,
angry,
}
final reactionsCubit = MultiEnumOptionCubit<ReactionType>(
options: [
EnumOptionEntity(type: ReactionType.like, label: 'Like', icon: Icons.thumb_up),
EnumOptionEntity(type: ReactionType.love, label: 'Love', icon: Icons.favorite),
EnumOptionEntity(type: ReactionType.laugh, label: 'Laugh', icon: Icons.emoji_emotions),
EnumOptionEntity(type: ReactionType.wow, label: 'Wow', icon: Icons.sentiment_very_satisfied),
EnumOptionEntity(type: ReactionType.sad, label: 'Sad', icon: Icons.sentiment_dissatisfied),
EnumOptionEntity(type: ReactionType.angry, label: 'Angry', icon: Icons.sentiment_very_dissatisfied),
],
);
// Use the Widget
EnumMultiOptionCheckboxGroup<ReactionType>(
cubit: reactionsCubit,
);
// Toggle selection
reactionsCubit.toggleOptionByType(ReactionType.like);
// Read selected values
final selectedReactions = reactionsCubit.selectedTypes;
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 #
FieldCubit<T>- Generic form field management with validationToggleCubit- Specialized cubit for boolean toggle fieldsDateTimeCubit- Manages date selectionImageCrudCubit- Handles image pick logic and validationEnumOptionCubit<T>- Dropdown selection with generic enumMultiEnumOptionCubit<T>- Multi-select enum field managementSwitchCubit- Toggle logicTextFieldCubit- Text field validation
Contributions #
Feel free to open issues or pull requests.
License #
© MIT License. Developed with ❤️ by Shohidul Islam