Constructs are the building blocks of your Revali project. They are the individual pieces of code that are generated by Revali. In this guide, you will learn how to create a new construct package.
Creating a new package for your construct is the first step in creating a new construct. When this package is imported into your server project, Revali will automatically register the construct and start generating the code.
Creating a new package for your construct serves several purposes. First, it allows Revali to locate the construct properly. Additionally, constructs generally come with their own dependencies and configurations, so isolating them in a separate package helps manage these resources more efficiently. Finally, constructs are added to your server project as a dev_dependency, meaning they won’t be included in the final build of the server project. This separation keeps the final build small by excluding development-only dependencies.
Create Package#
To create a new construct package, you can use the dart create command. This command will create a new Dart package with the necessary files and configurations.
dart create -t package my_construct
This command will create a new directory called my_construct with the following structure:
.
├── example
│ └── my_construct_example.dart
├── lib
│ ├── src
│ │ └── my_construct_base.dart
│ └── my_construct.dart
├── test
│ └── my_construct_test.dart
├── .gitignore
├── analysis_options.yaml
├── CHANGELOG.md
├── pubspec.lock
├── pubspec.yaml
└── README.md