Skip to content

Instantly share code, notes, and snippets.

@salihgueler
Created August 26, 2022 15:04
Show Gist options
  • Save salihgueler/048c75e901d45ca2243f3d1c1bb3c2e4 to your computer and use it in GitHub Desktop.
Save salihgueler/048c75e901d45ca2243f3d1c1bb3c2e4 to your computer and use it in GitHub Desktop.
return Form(
key: _formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextFormField(
controller: _usernameController,
keyboardType: TextInputType.name,
decoration: const InputDecoration(
labelText: 'Username',
border: OutlineInputBorder(),
),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter your username';
}
return null;
},
),
const SizedBox(height: 12),
TextFormField(
controller: _passwordController,
keyboardType: TextInputType.visiblePassword,
obscureText: true,
decoration: const InputDecoration(
labelText: 'Password',
border: OutlineInputBorder(),
),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter your password';
}
return null;
},
),
const SizedBox(height: 12),
ErrorText(errorMessage: _errorMessage),
ElevatedButton(
onPressed: _loginUser,
child: AppButton(
buttonText: 'Login',
isLoading: _isLoading,
),
),
const SizedBox(height: 12),
RichText(
textAlign: TextAlign.center,
text: TextSpan(
text: 'Don\'t have an account?\n',
style: Theme.of(context).textTheme.caption?.copyWith(
fontWeight: FontWeight.w700,
),
children: [
TextSpan(
text: 'Click here to register.',
style:
Theme.of(context).textTheme.caption?.copyWith(
decoration: TextDecoration.underline,
fontWeight: FontWeight.w700,
),
mouseCursor: SystemMouseCursors.click,
recognizer: TapGestureRecognizer()
..onTap = () => context.go('/sign-up'),
),
],
),
),
],
),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment