Back
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でRaisedButton
にNavigator
を入れたらタイトルのエラーが発生しました
// だめ
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),),
);
},
),