fromMap static method

JsBeforeUnloadResponse? fromMap(
  1. Map<String, dynamic>? map, {
  2. EnumMethod? enumMethod,
})

Gets a possible JsBeforeUnloadResponse instance from a Map value.

Implementation

static JsBeforeUnloadResponse? fromMap(
  Map<String, dynamic>? map, {
  EnumMethod? enumMethod,
}) {
  if (map == null) {
    return null;
  }
  final instance = JsBeforeUnloadResponse();
  instance.action = switch (enumMethod ?? EnumMethod.nativeValue) {
    EnumMethod.nativeValue => JsBeforeUnloadResponseAction.fromNativeValue(
      map['action'],
    ),
    EnumMethod.value => JsBeforeUnloadResponseAction.fromValue(map['action']),
    EnumMethod.name => JsBeforeUnloadResponseAction.byName(map['action']),
  };
  if (map['cancelButtonTitle'] != null) {
    instance.cancelButtonTitle = map['cancelButtonTitle'];
  }
  if (map['confirmButtonTitle'] != null) {
    instance.confirmButtonTitle = map['confirmButtonTitle'];
  }
  if (map['handledByClient'] != null) {
    instance.handledByClient = map['handledByClient'];
  }
  if (map['message'] != null) {
    instance.message = map['message'];
  }
  return instance;
}