newDrawer function

Future<DrawerModel> newDrawer(
  1. String appId,
  2. DrawerType drawerType, {
  3. bool? store,
})

Implementation

Future<DrawerModel> newDrawer(String appId, DrawerType drawerType,
    {bool? store}) async {
  var drawerId = drawerID(appId, drawerType);
  var menuDefModel = await menuDefRepository(appId: appId)!.get(drawerId);
  if (menuDefModel == null) {
    menuDefModel = newMenuDef(appId, drawerId);
    await menuDefRepository(appId: appId)!.add(menuDefModel);
  }
  var drawerModel =
      DrawerModel(documentID: drawerId, appId: appId, menu: menuDefModel);
  if ((store != null) && (store)) {
    await drawerRepository(appId: appId)!.add(drawerModel);
  }
  return drawerModel;
}