onItemClick method

void onItemClick(
  1. int index,
  2. Menu obj
)

Implementation

void onItemClick(int index, Menu obj) {
  if(obj.subs.isNotEmpty){ // parent
    setState(() {
      if (prevExpand != -1) {
        menus[prevExpand].expand = false;
      }
      menus[index] = obj;
      prevExpand = obj.expand ? index : -1;
    });
  } else { // child
    if(obj.route == null) return;
    Navigator.push(context, MaterialPageRoute(builder: (BuildContext context){
      return obj.route!;
    })).then((value) {

    });
  }
}