• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Duit-Foundation / duit_kernel / 20716609011

05 Jan 2026 01:17PM UTC coverage: 76.681% (+0.05%) from 76.636%
20716609011

push

github

web-flow
feat: ViewModel capability (#51)

* feat: Enhance Makefile and add ViewModel capability

* Updated Makefile to include new test and lint commands.
* Introduced ViewModelCapabilityDelegate for managing view interactions.
* Exported view_capability.dart in index.dart.
* Deprecated WidgetDisplayStateNotifier interface in favor of new capabilities.

* Rm api deprecation annotations

* wip

* wip

* wip

* wip

* wip

9 of 13 new or added lines in 4 files covered. (69.23%)

2 existing lines in 2 files now uncovered.

1779 of 2320 relevant lines covered (76.68%)

4.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.71
/lib/src/capabilities/ui_controller_capability.dart
1
import "package:duit_kernel/duit_kernel.dart";
2
import "package:duit_kernel/src/capabilities/driver_ref.dart";
3
import "package:meta/meta.dart";
4

5
/// Mixin that provides an interface for managing and interacting with UI element controllers
6
/// in the Duit driver.
7
///
8
/// Classes that mix in [UIControllerCapabilityDelegate] are expected to implement
9
/// logic for tracking, attaching, detaching, and updating UI controllers (typically wrapping
10
/// widgets, inputs, or other interactive elements).
11
///
12
/// By default, all methods throw [MissingCapabilityMethodImplementation] if not overridden, enforcing
13
/// that concrete platform or application drivers provide required behaviors.
14
///
15
/// Typical responsibilities include:
16
///   - Mapping UI controller IDs to their active controller instances
17
///   - Attaching/detaching controllers dynamically as UI is built or disposed
18
///   - Applying state and attribute updates received from the server or driver logic
19
///   - Exposing helpers to query or enumerate attached controllers
20
mixin UIControllerCapabilityDelegate implements DriverRefHolder {
NEW
21
  @override
×
22
  @mustBeOverridden
23
  void linkDriver(UIDriver driver) =>
24
      throw const MissingCapabilityMethodImplementation(
25
        "eventStream",
26
        "ViewModelCapabilityDelegate",
27
      );
28

29
  /// Attaches a UI element controller to the driver.
30
  ///
31
  /// Called when a new UI element or interactive widget is created and
32
  /// needs to be tracked or managed by the driver. The [id] should be a
33
  /// unique identifier for the controller within the driver context.
34
  ///
35
  /// The [controller] instance provides control over state, events, and
36
  /// properties of the associated UI element.
37
  ///
38
  /// Implementations are responsible for tracking the mapping and making the
39
  /// controller available for updates and lookups using [getController].
40
  ///
41
  /// Throws [MissingCapabilityMethodImplementation] if not overridden.
42
  @mustBeOverridden
4✔
43
  void attachController(
44
    String id,
45
    UIElementController controller,
46
  ) =>
47
      throw const MissingCapabilityMethodImplementation(
48
        "attachController",
49
        "UIControllerCapabilityDelegate",
50
      );
51

52
  /// Detaches the UI element controller associated with the given [id].
53
  ///
54
  /// Called when a UI element or interactive widget is disposed or no longer
55
  /// needs to be managed by the driver. The implementation should remove any
56
  /// references to the controller to allow for proper garbage collection and to
57
  /// prevent memory leaks.
58
  ///
59
  /// If the controller for the given [id] does not exist, this method may be a no-op.
60
  ///
61
  /// Throws [MissingCapabilityMethodImplementation] if not overridden.
62
  @mustBeOverridden
4✔
63
  void detachController(String id) =>
64
      throw const MissingCapabilityMethodImplementation(
65
        "detachController",
66
        "UIControllerCapabilityDelegate",
67
      );
68

69
  /// Returns the [UIElementController] associated with the given [id], or `null` if
70
  /// no such controller is currently attached to the driver.
71
  ///
72
  /// The [id] should match the unique identifier provided when [attachController] was called.
73
  ///
74
  /// This method enables lookups for dynamic access to element state, imperative methods,
75
  /// or for integrating with widgets that need to control or listen to specific UI element controllers.
76
  ///
77
  /// Throws [MissingCapabilityMethodImplementation] if not overridden.
78
  @mustBeOverridden
4✔
79
  UIElementController? getController(String id) =>
80
      throw const MissingCapabilityMethodImplementation(
81
        "getController",
82
        "UIControllerCapabilityDelegate",
83
      );
84

85
  /// Updates the attributes (properties) of the UI element controller identified by [controllerId].
86
  ///
87
  /// The [json] parameter is a `Map<String, dynamic>` containing key-value pairs representing
88
  /// the attributes to update on the specified controller. Implementations should deserialize
89
  /// or assign these values as appropriate for the UI element's state, triggering any necessary
90
  /// UI updates, re-rendering, or side effects.
91
  ///
92
  /// - If the controller with [controllerId] does not exist, this method may throw,
93
  ///   be a no-op, or handle the situation gracefully depending on implementation.
94
  /// - Values in [json] are expected to match the schema or interface supported by
95
  ///   the associated [UIElementController].
96
  ///
97
  /// Throws [MissingCapabilityMethodImplementation] if not overridden.
98
  @mustBeOverridden
4✔
99
  Future<void> updateAttributes(
100
    String controllerId,
101
    Map<String, dynamic> json,
102
  ) =>
103
      throw const MissingCapabilityMethodImplementation(
104
        "updateAttributes",
105
        "UIControllerCapabilityDelegate",
106
      );
107

108
  /// Returns the number of currently attached [UIElementController]s managed by this delegate.
109
  ///
110
  /// This getter should provide a count of all active UI element controllers that have been
111
  /// attached via [attachController], and not subsequently detached via [detachController].
112
  ///
113
  /// The value is useful for diagnostics, debugging, or for systems needing to monitor or
114
  /// iterate over all registered UI controllers at runtime.
115
  ///
116
  /// Throws [MissingCapabilityMethodImplementation] if not overridden.
117
  @mustBeOverridden
4✔
118
  int get controllersCount => throw const MissingCapabilityMethodImplementation(
119
        "controllersCount",
120
        "UIControllerCapabilityDelegate",
121
      );
122

123
  /// Called to clean up any external resources, subscriptions, or handlers
124
  /// typically when a delegate is being disposed of or detached. Implementations
125
  /// should ensure all open streams or event sources are closed.
126
  ///
127
  /// This method must be overridden by implementers.
128
  ///
129
  /// Throws [MissingCapabilityMethodImplementation] by default.
130
  @mustBeOverridden
4✔
131
  void releaseResources() => throw const MissingCapabilityMethodImplementation(
132
        "releaseResources",
133
        "UIControllerCapabilityDelegate",
134
      );
135
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc