OmegaFlowContract class
Declarative contract for an OmegaFlow: which events it listens to, which intents it accepts, and which expression types it may emit.
Why use it: Documents and validates flow boundaries. In debug mode, Omega can warn when a flow receives an event or intent not in its contract, or emits an expression type not declared. Enables tooling (Inspector, docs) and stricter conventions.
Example:
class AuthFlow extends OmegaFlow {
AuthFlow({required super.channel, required this.agent})
: super(id: 'authFlow');
final AuthAgent agent;
@override
OmegaFlowContract? get contract => OmegaFlowContract(
listenedEventNames: {AppEvent.authLoginSuccess.name, AppEvent.authLoginError.name},
acceptedIntentNames: {AppIntent.authLogin.name, AppIntent.authLogout.name},
emittedExpressionTypes: {'loading', 'success', 'error'},
);
@override
void onEvent(OmegaFlowContext ctx) { ... }
@override
void onIntent(OmegaFlowContext ctx) { ... }
}
With typed names:
contract => OmegaFlowContract.fromTyped(
listenedEvents: [AppEvent.authLoginSuccess, AppEvent.authLoginError],
acceptedIntents: [AppIntent.authLogin, AppIntent.authLogout],
emittedExpressionTypes: {'loading', 'success', 'error'},
);
Constructors
-
OmegaFlowContract({String? flowId, Set<
String> listenedEventNames = const {}, Set<String> acceptedIntentNames = const {}, Set<String> emittedExpressionTypes = const {}}) -
const
-
OmegaFlowContract.fromTyped({String? flowId, Iterable<
OmegaEventName> listenedEvents = const [], Iterable<OmegaIntentName> acceptedIntents = const [], Iterable<String> emittedExpressionTypes = const []}) -
Builds a contract from typed event and intent names (e.g. enums).
factory
Properties
-
acceptedIntentNames
→ Set<
String> -
Intent names this flow is declared to accept. Empty = no constraint (all allowed).
final
-
emittedExpressionTypes
→ Set<
String> -
Expression types this flow may emit to the UI. Empty = no constraint.
final
- flowId → String?
-
Optional flow id for documentation or tooling.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
listenedEventNames
→ Set<
String> -
Event names this flow is declared to react to. Empty = no constraint (all allowed).
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
acceptsEvent(
String name) → bool - Whether the flow is declared to listen to this event name. If listenedEventNames is empty, returns true (no constraint).
-
acceptsIntent(
String name) → bool - Whether the flow is declared to accept this intent name. If acceptedIntentNames is empty, returns true (no constraint).
-
allowsExpression(
String type) → bool - Whether the flow is declared to emit this expression type. If emittedExpressionTypes is empty, returns true (no constraint).
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited