Initial project commit
This commit is contained in:
66
lib/login.dart
Normal file
66
lib/login.dart
Normal file
@@ -0,0 +1,66 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_pwa_test/Content.dart';
|
||||
|
||||
class Login extends StatelessWidget {
|
||||
static const String _password = "SGVsbG9Xb3JsZCE=";
|
||||
|
||||
Login({Key? key, required this.loginCallback}) : super(key: key);
|
||||
|
||||
final VoidCallback loginCallback;
|
||||
|
||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
autovalidateMode: AutovalidateMode.disabled,
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
constraints: const BoxConstraints(maxWidth: 500),
|
||||
child: TextFormField(
|
||||
decoration: const InputDecoration(
|
||||
labelText: "Password",
|
||||
hintText: "Password",
|
||||
alignLabelWithHint: true,
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
validator: (s) {
|
||||
if (s == null) {
|
||||
return "Please provide a value";
|
||||
}
|
||||
|
||||
var encoded = base64Encode(utf8.encode(s));
|
||||
print(encoded);
|
||||
if (encoded != _password) {
|
||||
return "Password is wrong";
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16.0),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
var result = _formKey.currentState?.validate();
|
||||
if (result == null || !result) {
|
||||
print(
|
||||
"Could not validate password because of an internal error");
|
||||
return;
|
||||
}
|
||||
|
||||
loginCallback();
|
||||
},
|
||||
child: const Text("Ok"),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user