Let's start linking the two screens in the app:
- Start by engaging in one the most enjoyable activities for a developer – deleting code.
- Remove the loggedIn property and all the parts of the code where it's referenced. We're also no longer going to need the buildSuccess() method or the ternary method in the top build method.
- Update the build method with the following snippet:
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Login'),
),
body: Center(
child: _buildLoginForm(),
),
);
}
- In the _validate method, we can kick off the navigation instead of calling setState:
void _validate() {
final form = _formKey.currentState;
if (!form.validate()) {
return;
}
final name = _nameController.text;
final email = _emailController.text;
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => StopWatch(name: name, email...