Requirements
- Dart SDK 3.9 or higher
- Flutter 3.32 or higher (latest stable recommended)
- A Vyuh Framework project with vyuh_core configured
Authenticate with pub.vyuh.tech first
The Entity System packages is hosted on the private pub.vyuh.tech registry. Before running pub get, register a Bearer token issued by Vyuh Technologies based on your plan.
Run the one-time setup:
dart pub token add https://pub.vyuh.techDon't have a token yet? Email ask@vyuh.tech to request one. For full details (CI, Docker, rotation, troubleshooting), see the Pub Token Setup guide.
Add Dependencies
Add vyuh_entity_system, vyuh_entity_system_ui, vyuh_entity_annotations and vyuh_entity_generator to your pubspec.yaml as hosted dependencies:
Then resolve dependencies:
Run the code generator to materialize the *.g.dart files:
Setup
The entity system ships as five focused packages. For a Flutter app, you typically pull in two runtime packages and the annotations + generator pair:
vyuh_entity_system— widget-free runtime: models, API, services, authorization, plugin system.vyuh_entity_system_ui— Flutter widgets, layouts, editors, route builders, command palette wiring. Re-exportsvyuh_entity_system.vyuh_entity_annotations— pure-Dart@Entity/@Field/@ServerEntityannotations and theAuthorizeDSL.vyuh_entity_generator—build_runnerbuilder that turns the annotations into*.entity.dartand*.server.dartpart files.
Annotations & code generation
The fastest path is annotations + generator. Skip them only if you really want to hand-write every FieldDefinition, API client, and configuration — see the Packages page for both flavours.
1. Create the Entity System Plugin
The EntitySystemPlugin is the central entry point. Register it with your Vyuh application:
import 'package:vyuh_entity_system/vyuh_entity_system.dart';
final entityPlugin = EntitySystemPlugin(
baseUrl: 'https://api.example.com',
// OpenAuthorizationProvider grants every Authorize check — perfect for
// local development. Swap in a real AuthorizationProvider for production.
authorizationProvider: OpenAuthorizationProvider(),
);2. Register with Vyuh Platform
Add the plugin to your Vyuh platform initialization:
import 'package:vyuh_core/vyuh_core.dart';
import 'package:vyuh_entity_system/vyuh_entity_system.dart';
vyuh.runApp(
plugins: PluginDescriptor(
content: DefaultContentPlugin(...),
others: [entityPlugin],
),
features: () => [
myFeature,
],
);3. Register Entities via Feature Descriptor
Entities are registered through EntityExtensionDescriptor inside a feature:
import 'package:vyuh_core/vyuh_core.dart';
import 'package:vyuh_entity_system/vyuh_entity_system.dart';
final lmsFeature = FeatureDescriptor(
name: 'lms',
title: 'Learning Management System',
extensions: [
EntityExtensionDescriptor(
entities: [
courseConfig,
participantConfig,
trainerConfig,
],
),
],
);Each EntityConfiguration is registered with the plugin during feature initialization. The plugin automatically generates GoRouter routes for every entity whose metadata has route visibility. MenuVisibility also implies a route because menu entries must be navigable.
Verify the Setup
After setup, your entities should appear in the application's navigation menu (when their EntityMetadata.visibility includes MenuVisibility) and their routes should be accessible.
You can verify registration programmatically:
// Access the entity system plugin
final plugin = vyuh.entity;
// Look up the typed configuration for a specific entity
final courseConfig = plugin?.getConfig<Course>();
// List the registered entity identifiers
final identifiers = plugin?.registeredIdentifiers;
// Use the canonical route builder — never hardcode entity URLs
final route = plugin?.getConfig<Course>()?.route;
context.go(route!.list()); // /lms/courses
context.go(route.view('course-1')); // /lms/courses/course-1analysis_options.yaml
Add **/*.entity.dart to the analyzer.exclude list when you use the generator. The generated files emit deliberately permissive types and you do not want them flagged in CI.
analyzer:
exclude:
- "**/*.g.dart"
- "**/*.entity.dart"