feat(di): feature modules resolve shared/core deps (7.1.0)#1060
Merged
Conversation
Wire _bind to auto_injector 2.2.0's opt-in upward resolution (addInjector(injector, resolveUpward: true)) so a feature module's module-level binds resolve dependencies registered in a root-owned shared/core module — closing the asymmetry where only page-scoped `provide` could reach the core. Local binds still shadow same-typed core binds (core is the fallback). Bumps auto_injector constraint to >=2.2.0 and adds a regression test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Document that a feature's binds resolve root-owned/core deps (7.1.0), the local-shadows-core precedence, and the "await once in a Future<Module> builder" idiom for Hive/SharedPreferences so main stays thin and features take no parameters. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Release 7.1.0 — feature modules can consume shared/core deps
Closes the resolution asymmetry surfaced while reviewing a real v7 app: a
feature module's module-level binds could not resolve dependencies from a
root-owned shared/core module (a path-less
module(...)). Only page-scopedprovidebinds could reach the core; feature binds ran in a leaf injector blindto root-owned binds — forcing shared deps to be threaded in by hand.
What changed
_bindnow composes the feature injector withauto_injector 2.2.0'sopt-in upward resolution:
root.addInjector(injector, resolveUpward: true).provide, the core itself, or a featuremodule-level bind — all alike. A feature's own bind still shadows a
same-typed core bind (local wins; core is the fallback).
auto_injector: ">=2.2.0 <3.0.0".Verified behavior (the gap, reproduced then fixed)
provideaddSingleton(eager)add(lazy factory)addLazySingletonauto_injector 2.2.0 (dependency)
Adds
addInjector(child, resolveUpward: true)(opt-in, defaultfalse— nobehavior change for existing users), fixes a dispose-listener accumulation in
its layer graph, and adds an
UpwardResolutionCycleguard against mutual upwardlinks.
Tests
test/feature_resolves_core_test.dartregression test (featuremodule-level bind resolves a core
ApiConfig).flutter analyzeclean.🤖 Generated with Claude Code