fromNative static method
Reads the event out of its C form. Returns null for a variant this binding does not know about.
Implementation
static ViewEvent? fromNative(c.native_view_event_t raw) {
if (raw.typeAsInt ==
c.native_view_event_type_t.NATIVE_VIEW_EVENT_TYPE_FOCUSED.value) {
return ViewFocusedEvent(viewId: raw.view_id);
}
if (raw.typeAsInt ==
c.native_view_event_type_t.NATIVE_VIEW_EVENT_TYPE_BLURRED.value) {
return ViewBlurredEvent(viewId: raw.view_id);
}
if (raw.typeAsInt ==
c
.native_view_event_type_t
.NATIVE_VIEW_EVENT_TYPE_BUTTON_CLICKED
.value) {
return ButtonClickedEvent(viewId: raw.view_id);
}
if (raw.typeAsInt ==
c
.native_view_event_type_t
.NATIVE_VIEW_EVENT_TYPE_TEXT_FIELD_CHANGED
.value) {
return TextFieldChangedEvent(
viewId: raw.view_id,
text: raw.data.text_field_changed.text == ffi.nullptr
? null
: raw.data.text_field_changed.text
.cast<pkg_ffi.Utf8>()
.toDartString(),
);
}
if (raw.typeAsInt ==
c
.native_view_event_type_t
.NATIVE_VIEW_EVENT_TYPE_TEXT_FIELD_SUBMITTED
.value) {
return TextFieldSubmittedEvent(viewId: raw.view_id);
}
return null;
}