BloomEvent class

Typed DOM event abstraction that decouples event handlers from the browser runtime.

Handlers attached to ElNode.on receive a BloomEvent across both browser execution (populated from native DOM events via JS interop) and VM test environments (created via synthetic test factories like BloomEvent.fakeClick).

In the browser (mount.dart), event properties are extracted opportunistically from the underlying JavaScript event object. Depending on whether the event is an input, mouse, keyboard, or drag-and-drop event, many properties will be null. For example, value and checked are populated for <input>, <textarea>, and <select> elements, key and code for keyboard events, and clientX and clientY for mouse/pointer events.

Input(
  attrs: {'type': 'text', 'placeholder': 'Type and press Enter...'},
  on: {
    'input': (event) {
      final text = event.value ?? '';
      query.value = text;
    },
    'keydown': (event) {
      if (event.key == 'Enter' && !event.shiftKey) {
        event.preventDefault();
        submitQuery();
      }
    },
  },
)

Constructors

BloomEvent({required String type, String? value, bool? checked, Object? rawTarget, String? key, String? code, bool shiftKey = false, bool ctrlKey = false, bool altKey = false, bool metaKey = false, double? clientX, double? clientY, double? offsetX, double? offsetY, int? button, List<String>? files, String? dataTransfer, void preventDefaultFn()?, void stopPropagationFn()?})
Creates a new BloomEvent descriptor with the given properties and lifecycle callbacks.
BloomEvent.fake(String type, {String? value})
Creates a generic synthetic BloomEvent with type and optional value for VM unit testing.
factory
BloomEvent.fakeChange({String? value, bool? checked})
Creates a synthetic change BloomEvent carrying value or checked for VM unit testing.
factory
BloomEvent.fakeClick()
Creates a synthetic click BloomEvent for VM unit testing without a browser DOM.
factory
BloomEvent.fakeInput(String value)
Creates a synthetic input BloomEvent carrying value for VM unit testing.
factory
BloomEvent.fakeKeyDown(String key, {String? code})
Creates a synthetic keyboard BloomEvent with key and optional code for VM unit testing.
factory
BloomEvent.fakeMouseMove(double x, double y)
Creates a synthetic mouse BloomEvent with x and y viewport coordinates for VM unit testing.
factory

Properties

altKey bool
Whether the Alt / Option modifier key was active during this event.
final
button int?
The mouse button that triggered the event: 0 for primary/left, 1 for auxiliary/middle, 2 for secondary/right.
final
checked bool?
The boolean checked state extracted from the event target (target.checked).
final
clientX double?
Horizontal coordinate of the pointer within the application's viewport in pixels.
final
clientY double?
Vertical coordinate of the pointer within the application's viewport in pixels.
final
code String?
The physical key code identifier on the keyboard (e.g. 'KeyA', 'Enter', 'Space').
final
ctrlKey bool
Whether the Control modifier key was active during this event.
final
dataTransfer String?
Text data payload associated with HTML5 drag-and-drop events.
final
defaultPrevented bool
Whether preventDefault has been called on this event.
no setter
files List<String>?
File names for file input changes (<input type="file">) or drag-and-drop drops.
final
hashCode int
The hash code for this object.
no setterinherited
key String?
The printable key value of the pressed key (e.g. 'Enter', 'Escape', 'a', 'ArrowDown').
final
metaKey bool
Whether the Meta / Command / Windows modifier key was active during this event.
final
offsetX double?
Horizontal offset of the mouse pointer relative to the target element's padding edge.
final
offsetY double?
Vertical offset of the mouse pointer relative to the target element's padding edge.
final
propagationStopped bool
Whether stopPropagation has been called on this event.
no setter
rawTarget Object?
The raw JavaScript DOM target element in browser execution.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shiftKey bool
Whether the Shift modifier key was active during this event.
final
type String
The DOM event type string (e.g. 'click', 'input', 'change', 'submit', 'keydown').
final
value String?
The string value extracted from the event target (target.value).
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
preventDefault() → void
Prevents the browser's default action for this event.
stopPropagation() → void
Stops propagation (bubbling) of this event up the DOM tree.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited