Draggable Items Package
Features
Predefined Draggable Items: A list of common UI elements like Text Fields, Checkboxes, Radio Buttons, and more.
Easily Extendable: Allows developers to add new draggable items or modify existing ones.
Supports Images: Each draggable item includes an associated image for easy visualization.
Installation
To use this package, add the following to your pubspec.yaml file:
dependencies:
draggable_items_package:
git:
url: https://github.com/yourusername/draggable_items_package.git
ref: main
Then, run flutter pub get to install the package.
Import the Package
Import the package in your Dart file:
import 'package:draggable_items_package/draggable_items_package.dart';
Usage
Access Draggable Items
The package provides a list of draggable items (draggableItems) that can be easily accessed and used:
import 'package:draggable_items_package/draggable_items_package.dart';
void main() {
for (var item in draggableItems) {
print('Label: ${item.label}, Image: ${item.image}');
}
}
Create Custom Form Elements
You can create custom form elements using the FormElement class:
FormElement customElement = FormElement(
type: FormElementType.textField,
label: 'Custom Text Field',
value: 'Initial Value',
);
Display Draggable Items in a ListView
import 'package:flutter/material.dart';
import 'package:draggable_items_package/draggable_items_package.dart';
class DraggableItemsList extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ListView.builder(
itemCount: draggableItems.length,
itemBuilder: (context, index) {
final item = draggableItems[index];
return ListTile(
leading: Image.asset(item.image),
title: Text(item.label),
);
},
);
}
}
Assets Configuration
Ensure that you have added the necessary assets to your pubspec.
flutter:
assets:
- assets/images/textinput.png
- assets/images/textfield.png
- assets/images/dropdown.png
- assets/images/listview.png
- assets/images/grid.png
- assets/images/checkbox.png
- assets/images/row.png
- assets/images/column.png
- assets/images/calender.png
Testing
To run the tests, navigate to the package root directory and run:
flutter test
Contributing
Contributions are welcome! Feel free to open issues or submit pull ### requests to help improve this package.
Fork the repository.
Create a new branch (git checkout -b feature/your-feature).
Make your changes.
Commit your changes (git commit -m 'Add your feature').
Push to the branch (git push origin feature/your-feature).
Open a Pull Request.
License