Search code examples
androidflutterdartiso

i build drawer when when i tap on button it show me different error


when i click on the link in drawer it show me different error.

enter image description here

when i click on any drawer link it stuck and give me error message and took me to other error page. _/////////////////////////////////////////////////////// enter image description here

_/////////////////////////////////////////////////////// enter image description here

_///////////////////////////////////////////////////////

enter image description here

_///////////////////////////////////////////////////////

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);
          }),
        ],
      ),
    );
  }
}

Solution

  • On your buildListTitle change the onTap: function() to onTap: function