Как вы переходите на новую страницу / маршрут, используя ListTile во Flutter? - PullRequest
0 голосов
/ 26 апреля 2020

В Flutter я пытаюсь перейти на новую страницу, когда нажимаю на виджет ListTile. Я пытаюсь использовать функцию ontap (), однако она не работает.

ListTile(
                leading: Icon(Icons.border_color),
                title: Text('Freelance English Native needed'),
                subtitle: Text('Requirements: Native English'),
                onTap: () {
                  Navigator.pushNamed(context, '/second');
                },
              ),

MaterialApp(
  // Start the app with the "/" named route. In this case, the app starts
  // on the FirstScreen widget.
  initialRoute: '/',
  routes: {
    // When navigating to the "/" route, build the FirstScreen widget.
    '/': (context) => MyApp(),
    // When navigating to the "/second" route, build the SecondScreen widget.
    '/second': (context) => SecondScreen(),
  },
);

1 Ответ

0 голосов
/ 26 апреля 2020

попробуйте

ListTile(
                leading: Icon(Icons.border_color),
                title: Text('Freelance English Native needed'),
                subtitle: Text('Requirements: Native English'),
                onTap: () {
                 Navigator.push(
                   context,
                    MaterialPageRoute(builder: (context) => SecondScreen()),
        );
                },
              ),
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...