英文:
i build drawer when when i tap on button it show me different error
问题
当我点击抽屉中的链接时,它显示了不同的错误。
当我点击抽屉中的任何链接时,它会卡住并显示错误消息,并将我带到其他错误页面。
class MainDrawer extends StatelessWidget {
const MainDrawer({super.key});
Widget buildListTitle(String title, IconData icon, Function function) {
return ListTile(
leading: Icon(
icon,
size: 20,
),
title: Text(
title,
style: TextStyle(
fontFamily: 'RobotoCondensed',
fontSize: 24,
fontWeight: FontWeight.bold),
),
onTap: function(),
);
}
@override
Widget build(BuildContext context) {
return Drawer(
child: Column(
children: [
Container(
height: 120,
width: double.infinity,
padding: EdgeInsets.all(20),
alignment: Alignment.centerLeft,
color: Theme.of(context).accentColor,
child: Text(
'cooking up',
style: TextStyle(
fontWeight: FontWeight.w900,
fontSize: 30,
color: Theme.of(context).primaryColor,
),
),
),
SizedBox(
height: 20,
),
buildListTitle("Meal", Icons.restaurant, () {
Navigator.of(context).pushNamed("/");
}),
buildListTitle("Meal", Icons.restaurant, () {
Navigator.of(context).pushNamed(FilterScreen.routeName);
}),
],
),
);
}
}
英文:
when i click on the link in drawer it show me different error.
when i click on any drawer link it stuck and give me error message and took me to other error page.
_///////////////////////////////////////////////////////
_///////////////////////////////////////////////////////
_///////////////////////////////////////////////////////
_///////////////////////////////////////////////////////
class MainDrawer extends StatelessWidget {
const MainDrawer({super.key});
Widget buildListTitle(String title, IconData icon, Function function) {
return ListTile(
leading: Icon(
icon,
size: 20,
),
title: Text(
title,
style: TextStyle(
fontFamily: 'RobotoCondensed',
fontSize: 24,
fontWeight: FontWeight.bold),
),
onTap: function(),
);
}
@override
Widget build(BuildContext context) {
return Drawer(
child: Column(
children: [
Container(
height: 120,
width: double.infinity,
padding: EdgeInsets.all(20),
alignment: Alignment.centerLeft,
color: Theme.of(context).accentColor,
child: Text(
'cooking up',
style: TextStyle(
fontWeight: FontWeight.w900,
fontSize: 30,
color: Theme.of(context).primaryColor,
),
),
),
SizedBox(
height: 20,
),
buildListTitle("Meal", Icons.restaurant, () {
Navigator.of(context).pushNamed("/");
}),
buildListTitle("Meal", Icons.restaurant, () {
Navigator.of(context).pushNamed(FilterScreen.routeName);
}),
],
),
);
}
}
答案1
得分: 2
在你的 buildListTitle
中将 onTap: function()
修改为 onTap: function
。
英文:
On your buildListTitle
change the onTap: function()
to onTap: function
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论