copyOrDefault function

MenuDefModel copyOrDefault(
  1. String appId,
  2. String documentID,
  3. MenuDefModel? menuDefModel
)

Implementation

MenuDefModel copyOrDefault(
    String appId, String documentID, MenuDefModel? menuDefModel) {
  if (menuDefModel == null) {
    return newMenuDef(appId, documentID);
  } else {
    if (menuDefModel.menuItems == null) {
      return menuDefModel.copyWith(menuItems: []);
    } else {
      return menuDefModel.copyWith(menuItems: List.of(menuDefModel.menuItems!));
    }
  }
}