import 'package:flutter/material.dart';
class SignUp extends StatelessWidget {
String username_signup;
String password_signup;
final GlobalKey<FormState> formKey2 = GlobalKey<FormState>();
void signup() {
final formState = formKey2.currentState;
if (formState.validate()) {
formState.save();
database[username_signup] = password_signup;
print(database);
}
else {
formKey2.currentState.reset();
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Sign Up")),
body: ListView(
children: [
SizedBox(
height: 25,
),
// LOGO
Center(
child: Container(
child: Image.asset("images/logo.png"),
Form(
// This is the key used to validate the forms input
key: formKey,
child: Column(
children: <Widget>[
// USERNAME //
TextFormField(
// This is to define the border and to label the text
decoration: InputDecoration(
labelText: "Enter a username",
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0)
)
),
// Checks the user input to see if it is valid
validator: (input) {
if (input.isEmpty) {
return "Please enter a username";
}
return null;
},
// If the validator passed, then save the information
onSaved: (input) => username_signup = input,
),
SizedBox(
height: 10,
),
// PASSWORD //
TextFormField(
// This is to define the border and to label the text
decoration: InputDecoration(
labelText: "Enter a password",
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10.0)
)
),
// Checks the user input to see if it is valid
validator: (input) {
if (input.isEmpty) {
return "Please enter a password";
}
return null;
},
obscureText: true,
// If the validator passed, then save the information
onSaved: (input) => password_signup = input,
),
]
),
),
),
]
),
);
}
}