Skip to content

Instantly share code, notes, and snippets.

@vaygeth89
Created October 16, 2021 04:24
Show Gist options
  • Save vaygeth89/9a28b469f427b84737d8b650a1316194 to your computer and use it in GitHub Desktop.
Save vaygeth89/9a28b469f427b84737d8b650a1316194 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
import 'package:tutorial_flutter_minimalist_authentication/models/account/sign_in.dart';
import 'package:tutorial_flutter_minimalist_authentication/widgets/sign_in_form.dart';
class SignInPage extends StatelessWidget {
const SignInPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Sign In Page"),
),
body: Container(
height: MediaQuery.of(context).size.height,
alignment: Alignment.center,
child: SignInForm(
onSignIn: (emailInput, passwordInput) {
//Todo add the cubit sign in call
},
)),
);
}
}
//Just reusable Sign In form Widget
class SignInForm extends StatefulWidget {
const SignInForm({Key? key, required this.onSignIn}) : super(key: key);
@override
_SignInFormState createState() => _SignInFormState();
final Function(String, String) onSignIn;
}
class _SignInFormState extends State<SignInForm> {
final emailTextController = TextEditingController(text: "");
final passwordTextController = TextEditingController(text: "");
final emailFocusNode = FocusNode();
final passwordFocusNode = FocusNode();
@override
Widget build(BuildContext context) {
return Container(
constraints: BoxConstraints(minWidth: 200, maxWidth: 300),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
TextField(
controller: emailTextController,
focusNode: emailFocusNode,
decoration: InputDecoration(hintText: "Email"),
),
SizedBox(
height: 10,
),
TextField(
controller: passwordTextController,
focusNode: passwordFocusNode,
obscureText: true,
decoration: InputDecoration(hintText: "Password"),
),
SizedBox(
height: 15,
),
MaterialButton(
child: Text("Sign In"),
color: Theme.of(context).primaryColor,
onPressed: () {
widget.onSignIn(
emailTextController.text, passwordTextController.text);
})
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment