stringToOnDelete function Null safety

OnDelete stringToOnDelete(
  1. String value
)

Convert a string to an on delete constraint

Implementation

OnDelete stringToOnDelete(String value) {
  OnDelete res;
  switch (value) {
    case "restrict":
      res = OnDelete.restrict;
      break;
    case "cascade":
      res = OnDelete.cascade;
      break;
    case "set_null":
      res = OnDelete.setNull;
      break;
    case "set_default":
      res = OnDelete.setDefault;
      break;
    default:
      throw OnDeleteConstraintUnknown("Unknown on delete constraint $value");
  }
  return res;
}