I want to redirect the user to the desired page depending on the "navigation" key, I tried in such ways:
final _bottomAppBarItem = [
{
'iconData': Icons.airplay,
'text': 'news',
'navigation': NewsPage(),
},
{
'iconData': Icons.person,
'text': 'profile',
'navigation': UserProfilePage(),
}];
Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => item['navigation']));
OR
final _bottomAppBarItem = [
{
'iconData': Icons.airplay,
'text': 'news',
'navigation': 'NewsPage',
},
{
'iconData': Icons.person,
'text': 'profile',
'navigation': 'UserProfilePage',
}];
Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => item['navigation']()));
But in both cases it turns out a mistake, how can I live with it?