getMenuItemsForCurrentUser static method

List<MenuItem> getMenuItemsForCurrentUser()

Implementation

static List<MenuItem> getMenuItemsForCurrentUser() {
  var currentUser = FlickerSecurity.currentUser;
  if (currentUser == null) {
    return publicMenu.items;
  }

  var menuItems = FlickerConfiguration.menus.where((menu) {
    if (menu.role == null) return false;
    return menu.role!.title == currentUser.role!.title;
  });

  if (menuItems.isEmpty) {
    return publicMenu.items;
  }

  return menuItems.first.items;
}