Can some one help me with Flutter.
I'm trying to (Navigate to a new screen and back.)
Follow the guide here:
https://flutter.dev/docs/cookbook/navigation/navigation-basics
But i got this error here:
Another exception was thrown: Navigator operation requested with a context that does not include a Navigator.
Here is my Simple Flutter code:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget{
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp>{
@override
Widget build(BuildContext context){
return new MaterialApp(
title: 'Welcome',
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
title: Text('Welcome to view by view'),
),
body: Center(
child: Wrap(
children: <Widget>[
RaisedButton(
child: Text('View 2'),
onPressed: (){
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SecondRoute()),
);
},
)
],
),
),
)
);
}
}
class SecondRoute extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Second Route"),
),
body: Center(
child: RaisedButton(
onPressed: () {
Navigator.pop(context);
},
child: Text('Go back!'),
),
),
);
}
}
Thanks!