selectMenu method
void
selectMenu(
Implementation
void selectMenu(MenuNode menu) {
if(state is! MenuLoadSuccess) return;
MenuLoadSuccess old = state as MenuLoadSuccess;
MenuState oldSate = old.state;
MenuState newState;
if (menu.isLeaf) {
newState = oldSate.copyWith(activeMenu: menu.path);
} else {
List<String> menus = [];
String path = menu.path.substring(1);
List<String> parts = path.split('/');
if (parts.isNotEmpty) {
String path = '';
for (String part in parts) {
path += '/$part';
menus.add(path);
}
}
if (oldSate.expandMenus.contains(menu.path)) {
menus.remove(menu.path);
}
newState = oldSate.copyWith(expandMenus: menus);
}
emit(MenuLoadSuccess(
state: newState,
));
}