Masahiro Okubo

The following assertion was thrown while handling a gesture:<br>Navigator operation requested with a context that does not include a Navigator.<br>The context used to push or pop routes from the Navigator must be that of a widget that is a<br>descendant of a Navigator widget.

The following assertion was thrown while handling a gesture:<br>Navigator operation requested with a context that does not include a Navigator.<br>The context used to push or pop routes from the Navigator must be that of a widget that is a<br>descendant of a Navigator widget.

flutterでRaisedButtonNavigator を入れたらタイトルのエラーが発生しました

// だめ
RaisedButton(
  onPressed: () {
  print("入った");
  Navigator.push(context, MaterialPageRoute(builder: (context) => GoogleMapSample()));},
  child: const Text('Mapをみる', style: TextStyle(fontSize: 20),),
),

// ok
Builder(
  builder: (context) {
    return RaisedButton(
      onPressed: () {
      print("入った");
      Navigator.push(context, MaterialPageRoute(builder: (context) => GoogleMapSample()));},
      child: const Text('Mapをみる', style: TextStyle(fontSize: 20),),
    );
  },
),

参考記事

【Flutter】画面遷移でのエラーについて

Buy Me A Coffee

関連記事

copyright© 2016-2021 Masahiro Okubo