getOrCreate method

Future<HomeMenuModel> getOrCreate()

Implementation

Future<HomeMenuModel> getOrCreate() async {
  var homeMenuModel =
      await homeMenuRepository(appId: app.documentID)!.get(identifier);
  if (homeMenuModel == null) {
    homeMenuModel = HomeMenuModel(
        documentID: identifier,
        appId: app.documentID,
        name: 'Home menu',
        menu: await menuDef());
    await homeMenuRepository(appId: app.documentID)!.add(homeMenuModel);
  }
  return homeMenuModel;
}