inlay_gen 0.1.1
inlay_gen: ^0.1.1 copied to clipboard
Code generator for the inlay add-to-app framework - produces type-safe route and store classes for Dart, Kotlin, and Swift from annotated schemas.
inlay_gen #
Code generator for the inlay add-to-app framework. It reads annotated Dart schema files and produces type-safe route and store classes for Dart, Kotlin, and Swift, so navigation and shared state never rely on arbitrary strings crossing the platform boundary.
How it works #
- You write plain Dart schema files (specs only - never imported by app code) annotated with inlay annotations.
inlay_genparses them and generates matching typed classes for all three languages.- The generated Dart compiles into your Flutter module; the generated Kotlin and Swift compile into the native hosts.
- A schema fingerprint is embedded in every language's output, so a module and a host built from different schema revisions fail loudly instead of silently corrupting data.
Annotations #
// A Flutter screen reachable from native or other Flutter screens.
// Declare `result:` to get typed result plumbing (pushForResult / popWithResult).
@InlayFlutterRoute('/counter', result: int)
class CounterPage {
const CounterPage({this.seed});
final int? seed;
}
// A Flutter dialog rendered over a native screen in a transparent container.
@InlayFlutterDialog('/confirm-delete/:itemId', result: bool)
class ConfirmDeleteDialog {
const ConfirmDeleteDialog({required this.itemId});
final String itemId;
}
// A native screen reachable from Flutter.
@InlayNativeRoute(result: String)
class NativeAboutPage {
const NativeAboutPage({required this.appVersion});
final String appVersion;
}
// A typed store on top of inlay's cross-engine key-value storage.
@InlayStore(key: 'user_preferences')
class UserPreferencesStore {
const UserPreferencesStore({
@InlayStoreKey() required this.userId, // scopes the store per key
this.darkMode = false,
this.tags = const [],
});
final String userId;
final bool darkMode;
final List<String> tags;
}
Supported field types: bool, int, double, num, String, Uint8List, enums, annotated data classes, List<T>, Map<K, V>, and nested combinations.
Configuration (inlay.yaml) #
Place an inlay.yaml in your Flutter module:
routes: lib/inlay/routes.dart
stores: lib/inlay/stores.dart
dart:
output: lib/src/generated/
kotlin:
output: native/android/src/main/kotlin/com/example/generated/
package: com.example.generated
swift:
output: native/ios/Classes/Generated/
Running #
As a standalone CLI:
dart run inlay_gen:inlay_gen --config inlay.yaml
Or as a build_runner builder:
dart run build_runner build
Outputs #
- Dart - sealed
FlutterRoute/FlutterDialogRoutehierarchies for exhaustive pattern matching, per-routeencode/decode, typed result helpers, native route wrappers, typed store classes with immutable snapshots andcopyWith. - Kotlin - route data classes, an abstract
NativeRouteHandlerwith typedon*methods, typed store wrappers withcontainsChanges. - Swift - route structs conforming to
FlutterRoute/FlutterDialogRoute, aNativeRouteHandlerclass, typed store structs withcontainsChanges(in:).
See the inlay documentation for how the generated code is used, and the example module for a complete schema.
🛠️ Maintained by LeanCode #
This package is built with 💙 by LeanCode. We are top-tier experts focused on Flutter Enterprise solutions.
Why LeanCode? #
-
Creators of Patrol – the next-gen testing framework for Flutter.
-
Production-Ready – We use this package in apps with millions of users.
-
Full-Cycle Product Development – We take your product from scratch to long-term maintenance.