ingmbk
ingmbk

Reputation: 152

error while using onTap function inside ListTile

while using onTap function i got this error Function expressions can't be named. Try removing the name, or moving the function expression to a function declaration statement.

                    ListTile(
                      leading: Icon(Icons.home),
                      title: Text('Home'),
                      onTap() =>Navigator.of(context).push(MaterialPageRoute(builder: (context) => HomeScreen()),)
                      )

Upvotes: 0

Views: 1462

Answers (1)

Pete K
Pete K

Reputation: 128

You are missing a ':' after onTap. It should read:

ListTile(
        leading: Icon(Icons.home),
        title: Text('Home'),
        onTap: () => Navigator.of(context)
            .push(MaterialPageRoute(builder: (context) => HomeScreen())));

Upvotes: 1

Related Questions