Как настроить кнопку возврата go в браузере для Flutter Web App - PullRequest
0 голосов
/ 20 апреля 2020

Я не спрашиваю о веб-просмотре. Это о веб-приложении Flutter. Мне нужно go вернуться на указанную c страницу, когда пользователь нажимает кнопку «назад», встроенную в браузер.

enter image description here

Есть предположения?

Я получаю эту ошибку, когда нажимаю кнопку возврата

Error: Assertion failed: org-dartlang- 
    sdk:///flutter_web_sdk/lib/_engine/engine/history.dart:110:14 
    _userProvidedRouteName != null
    is not true
        at Object.throw_ [as throw] (http://localhost:8300/dart_sdk.js:4770:11)
        at Object.assertFailed (http://localhost:8300/dart_sdk.js:4721:15)

1 Ответ

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

onWillPop Перейти на новую страницу

class webScope extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new WillPopScope(
      onWillPop: () async => Navigator.push(context, MaterialPageRoute(builder: (context) => new NewPageWidget())),
      child: Scaffold(
        appBar: new AppBar(
          title: new Text("webScope"),
        ),
      ),
    );
  }
}
...