I was trying to connect 2 slides(Login and registration) but I get the below error. The error comes when I click the "Don't Have an Account?" text which should send me to the registration slide. This is the error
═══════ Exception caught by gesture ═══════════════════ The following assertion was thrown while handling a gesture: Navigator operation requested with a context that does not include a Navigator.
The context used to push or pop routes from the Navigator must be that of a widget that is a descendant of a Navigator widget.
This is my login file
import 'package:flutter/material.dart';
import 'package:scroll_app_2/register.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget{
@override
Widget build(BuildContext context){
Color hexToColor(String code) {
return new Color(int.parse(code.substring(1, 7), radix: 16) + 0xFF000000);
}
return MaterialApp(
debugShowCheckedModeBanner: false,
title: "Welcome to Flutter",
home: new Material(
child: new Container (
padding: const EdgeInsets.all(30.0),
color: Colors.white,
child: new Container(
child: new Center(
child: new Column(
children : [
new Padding(padding: EdgeInsets.only(top: 140.0)),
new Text('Welcome!', //heading
style: new TextStyle(color: hexToColor("#0000"), fontSize: 30.0),),
new Padding(padding: EdgeInsets.only(top: 50.0)),
// email text field is below
new TextFormField(
decoration: new InputDecoration(
labelText: "Enter Email",
fillColor: Colors.blue,
border: new OutlineInputBorder(
borderRadius: new BorderRadius.circular(17.0),
borderSide: new BorderSide(
),
),
),
validator: (val) {
if(val.length==0) {
return "Email cannot be empty";
}else{
return null;
}
},
keyboardType: TextInputType.emailAddress,
style: new TextStyle(
fontFamily: "Poppins",
),
),
new Padding(padding: EdgeInsets.only(top: 20.0)),
//password text field is below
new TextFormField(
obscureText: true,
decoration: new InputDecoration(
labelText: "Enter Password",
fillColor: Colors.blue,
border: new OutlineInputBorder(
borderRadius: new BorderRadius.circular(17.0),
borderSide: new BorderSide(
),
),
//fillColor: Colors.green
),
validator: (val) {
if(val.length==0) {
return "Password cannot be empty";
}else{
return null;
}
},
keyboardType: TextInputType.emailAddress,
style: new TextStyle(
fontFamily: "Poppins",
),
),
new Padding(padding: EdgeInsets.only(top: 10.0)),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
new Text("Forgot Password?", style: TextStyle(
fontSize: 15.0,
color: Colors.grey[800],
fontFamily: "poppins",
letterSpacing: 1.2,
),)
],
),
new Padding(padding: EdgeInsets.only(top: 15.0)),
//Login button below
RaisedButton (
onPressed: () {},
color: Colors.amber,
padding: EdgeInsets.fromLTRB(75.0, 10.0, 75.0, 10.0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(17)),
child: Text("Login", style: TextStyle(
fontSize: 20.0,
letterSpacing: 1.2,
),),
),
new Padding(padding: EdgeInsets.only(top: 150.0)),
InkWell(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => RegisterPage())
);
},
child: new Text(
"Don't Have an Account?",
style: TextStyle(
fontSize: 15.0,
letterSpacing: 1.2,
),
),
)
]
)
),
)
)
)
);
}
}
This is my register file which I want to go to when the text is clicked
import 'package:flutter/material.dart';
class RegisterPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: new Material(
child: new Container (
padding: const EdgeInsets.all(30.0),
color: Colors.yellowAccent,
),
),
);
}
}