locorda_init_generator
Code generator for Locorda convenience wrapper (initLocorda).
Purpose
Generates lib/init_locorda.g.dart which provides a simplified initialization function that:
- Auto-detects and configures
workerSetupwhenworker_generated.g.dartexists - Auto-generates
mapperInitializerwheninit_rdf_mapper.g.dartexists - Propagates all other
Locorda.createparameters - Propagates custom parameters from
initRdfMapper(excluding framework params)
Installation
This package is automatically applied when you depend on locorda_dev:
dart pub add dev:locorda_dev dev:build_runner
Usage
After running dart run build_runner build, use the generated function:
import 'package:your_app/init_locorda.g.dart';
final locorda = await initLocorda(
config: myConfig,
storage: myStorage,
remotes: myRemotes,
);
The generator automatically handles:
- Setting
workerSetup: generatedWorkerSetupifworker_generated.g.dartexists - Setting
jsScript: 'worker_generated.dart.js'appropriately - Generating
mapperInitializerlambda ifinit_rdf_mapper.g.dartexists
Requirements
- Requires
analyzerfor code analysis - Compatible with Flutter stable and latest versions
Architecture
This is a separate package (not part of locorda_builder) because:
- Heavy analyzer dependency (~20MB)
- Advanced code analysis features
- Should not burden apps that don't use this feature
Libraries
- builder
- Builder for generating initLocorda convenience wrapper.
- locorda_init_generator