select method
void
select(
Implementation
void select(MenuNode menu) {
bool hasHistory = _history.where((e) => e.menuPath == menu.path).isNotEmpty;
print("=====select: ${hasHistory}===============");
if (hasHistory) {
_shouldAddHistory = false;
// goRouter.go(menu.path);
return;
}
if (menu.isLeaf) {
_state = state.copyWith(activeMenu: menu.path);
// goRouter.go(menu.path);
_history.add(MenuHistory(
menuLabel: menu.label,
menuPath: menu.path,
));
// notifyListeners();
} 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 (state.expandMenus.contains(menu.path)) {
menus.remove(menu.path);
}
_state = state.copyWith(expandMenus: menus);
notifyListeners();
}
}