Created
July 5, 2024 11:04
-
-
Save rayliverified/566d7a9e429e0ffa0f4b49e1345a3383 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:flutter/services.dart'; | |
void main() { | |
runApp(const MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
const MyApp({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return const MaterialApp( | |
title: 'MyApp Demo', | |
debugShowCheckedModeBanner: false, | |
home: Scaffold( | |
body: Canvas1(), | |
), | |
); | |
} | |
} | |
class Canvas1 extends StatelessWidget { | |
const Canvas1({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return Container( | |
alignment: Alignment(0.0, -0.7), | |
clipBehavior: Clip.hardEdge, | |
decoration: const BoxDecoration( | |
color: Colors.white, | |
), | |
child: SizedBox( | |
width: 250, | |
height: 142, | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
children: [ | |
SizedBox( | |
width: 250, | |
child: TextFormField( | |
keyboardType: TextInputType.text, | |
style: const TextStyle( | |
color: Colors.black, | |
fontSize: 14, | |
fontFamily: 'Roboto', | |
), | |
textAlign: TextAlign.left, | |
textAlignVertical: TextAlignVertical.center, | |
autocorrect: false, | |
minLines: null, | |
autovalidateMode: AutovalidateMode.onUserInteraction, | |
validator: (value) { | |
if (value == null || value.isEmpty) { | |
return 'This field is required.'; | |
} | |
final RegExp regex = RegExp( | |
r'^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$'); | |
final Match? match = regex.matchAsPrefix(value); | |
final bool isValid = | |
match?.start == 0 && match?.end == value.length; | |
if (isValid) return null; | |
return 'Invalid email address.'; | |
}, | |
cursorHeight: 14, | |
cursorRadius: const Radius.circular(2), | |
cursorColor: const Color(0xFF5C69E5), | |
autofillHints: const [AutofillHints.email], | |
decoration: InputDecoration( | |
labelText: 'Email', | |
labelStyle: const TextStyle( | |
color: Colors.grey, | |
fontSize: 14, | |
fontFamily: 'Roboto', | |
), | |
floatingLabelStyle: const TextStyle( | |
color: Colors.blue, | |
fontSize: 14, | |
fontFamily: 'Roboto', | |
), | |
errorStyle: const TextStyle( | |
color: Color(0xFFFF0000), | |
fontSize: 12, | |
fontFamily: 'Roboto', | |
), | |
errorMaxLines: 1, | |
floatingLabelBehavior: FloatingLabelBehavior.always, | |
isDense: true, | |
contentPadding: | |
const EdgeInsets.symmetric(horizontal: 12, vertical: 16), | |
focusColor: Colors.blue, | |
hoverColor: const Color(0x197F7F7F), | |
errorBorder: OutlineInputBorder( | |
borderRadius: BorderRadius.circular(4.0), | |
borderSide: const BorderSide( | |
color: Color(0xFFFF0000), | |
), | |
), | |
focusedBorder: OutlineInputBorder( | |
borderRadius: BorderRadius.circular(4.0), | |
borderSide: const BorderSide( | |
color: Colors.blue, | |
width: 1.5, | |
), | |
), | |
focusedErrorBorder: OutlineInputBorder( | |
borderRadius: BorderRadius.circular(4.0), | |
borderSide: const BorderSide( | |
color: Color(0xFFFF0000), | |
), | |
), | |
disabledBorder: OutlineInputBorder( | |
borderRadius: BorderRadius.circular(4.0), | |
borderSide: const BorderSide( | |
color: Color(0x197F7F7F), | |
), | |
), | |
enabledBorder: OutlineInputBorder( | |
borderRadius: BorderRadius.circular(4.0), | |
borderSide: const BorderSide( | |
color: Color(0x809E9E9E), | |
width: 1.5, | |
), | |
), | |
border: OutlineInputBorder( | |
borderRadius: BorderRadius.circular(4.0), | |
borderSide: const BorderSide( | |
color: Color(0x809E9E9E), | |
width: 1.5, | |
), | |
), | |
alignLabelWithHint: true, | |
), | |
), | |
), | |
SizedBox( | |
width: 250, | |
child: TextFormField( | |
keyboardType: TextInputType.text, | |
style: const TextStyle( | |
color: Colors.black, | |
fontSize: 14, | |
fontFamily: 'Roboto', | |
), | |
textAlign: TextAlign.left, | |
textAlignVertical: TextAlignVertical.center, | |
obscureText: true, | |
autocorrect: false, | |
minLines: null, | |
autovalidateMode: AutovalidateMode.onUserInteraction, | |
validator: (value) { | |
if (value == null || value.isEmpty) { | |
return 'This field is required.'; | |
} | |
}, | |
cursorHeight: 14, | |
cursorRadius: const Radius.circular(2), | |
cursorColor: const Color(0xFF5C69E5), | |
autofillHints: const [AutofillHints.password], | |
decoration: InputDecoration( | |
labelText: 'Password', | |
labelStyle: const TextStyle( | |
color: Colors.grey, | |
fontSize: 14, | |
fontFamily: 'Roboto', | |
), | |
floatingLabelStyle: const TextStyle( | |
color: Colors.blue, | |
fontSize: 14, | |
fontFamily: 'Roboto', | |
), | |
errorStyle: const TextStyle( | |
color: Color(0xFFFF0000), | |
fontSize: 12, | |
fontFamily: 'Roboto', | |
), | |
errorMaxLines: 1, | |
floatingLabelBehavior: FloatingLabelBehavior.always, | |
isDense: true, | |
contentPadding: | |
const EdgeInsets.symmetric(horizontal: 12, vertical: 16), | |
focusColor: Colors.blue, | |
hoverColor: const Color(0x197F7F7F), | |
errorBorder: OutlineInputBorder( | |
borderRadius: BorderRadius.circular(4.0), | |
borderSide: const BorderSide( | |
color: Color(0xFFFF0000), | |
), | |
), | |
focusedBorder: OutlineInputBorder( | |
borderRadius: BorderRadius.circular(4.0), | |
borderSide: const BorderSide( | |
color: Colors.blue, | |
width: 1.5, | |
), | |
), | |
focusedErrorBorder: OutlineInputBorder( | |
borderRadius: BorderRadius.circular(4.0), | |
borderSide: const BorderSide( | |
color: Color(0xFFFF0000), | |
), | |
), | |
disabledBorder: OutlineInputBorder( | |
borderRadius: BorderRadius.circular(4.0), | |
borderSide: const BorderSide( | |
color: Color(0x197F7F7F), | |
), | |
), | |
enabledBorder: OutlineInputBorder( | |
borderRadius: BorderRadius.circular(4.0), | |
borderSide: const BorderSide( | |
color: Color(0x809E9E9E), | |
width: 1.5, | |
), | |
), | |
border: OutlineInputBorder( | |
borderRadius: BorderRadius.circular(4.0), | |
borderSide: const BorderSide( | |
color: Color(0x809E9E9E), | |
width: 1.5, | |
), | |
), | |
alignLabelWithHint: true, | |
), | |
), | |
) | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment