velvet_generator 0.0.1-dev.15
velvet_generator: ^0.0.1-dev.15 copied to clipboard
The code generator for the Velvet framework. It helps to automate some tasks as autoload, service binding, and more.
Velvet Generator #
The generator works with the velvet_annotation package to generate code.
See the example in the velvet_annotation package.
The generator not only exports velvet generators and builders but also wraps vendored generators and builders in build.yaml. (riverpod, freezed, go_router, json_serializable).
So you can use the vendored generators and builders without adding them to your pubspec.yaml.
Velvet Generators #
@VelvetAutoloader #
The @VelvetAutoloader is a simple way to load some files automatically. It is useful for loading plugins or other files that need to be loaded automatically that, otherwise, would need to be imported manually and can be error-prone.
Create a file named lib/loaders/velvet_plugin_loader.velvet.dart then add the following code:
import 'package:velvet_annotation/velvet_annotation.dart';
import 'package:velvet_framework/velvet_framework.dart';
import 'velvet_plugin_loader.velvet.dart';
@VelvetAutoloader(glob: 'lib/**/*_plugin.dart', type: VelvetPlugin)
List velvetPluginLoader() => $velvetPluginLoaderItems;
The generator will generate the velvet_plugin_loader.velvet.dart file that is not a part but a standalone file.
The code generated will be:
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// AutoloaderGenerator
// **************************************************************************
import 'package:your_project/plugins/example_plugin_one.dart';
import 'package:your_project/plugins/example_plugin_two.dart';
import 'package:your_project/plugins/example_plugin_three.dart';
List<VelvetPlugin> $velvetPluginLoaderItems = [
ExamplePluginOne(),
ExamplePluginTwo(),
ExamplePluginThree(),
];
Contributing #
If you would like to contribute to Velvet, please read the contributing guidelines before submitting a pull request.
License #
Velvet is released under the MIT License.