crystallis.dart
💠✨ Data class codegen w/ validation & runtime metadata for Dart
dart pub get crystallis
also see crystallis_codegen (pub.dev)
💙 Use cases
- Data classes with generated copy/get/set methods
- Validation of fields and entire objects at runtime
- Runtime metadata for reflection, serialization, form building, etc
✨ Features
- Codegen-based data classes (
copyWith, constructors, get/set, equality, etc) - Supports both mutable and immutable classes!
- Per-field validation via annotations (
@Min(1),@Max(100),@Regex('^[a-z]+\$'), etc) - JSON-compatible de/serialization
- Per-field customizable serializers via
@Serializer(...)annotation serializemethod returningMap<String, dynamic>- Generates a
deserializeconstructor
- Per-field customizable serializers via
- Runtime reflection (field metadata available for all annotated classes)
copyFrom: copy compatible fields between different data classes- Optional per-class deep copying/equality for collections
- Full-object validation
- String-named getter/setter methods
- Optimized for runtime performance and minimal overhead
Coming up next:
- Support for native/FFI types
ByteBufferserialization/deserialization- More validators
🔮 Usage Guide
Getting Started
-
Add
crystallistodependenciesandcrystallis_generatortodev_dependenciesin yourpubspec.yaml: -
Annotate your data classes with
@CrystallisData()and define fields with validation annotations as needed.
- TODO: Add example here
- Run the code generator:
dart run build_runner build
- Alternatively: use
watchfor continuous code generation during development:
dart run build_runner watch
- Use the generated classes in your application!
Example
/// TODO
Development & Maintenance
TODO
📄 License
This project is licensed under the Mozilla Public License 2.0 - see the LICENSE file for details.
🔥 Contributing
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes. Make sure to read the following guidelines before contributing:
🙏 Credits & Acknowledgements
Contributors 🧑💻💙📝
This package is developed/maintained by the following rockstars! Your contributions make a difference! 💖
Sponsors 🫶✨🥳
Kind thanks to all our sponsors! Thank you for supporting the Dart/Flutter community, and keeping open source alive! 💙
Based on
dart_package_template- a high-quality Dart package template with best practices, CI/CD, and more! 💙✨