Widget _buildMenuItem(BuildContext context, MenuItem item) {
return ExpansionTile(
title: Text(item.title),
children: _buildSubMenu(context, item.children),
);
}
List<Widget>? _buildSubMenu(BuildContext context, List<MenuItem>? children) {
if (children == null) {
return null;
}
return children.map((child) {
if (child.children != null) {
return _buildMenuItem(context, child);
} else {
return ListTile(
title: Text(child.title),
onTap: () {
Navigator.of(context).pop(); // Close the drawer
if (child.routeName != null) {
Navigator.pushNamed(context, child.routeName!);
}
},
);
}
}).toList();
}
This is the one page code of nested side menu in flutter every thing is working fine but I’m getting error here
The argument type 'List<Widget>?' can't be assigned to the parameter type 'List<Widget>'.
I’m new bee in flutter please help if possible
Thank you…!