import 'package:flutter/material.dart';
class Login extends StatelessWidget {
String username;
String password;
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
@override
Widget build(BuildContext context) {
Map<String, String> database = {"sumay": "Password12345"};
void login() {
final formState = formKey.currentState;
// If the form is validated and nothing is wrong with it
if (formState.validate()) {
formState.save();
if (database.containsKey(username)) {
if (database[username] == password) {
formKey.currentState.reset();
Navigator.push(context, MaterialPageRoute(builder: (context) => Home()));
}
else {
formKey.currentState.reset();
}
}
else {
formKey.currentState.reset();
}
}
else {
formKey.currentState.reset();
}
}
return Scaffold(
appBar: AppBar(title: Text("Login")),
body: ListView(
children: [
SizedBox(
height: 25,
),
// LOGO
Center(
child: Container(
child: Image.asset("images/logo.png"),
),
),
]
),
);
}
}