crystallis 0.0.3 copy "crystallis: ^0.0.3" to clipboard
crystallis: ^0.0.3 copied to clipboard

Data class codegen w/ validation & runtime metadata for Dart

crystallis.dart #

💠✨ Data class codegen w/ validation & runtime metadata for Dart

dart pub get crystallis

also see crystallis_codegen (pub.dev)

License: MPL 2.0 build example stars
pub package pub score likes

💙 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
    • serialize method returning Map<String, dynamic>
    • Generates a deserialize constructor
  • 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
  • ByteBuffer serialization/deserialization
  • More validators

🔮 Usage Guide #

Getting Started #

  1. Add crystallis to dependencies and crystallis_generator to dev_dependencies in your pubspec.yaml:

  2. Annotate your data classes with @CrystallisData() and define fields with validation annotations as needed.

  • TODO: Add example here
  1. Run the code generator:
dart run build_runner build
  • Alternatively: use watch for continuous code generation during development:
dart run build_runner watch
  1. 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! 💖

contributors badge

Sponsors 🫶✨🥳 #

Kind thanks to all our sponsors! Thank you for supporting the Dart/Flutter community, and keeping open source alive! 💙

sponsors badge


Based on dart_package_template - a high-quality Dart package template with best practices, CI/CD, and more! 💙✨

0
likes
160
points
283
downloads

Publisher

unverified uploader

Weekly Downloads

Data class codegen w/ validation & runtime metadata for Dart

Repository (GitHub)
View/report issues

Documentation

API reference

License

MPL-2.0 (license)

Dependencies

collection, meta

More

Packages that depend on crystallis