d_rocket_builder library
๐ d_rocket_builder โ build_runner codegen for d_rocket.
This package provides five build_runner builders that together wire up the d_rocket framework:
d_rocket_builder:record(aPartBuilderwith the default.g.dartsuffix) โ walksextends Recordclasses and emits apartfile with a_[ClassName]Initclass plus aregister[ClassName]Record()function per class.d_rocket_builder:serializer(aPartBuilderwith the.d_rocket_serializer.g.dartsuffix) โ walks@Serializableclasses and emits apartfile withXFromJson/XToJson/register[X]Serializer()per class.d_rocket_builder:rest_client(aPartBuilderwith the.d_rocket_rest_client.g.dartsuffix) โ walks@RestClientclasses and emits apartfile with a_$[ClassName]implementation plus aregister[ClassName]RestClient()factory per class.d_rocket_builder:rocket_table(aPartBuilderwith the.d_rocket_orm.g.dartsuffix) โ walks@Tableclasses and emits apartfile with a_$Table[ClassName].entityMetaliteral plus aregister[ClassName]EntityMeta()helper per class.d_rocket_builder:record_registry(aLibraryBuilder) โ scans the consumer'slib/**.dart, collects allextends Recordand all@Serializableand all@RestClientand all@Tableclasses, and emits a singlelib/d_rocket_registry.g.dartwith a publicinitializeD()function that calls everyregister[ClassName]Record(), everyregister[ClassName]Serializer(), everyregister[ClassName]RestClient(), and everyregister[ClassName]EntityMeta().
The user calls initializeD() once in main() and every
d_rocket-managed class is wired up.
/ / (absorb + ORM)
The d_rocket_builder:serializer and the extension of
d_rocket_builder:record_registry to detect @Serializable
were added in . The d_rocket_builder:rest_client and
the extension of d_rocket_builder:record_registry to detect
@RestClient were added in . The
d_rocket_builder:rocket_table and the extension of
d_rocket_builder:record_registry to detect @Table
were added in ("ORM").
Before these phases, the codegen was split across three
separate packages (d_builder, d_serializer_build,
d_rest_build) with three separate initializeD*() calls.
All four (records, serializers, REST clients, ORM tables)
are now unified here under a single initializeD().
Output namespaces
The four per-file builders use distinct PartBuilder
suffixes so a single Dart file can use
extends Record + @Serializable + @RestClient +
@Table without any build error:
recordโ*.g.dart(the defaultsource_gensuffix forextends Recordclasses).serializerโ*.d_rocket_serializer.g.dart('s non-default suffix to avoid collision with therecordbuilder; see HANDOFF.md ยง6).rest_clientโ*.d_rocket_rest_client.g.dart('s non-default suffix, same rationale).rocket_tableโ*.d_rocket_orm.g.dart('s non-default suffix, same rationale).
Classes
- DRocketLintsPlugin
- The d_rocket analyzer plugin. Registers both lint rules and one IDE quick-fix:
- LinqClosureFix
-
The
CorrectionProducer(quick-fix) associated with LinqClosureRule.code. - LinqClosureRule
-
The rule class. Registered in
lib/main.dart'sDRocketLintsPlugin.register. - NPlusOneRule
-
The rule class. Registered in
lib/main.dart'sDRocketLintsPlugin.register.
Functions
-
buildRealtime(
BuilderOptions options) โ Builder -
Builder factory for
d_rocket_builder:realtime. -
buildRecord(
BuilderOptions options) โ Builder -
Builder factory for
d_rocket_builder:record. -
buildRecordRegistry(
BuilderOptions options) โ Builder -
Builder factory for
d_rocket_builder:record_registry. -
buildRestClient(
BuilderOptions options) โ Builder -
Builder factory for
d_rocket_builder:rest_client. -
buildRocketMigration(
BuilderOptions options) โ Builder -
Builder factory for
d_rocket_builder:rocket_migration. -
buildRocketTable(
BuilderOptions options) โ Builder -
Builder factory for
d_rocket_builder:rocket_table. -
buildSerializer(
BuilderOptions options) โ Builder -
Builder factory for
d_rocket_builder:serializer.
Typedefs
- LinqClosureLint = LinqClosureRule
-
Backward-compat re-exports. The 1.x +
custom_lint_builderAPI exposedLinqClosureLint,LinqClosureFix, andDRocketLintsPluginclasses. The 2.0 migration renamed these toLinqClosureRule,LinqClosureFix(now aCorrectionProducer), andDRocketLintsPlugin(now anAnalysisServerPluginPlugin). - NPlusOneLint = NPlusOneRule
-
Backward-compat alias. The 1.x +
custom_lint_builderAPI exposed this rule asNPlusOneLint; the 2.0 +analysis_server_pluginversion isNPlusOneRule. The old name continues to compile via this typedef so consumers don't have to update their imports.