actionFromMap method

ActionModel? actionFromMap(
  1. Map<String, Object> actionMap
)

Implementation

ActionModel? actionFromMap(Map<String, Object> actionMap) {
  String type = actionMap["type"] as String;
  switch (type) {
    case "MEAppEvent":
      return AppEventActionModel(
          id: actionMap["id"] as String,
          title: actionMap["title"] as String,
          type: actionMap["type"] as String,
          name: actionMap["name"] as String,
          payload: actionMap["payload"] != null
              ? Map<String, Object>.from(
                  actionMap["payload"] as Map<dynamic, dynamic>)
              : {});
    case "MECustomEvent":
      return CustomEventActionModel(
          id: actionMap["id"] as String,
          title: actionMap["title"] as String,
          type: actionMap["type"] as String,
          name: actionMap["name"] as String,
          payload: actionMap["payload"] != null
              ? Map<String, Object>.from(
                  actionMap["payload"] as Map<dynamic, dynamic>)
              : {});
    case "OpenExternalUrl":
      return OpenExternalUrlActionModel(
          id: actionMap["id"] as String,
          title: actionMap["title"] as String,
          type: actionMap["type"] as String,
          url: actionMap["url"] as String);
    default:
      return null;
  }
}