We're going to take a small break from the stopwatch for this recipe:
-
Create a new file called login_screen.dart and generate the code snippet for a new StatefulWidget by typing stful and tapping Enter. Your IDE will automatically create a placeholder widget and its state class.
-
Name this class LoginScreen. The State class will automatically be named _LoginScreenState. Don't forget to fix your missing imports by bringing in the material library.
-
Our login screen needs to know whether the user is logged in to show the appropriate widget tree. We can handle this by having a boolean property called loggedIn and forking the widget tree accordingly.
-
Add the following code just under the class declaration of _LoginScreenState:
bool loggedIn = false;
String name;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Login'),
),
...