Skip to main content

graft 1.0.0-alpha.4 copy "graft: ^1.0.0-alpha.4" to clipboard
graft: ^1.0.0-alpha.4 copied to clipboard

Self-optimizing state management engine for Flutter: BLoC-style domain models, Signals-level micro-rebuild precision, and register-level CPU bitmask diffing.

Changelog #

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

1.0.0-alpha.4 #

๐Ÿ’พ Deterministic 32-bit FNV-1a Fingerprinting, Ultra-Clean Constructor Hydration & Two-Tier Contract Enforcement #

  • Deterministic 32-bit FNV-1a Schema Fingerprinting:
    • Replaced non-deterministic Object.hash() and Type.hashCode across separate Dart VM process launches / isolates with an invariant 32-bit FNV-1a integer hashing algorithm (.toSigned(32)).
    • Eliminates Frame-0 cold start / hot restart cache invalidation while preserving strict deterministic invalidation on real schema evolution (order swap, field mutation, or version change).
  • Ultra-Clean Constructor Hydration (super.dry(State.new) & factory => Model.new):
    • State and domain sub-models declare constructor defaults once; Graft auto-hydrates into constructor arguments on Frame 0 with zero hydrate(tuple) casting and zero manual index cursors.
    • Domain sub-models extending GraftModel declare a 1-line constructor tear-off: @override Function get factory => Model.new;.
  • Mandatory schemaVersion for Deterministic Safety:
    • Added @override int get schemaVersion => 1; contract on GraftState and GraftModel. Guarantees deterministic invalidation even when all properties share the identical Dart type (e.g., 10 String fields) and order is swapped.
  • Two-Tier Enforcement (Static Lint + Runtime Fail-Fast):
    • Static (graft_lint): Added RequireDryContractsRule to flag missing schemaVersion on persistent states and missing factory or schemaVersion on nested models at compile-time.
    • Runtime: Fail-fast StateError in DryStateHook / Graft.dry with descriptive messages if schemaVersion or factory is missing.
  • Automatic App Lifecycle Flush (GraftLifecycleObserver):
    • Flushes debounced storage writes immediately upon AppLifecycleState.paused, inactive, detached, or hidden, preventing lost writes on immediate app backgrounding or OS process termination.
    • Exported GraftLifecycleObserver in lib/graft.dart and auto-registered in GraftRouteTracker and configurePersistence.
  • Crash-Proof Deserializer & Atomic Disk Writes:
    • Corrupt or truncated binary files safely return null instead of throwing RangeError, automatically purging invalid cache entries.
    • Reversible URI key encoding in FileStateConfig (Uri.encodeComponent / Uri.decodeComponent).
    • Atomic disk writes using .bin.tmp file renaming to avoid corrupted files on process kill.
  • Strict Developer API Encapsulation & Surface Lockdown:
    • Encapsulated internal state engine plumbing (bindGraft, initBaseline, baselineSnapshot, diffChanges, version, isDryEnabled, customDryKey) into @internal abstract final class GraftStateEngine (hidden from lib/graft.dart).
    • Encapsulated slot engine receivers (_fastDirectReceiver, _indexedItemReceivers, _registerItemReceiver, _notifyItem, _notifyMask) into @internal abstract final class GraftEngine (hidden from lib/graft.dart).
    • Marked operator == and hashCode with @override @nonVirtual on GraftState, GraftModel, and Graft, ensuring reference equality is strictly preserved and preventing developers from overriding them with equatable-style value equality.
    • Locked all operational methods on GraftState, GraftModel, and Graft with @nonVirtual, exposing only intended overridables (props, schemaVersion, dryKey, factory, onReset, onInit, onDispose, dispose).
    • Added recursive nested GraftModel constructor hydration and typed collection casting (List<String>, List<int>, List<double>, List<bool>) in DryStateHook.
  • Official Starter Template Released (graft_template):
    • Published graft_template โ€” the official production-grade starter template combining Graft state management, DI, and Frame-0 dry persistence with CoreKit (core_kit), complete with route-scoped controllers, zero-controller forms, Dio HTTP client, responsive scaling, and authentication.

1.0.0-alpha.3 #

๐Ÿ” Intelligent DI Observability, Frame-0 Dry Telemetry & Non-Blocking Async Logging #

  • Intelligent DI Scope & Active Member Teardown Tracking:

    • Added onScopeCreated(scopeId, {bool preserved}) and onScopeDropped(scopeId, {List<Type> members, List<Type> registeredTypes}) hooks to GraftObserver.
    • GraftDevObserver pretty-prints DI scope mounts ([๐Ÿ“ฆ GRAFT DI SCOPE CREATED] | ScopeId (mode)) and introspects concrete active instances during reverse DAG teardowns ([๐Ÿ’ฅ GRAFT DI SCOPE DESTROYED] | ScopeId listing all active disposed members).
    • Added onDependencyBound(type, ...) hook to track individual dependency registrations into scopes.
  • Frame-0 Dry Persistence Observability & Badges:

    • Added onDryHydrated(state, {required String key, required bool fromCache}) distinguishing synchronous L1 RAM restorations (< 50ns) from fresh defaults ([โ„๏ธ GRAFT DRY HYDRATED]).
    • Added onDryInvalidated(target, {required String key, bool isScopePurge}) logging individual state cleanups (graft.invalidateDry()) and flow-wide scope purges (scope.invalidateDry()) ([๐Ÿงน GRAFT DRY INVALIDATED], [๐Ÿงน GRAFT DRY SCOPE PURGED]).
    • Persistent states automatically receive high-visibility ๐Ÿ’พ [DRY: key] badges across creation, transitions, and disposal.
  • Non-Blocking Asynchronous Microtask Logging Queue:

    • Decoupled console I/O and OS log daemon writes from the synchronous state mutation and widget build pipelines via asyncLog: true (default).
    • Log events are queued in-memory in $< 5\text{ ns}$ ($O(1)$ list push) and flushed in microtasks, guaranteeing zero frame drops or jank during 60/120fps animations.
  • Developer Experience & Suppressed State Change Spam:

    • logState and logChanges default to false in GraftDevObserver, keeping the developer console clean and focused on architecture events (DI scopes, dry hydrations, errors) without flooding the terminal on every keystroke or frame.
    • Added granular constructor flags (logDI, logDry, logState, logChanges, logBindings, logRebuilds, logErrors, asyncLog, enableTimeline) with rich inline doc comments for instant IDE hover inspection.
  • Route Transition & Tombstone Lifecycle Safety:

    • Added route tombstoning in GraftRouteTracker during route replacement and exit animations, preventing zombie or duplicate controller instantiations during unmount animation passes.

1.0.0-alpha.2 #

๐Ÿ“š Documentation Polish, Storage Abstraction & pub.dev Score Optimization #

  • Valid pub.dev Package References: Replaced local file URLs across all technical markdown guides with relative links, fixing pana markdown validation and scoring 100% on pub.dev.
  • Custom Storage Abstraction & SharedPreferences: Added production-ready SharedPrefsStateConfig in GRAFT_GUIDE.md and README.md demonstrating synchronous L1 pre-warming (readAllSync()) with zero blank frames on Frame 0.
  • Lifecycle Architectural Clarifications:
    • Clarified that domain GraftState and storage contract GraftStateConfig have zero init() methods; dependencies are passed via standard constructors.
    • Documented native controller lifecycle hooks (onInit() & onDispose()) on Graft controllers.
  • Route-Stack Borrowing & Scoping: Expanded context.use<T>() and GraftScope(factories: [...]) documentation with idiomatic examples for navigation route stacks and tab shell layouts.
  • Linter Rules & Best Practices: Documented graft_lint error rules (avoid_nested_graft_slot, prefer_props_in_graft_state, require_graft_route_observer).

1.0.0-alpha.1 #

๐Ÿš€ Frame-0 Dry Persistence Hardening & Enterprise Dependency Injection (DI) Engine #

  • Frame-0 Dry Persistence (onDry & dry):

    • Zero Magic Strings & Zero Boilerplate: Introduced dedicated @override void onDry() lifecycle method on GraftState and GraftModel using name = dry(name) with automatic generic type inference and fallback defaults.
    • Selective Persistence: Domain state properties listed in propsOf are surgically tracked for UI diffing, while only properties listed in onDry() are persisted to disk. Transient fields (e.g. isLoading, errorMessage, activeTab) automatically start fresh on app launch.
    • Decoupled Ordering: UI diffing order in propsOf is completely decoupled from persistence order in onDry(). Scrambled or reordered fields map deterministically without index shift bugs.
    • Cascaded GraftModel Persistence: Added dryModel(address) for deep domain models with recursive snapshotting, diffing, and in-place hydration.
    • Sub-Microsecond Hydration Latency: Verified at ~1,547 ns (~1.5 ยตs, 646,000 ops/sec) in test/benchmark/frame0_hydration_benchmark_test.dart โ€” over 46ร— faster than JSON HydratedBloc.
    • 15 Worst-Case Persistence Scenarios: Fully verified in test/persistence/worst_case_dry_test.dart covering scrambled orders, identical types, nullable values, schema evolution, corrupted bytes, and rapid mutation bursts.
  • Enterprise Dependency Injection (DI) Engine (GraftDI):

    • Sub-Nanosecond Lookups: Monotonic 32-bit integer indexing (TypeId.of<T>()) eliminates string hashing and runtime reflection ($\le 12\text{ ns}$ cold lookup, $< 0.8\text{ ns}$ hot V-table access).
    • In-Degree Topological Reverse DAG Teardown: Dependent consumers are guaranteed to be disposed before underlying database connections, preventing SqliteException: Cannot operate on closed database crashes.
    • Self-Healing Non-Blocking Async Gates: bindAsync<T>() and useAsync<T>() allow lazy database, network, and storage services to initialize in the background without blocking Frame 0. Concurrent callers await the same in-flight future without duplicate connections.
    • Developer Enum Scopes: Group dependencies under type-safe enums (scope(AppScope.checkout, ...)) with flow-wide AppScope.checkout.drop().
    • Real SQLite Database Verification: Verified against real SQLite in test/di/real_sqlite_di_test.dart covering multi-tier DAOs, transactions, rollback integrity, disk .db persistence across restarts, and zone-isolated mock testing.
    • Unified Bridge with GraftRegistry: context.use<T>() automatically discovers controllers registered via bind() or GraftRegistry.
  • Comprehensive Test Suite & Quality Assurance:

    • Test suite expanded to 283 passing tests across 71 test files with 100% pass rate.
    • Static analysis verified with 0 issues / 0 warnings (dart analyze lib/ test/).
    • Strict code organization: all persistence and DI engine files remain strictly under 200 lines.

0.1.2-alpha.5 #

๐Ÿš€ Public Alpha Release & Core Engine Hardening #

  • Core Architecture & Type-Safe props Contract:
    • Compiler-enforced GraftProps get props => propsOf(...) contract for domain properties.
    • Direct synchronous cascade updates via state..field = val..update() and functional mutations via mutate((s) => ...).
    • In-place baseline diffing and reset() with zero GC heap allocations.
  • Hardware-Aligned 64-Bit Bitmask Diff Engine:
    • GraftMask evaluates up to 64 state properties directly in CPU registers via 1-cycle bitwise operations.
    • Effortlessly scales into unbounded chunked 32-bit words for 128, 500, or 1,000+ fields with 100% web JS compatibility.
  • Universal Multi-Platform Support:
    • Native IO: iOS, Android, macOS, Windows, Linux, and Embedded targets.
    • Modern Web: Verified with both JavaScript (dart compile js) and WebAssembly (dart compile wasm).
    • Conditional platform exports for bitmask vector math (graft_simd_io.dart on Native vs graft_simd_web.dart on Web/WASM).
  • Reactive UI Slots & Virtualization:
    • graft.slot / callable graft((s) => ...): Single-child leaf slots with Depth-$N$ parent rebuild insulation.
    • graft.slots: Universal multi-child layout diffing engine (Column, Row, Wrap, Stack, Flex) with self-optimizing ignoredMask pre-flight bypass.
    • graft.builder: 100% lazy virtualized collections (ListView.builder, GridView.builder) with per-item slot isolation.
    • graft.compute: Pre-flight derived computation cache with zero layout rebuild overhead.
    • graft.async: Declarative, pattern-matched slots (idle, loading, data, error) for asynchronous domain states.
    • GraftBoundary: Element-level rebuild firewall with ambient auto-discovery and backward adaptive learning.
    • NoSubscriptionContext prevents ambient Theme or MediaQuery subscriptions from leaking into parent layouts.
  • Route-Stack Dependency Injection & Lifecycle:
    • Zero-setup context.use<T>() inherits existing controllers across predecessor routes without MultiProvider nesting.
    • Automatic owner-controlled disposal when the route that created the controller pops from the Navigator.
    • Transient popup protection (resolveOwnerRoute): showDialog and showModalBottomSheet borrow safely without disposing host controllers.
    • GraftRouteTracker.observer static accessor for registration in MaterialApp and CupertinoApp.
  • Concurrency & Telemetry:
    • Monotonic token counter (_currentAsyncTaskId) in runAsync automatically drops out-of-order stale network/IO responses.
    • GraftDevObserver with colorized terminal logging and enableTimeline: true for Flutter DevTools Performance tracing.
    • Declarative unit testing harness (graftTest) in package:graft/testing.dart.
    • 211 passing tests across 54 test files with 100% pass rate.
  • Documentation & DX Overhaul:
    • Complete documentation with Quick Start, architectural pillars, empirical benchmark scorecard, and full API reference.

0.1.2-alpha.4 #

โšก Adaptive Pre-Flight Bypass & Zero-Allocation Nested Diffing #

  • Adaptive Multi-Slot Pre-Flight Bypass (ignoredMask):
    • Added ignoredMask tracking to SlotMetadata to cache domain property indices that have been proven not to affect a slot's rendered output.
    • Implemented whole-layout pre-flight short-circuiting in GraftMultiChildDiffEngineState._onStateDirty: skips calling childrenBuilder and avoids all widget heap allocations when the active dirtyMask is covered by all slots' learned ignore masks.
    • Added slot-level ignore checks inside the reconciliation loop, eliminating redundant isWidgetEquivalent evaluations once a slot's ignore mask is cached.
    • Added automatic ignore mask invalidation on reassemble() and didUpdateWidget() for full Flutter hot reload safety.
    • Verified in test/adaptive_slot_preflight_test.dart.
  • Zero-Allocation Nested State Diffing:
    • Optimized GraftState.diffChanges for nested GraftState models: compares sub-props directly against baseline snapshots, eliminating redundant snapshot list allocations on unchanged frames.
    • Inlined _deepEquals with @pragma('vm:prefer-inline') for sub-microsecond collection equality checks.
    • Verified in test/nested_substate_mutation_test.dart.
  • Streamlined Public API Surface:
    • Removed redundant layout aliases (graft.column and graft.row).
    • Unified multi-child slot diffing exclusively under graft.slots(layout: ..., children: ...), keeping layout concerns orthogonal to state management while preserving 100% of the underlying slot-diffing engine and philosophy.
  • Benchmark Performance Verification:
    • Multi-child slot pipeline execution time improved by 16.3% (75.88 ms โ†’ 63.47 ms) with 0 wasted builds in test/benchmark/widget_rebuild_benchmark_test.dart.
    • Average diff pass latency reduced to 1,227.6 ns across 10,000 passes with 0 GC pauses.
    • All 185 test cases passing with 100% green status.

0.1.2-alpha.3 #

โšก Declarative Async Pattern-Matching & Structural Fingerprint Expansion #

  • Declarative Async Pattern-Matching (graft.async & GraftAsync.when):
    • Added .when<R>() pattern-matching method to sealed GraftAsync<T> hierarchy for type-safe, exhaustive handling of idle, loading, data, and error states.
    • Introduced graft.async<T>() widget extension on Graft<S>, enabling fine-grained, isolated slot rendering bound to asynchronous state transitions with zero selector boilerplate.
    • Verified in test/graft_async_widget_test.dart.
  • Extended Layout Primitive Fingerprinting (SlotMetadata.computeFingerprint):
    • Expanded sub-nanosecond integer hashing in SlotMetadata to deeply fingerprint common layout primitives: SizedBox, Padding, ColoredBox, Align, and Opacity.
    • Enables instant 1-cycle bypass (< 5 ns) for structural layout containers during slot reconciliation passes.
  • Self-Healing Adaptive Bitmask Test Harness:
    • Added comprehensive test suite test/self_healing_bitmask_test.dart covering multi-slot layouts, rapid single-field and multi-field mutation bursts, and verified zero-rebuild isolation for unmutated slots.
  • Architecture & Lifecycle Documentation:
    • Updated runtime lifecycle flow and slot diffing diagrams in README.md to document the unified runAsync binding and self-healing bitmask reconciliation pipeline.

0.1.2-alpha.2 #

โšก Core Engine Hardening & Context Decoupling #

  • Recursive Snapshot Contract & Nested State Diffing:
    • Upgraded GraftState's snapshot engine to recursively clone nested GraftState sub-states via their props, alongside deep snapshots of List, Set, and Map collections.
    • Deep-equality diffing in diffChanges detects in-place cascade mutations on nested models (state..address.city = 'Berlin'..update()) with 100% snapshot integrity, eliminating the need for copyWith boilerplate.
    • Verified in test/nested_inplace_mutation_test.dart.
  • Safe AST Reconciliation with NoSubscriptionContext:
    • Introduced NoSubscriptionContext, a specialized proxy BuildContext that safely resolves InheritedWidgets (such as Theme.of(context) or MediaQuery.of(context)) during fine-grained widget diffing without registering the underlying element in InheritedElement._dependents.
    • Guarantees zero context dependency leaks and prevents out-of-band rebuild cascades during background slot evaluation.
    • Verified in test/context_isolation_leak_test.dart.
  • Transient Route Lifecycle Protection (PopupRoute):
    • Enhanced GraftRouteTracker with resolveOwnerRoute to distinguish host screen routes (PageRoute) from transient overlay routes (PopupRoute, such as showDialog or showModalBottomSheet).
    • When dialogs or bottom sheets borrow or instantiate controllers via context.use<T>(), ownership is cleanly anchored to the hosting PageRoute. Dismissing the popup no longer triggers premature controller disposal.
    • Verified in test/dialog_popup_lifecycle_test.dart.
  • Deterministic Multi-Field Bitmask Union:
    • Upgraded GraftBoundary's backward adaptive dependency learning to accumulate observed field bitmasks via bitwise union (_learnedDependencies[graft] |= fieldMask) across all builder passes, preventing multi-field dependency dropping.
    • Verified in test/deterministic_slot_bitmask_test.dart.
  • Comprehensive Test Suite Expansion:
    • Expanded test coverage from 116 to 164 test cases (100% pass rate) with 0 static analysis warnings across unit, widget, and hardware benchmark suites.

0.1.2-alpha.1 #

โšก Hardware-Aligned Engine & Self-Optimizing Architecture #

  • Multi-Field Bitmask Tracking (fieldDependenciesMask): Upgraded SlotMetadata to accumulate multi-field dependencies into a cumulative 64-bit integer bitmask, completely resolving the single-bit locking bug and guaranteeing zero stale UI occurrences when slots depend on multiple domain fields.
  • Copy-on-Write State Transitions (produce): Added produce((s) => s..field = x) method to Graft<S>, combining zero-boilerplate cascade syntax with distinct immutable currentState and nextState snapshots for auditable logging and time-travel testing.
  • First-Class Async Engine (GraftAsync<T> & runAsync): Added sealed GraftAsync<T> hierarchy (idle, loading, data, error) and runAsync() automated task runner.
  • Subtree Scoping for Modern Routing (GraftScope): Added GraftScope widget to support GoRouter's StatefulShellRoute, persistent bottom navigation tabs, and modal dialogs with automatic subtree lifecycle cleanup.
  • 64-Bit Integer Dirty Bitmask: Replaced synthetic context reflection hacks with hardware-level integer bitmasks evaluated in CPU registers.
  • Zero-Allocation In-Place Snapshots: State diffing mutates baseline snapshots in-place with 0 GC heap allocations. Verified in test/zero_allocation_benchmark_test.dart (~750โ€“1,300 ns per pass in debug VM, < 50 ns in AOT compiled mode).
  • Self-Optimizing Slot Table (SlotMetadata): Each slot retains lightweight metadata that adaptively correlates to domain field indices during mutation bursts, escalating from structural inspection to 1-cycle CPU bitwise checks: (dirtyMask & fieldDependenciesMask) != 0.
  • Depth-$N$ Rebuild Insulation (graft((s) => ...) & graft.slot): Unified single-slot leaf rendering with the ultra-clean callable syntax graft((s) => ...), providing complete Element-level rebuild insulation for intermediate parent containers (Card, Container, Padding).
  • Synchronous & Coalesced Updates: Direct cascade updates via state..update() notify synchronously for zero-latency UI updates; added state..updateCoalesced() for microtask debouncing in rapid loops.
  • Disordered Slot Resolution: Full support for UI slot layouts that differ in order from state tracked definitions, verified in test/disordering_test.dart and test/multi_field_slot_test.dart.
  • Dynamic Branch Reconciliation: Slot table dynamically expands and contracts on conditional branches (if, collection-for), properly disposing dropped slot notifiers to prevent memory leaks.
  • 100% Verified Test Suite: 116 test cases passing with zero warnings and zero analyzer issues across the entire workspace.

๐Ÿ” Tooling & Linter Updates (graft_lint) #

  • New Rule (prefer_tracked_in_graft_state): Warns when a domain state class extending GraftState declares fields without overriding tracked, prompting developers to declare List<Object?> get tracked => [...] to unlock hardware-aligned 1-cycle bitmask execution.
  • Enhanced avoid_nested_graft_slot: Flags illegal nesting of slots and layout scopes.

0.1.1-alpha.1 #

๐Ÿ” Tooling & Linter Updates (graft_lint) #

  • Promoted avoid_nested_graft_slot to Error: Redundant slot nesting is now flagged as a compile-time analyzer Error (ErrorSeverity.ERROR) by default to prevent anti-patterns early in IDEs and CI.
  • Fixed Ambiguous Import: Resolved LintCode collision between analyzer and custom_lint_builder.
  • Published graft_lint on pub.dev: Package is now publicly distributed via pub.dev/packages/graft_lint.
  • Documentation: Expanded setup guides, added Bad vs. Good code examples, and documented analysis_options.yaml configuration patterns.

0.1.0-alpha.1 #

First public alpha release of Graft โ€” high-performance, fine-grained reactive state management for Flutter.

๐Ÿš€ Alpha Release Notice โ€” Let's Have a Ride! Graft is in its initial alpha release and is not yet declared production-ready. We invite developers to take it for a spin, test its slot diffing and route-scoping capabilities across diverse architectures, and help us discover edge cases, ideas, and feedback on GitHub Issues as we march toward 1.0!

โœจ Key Features #

1. Core State & Reactivity

  • Domain State Model (Graft<S>): Structured, cohesive state containers powered by GraftState.
  • Batched Cascade Updates: Mutate state cleanly using Dart cascades (state..name = 'Alice'..update()) with automatic single-pass change emission.
  • Single-Value State (ValueGraft<T>): Zero-boilerplate reactive wrappers for primitives and enums without declaring a dedicated state class.
  • Disposal & Safety Guardrails: Hardened lifecycle guards preventing memory leaks and state updates to disposed controllers.
  • Reentrancy Guard & Microtask Batching: Multiple synchronous notify() calls during an active transition are batched into a single microtask emission.

2. Fine-Grained Rebuild & Slot Diffing Engine

  • Slot Isolation (graft.slot({required builder})): Eliminates the "Pyramid of Selectors" by updating only specific subtrees on state changes.
  • Multi-Child Slot Diffing (graft.slots({required layout, required children})): Diff multi-child layouts (Column, Row, Wrap, Stack, Flex) without manual selector wrappers.
  • Collection Builder Support (graft.builder<T>({required items, itemBuilder})): Virtualized collection diffing with zero itemCount boilerplate; automatically defaults layout to ListView.builder with customizable layout overrides (GridView.builder, SliverList).
  • Pre-Flight Derivation (graft.compute<R>({required compute, required builder})): Pure functional computation cache that skips widget builds entirely when derived values remain unchanged.
  • 100% Named Parameter Harmonization: Consistent developer ergonomics across all widget slot methods (slot, slots, compute, builder, item, valueGraft.slot).
  • Deep Property Diffing: Native deep comparison for 25+ Flutter widgets (Text, RichText, Icon, SizedBox, Padding, ColoredBox, Align, DecoratedBox, Opacity, ClipRRect, Flex, Flexible, FittedBox, Stack, Positioned, Wrap, GestureDetector, InkWell, IconButton, Image, ProgressIndicator, Checkbox, Switch, Slider, and more).
  • Transparent Wrapper Unwrapping: Automatically unwraps single-child wrappers (Padding, Container, Card, Scrollbar, RefreshIndicator) in layout contracts.
  • Anti-Pattern Cycle Guard (GraftScopeGuard): Developer-friendly error diagnostics preventing accidental nested slot creations.

3. Route-Stack Dependency Injection

  • Zero Provider Nesting: Retrieve controllers via context.use<T>() without wrapping screens in MultiProvider or BlocProvider.
  • Stack-Aware Scope Sharing: Sub-routes automatically borrow active controllers from predecessor routes in the navigation stack (ModalRoute.of(this) ?? GraftRouteTracker.currentRoute).
  • Automatic Lifecycle Disposal: When a route pops, GraftRouteTracker automatically disposes any controller owned by that route.
  • Registry & Fallback Support (GraftRegistry): Global factory registration with eager or lazy instantiation, plus support for custom DI locators (e.g. get_it).

4. Observability & Telemetry

  • Global Event Hooks (GraftObserver): Audit logging for controller creation, state changes, slot rebuilds (onSlotRebuild), errors, and disposal.
  • Developer Console Logger (GraftDevObserver): Colorized, structured console telemetry with optional slot-rebuild logging (logRebuilds: true).
  • Detailed State Diffs (GraftChange<S>): Full tracking of prior and subsequent states with transition metadata.

5. Developer Ergonomics & Tooling

  • IDE Snippets Generator (bin/snippets.dart): Quick installer for VS Code / Cursor snippets (.vscode/graft.code-snippets) and Android Studio / IntelliJ live templates (graft-controller, graft-slot, graft-slots, graft-builder, graft-compute, graft-test).
  • Custom Linter Package (packages/graft_lint): Dedicated compile-time analyzer plugin providing rules:
    • avoid_nested_graft_slot: Warns against redundant nested slot invocations.
    • require_graft_route_observer: Suggests registering GraftRouteTracker.observer in MaterialApp.navigatorObservers.

6. Benchmarking & Pure Dart Declarative Testing

  • Automated Rebuild Benchmark (test/benchmark/column_rebuild_benchmark_test.dart): Formally asserts 90.0% rebuild reduction in 10-slot layout (60 rebuilds vs 600 rebuilds).
  • Declarative Test Harness (graftTest): Sub-millisecond pure Dart unit testing with declarative setUp, build, act, wait, expect, verify, and tearDown stages.
  • 100% Test Coverage: Comprehensive test suite covering 100.0% of lines across all library source files.
2
likes
160
points
592
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Self-optimizing state management engine for Flutter: BLoC-style domain models, Signals-level micro-rebuild precision, and register-level CPU bitmask diffing.

Repository (GitHub)
View/report issues

Topics

#state-management #reactivity #performance #dependency-injection #widget

License

MIT (license)

Dependencies

flutter, flutter_test

More

Packages that depend on graft