@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Appcolors.white,
appBar: AppBar(
backgroundColor: Appcolors.white,
elevation: 0,
),
body: SingleChildScrollView(
child: SafeArea(
child: Column(
children: [
const Padding(
padding: EdgeInsets.fromLTRB(0, 30,0,0),
child: Center(child: Text('Welcome Back!',style: TextStyle(fontSize: 30,fontWeight: FontWeight.w700),)),
),
const SizedBox(height: 8),
const Text('Please enter your account here',style: TextStyle(fontSize: 15,fontWeight: FontWeight.w400),),
const SizedBox(height: 59,),
//Email textfield
Padding(
padding: const EdgeInsets.only(left: 31, right: 31),
child: TextField(
cursorColor: Appcolors.black,
decoration: InputDecoration(
fillColor: Appcolors.white,
filled: true,
prefixIcon: const Icon(Icons.email_outlined,color: Appcolors.black),
label: Text('Email'),
enabledBorder: OutlineInputBorder(
borderSide: const BorderSide(color: Appcolors.textfieldborder),
borderRadius: BorderRadius.circular(32)),
focusedBorder: OutlineInputBorder(
borderSide: const BorderSide(color: Appcolors.buttonColor),
borderRadius: BorderRadius.circular(32)),
),
),
),
const SizedBox(height: 30,),
//Password textfield
Padding(
padding: const EdgeInsets.only(left: 31, right: 31),
child: TextField(
cursorColor: Appcolors.black,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.lock,color: Appcolors.black),
label: const Text('Password'),
labelStyle: TextStyle(color: Appcolors.buttonColor),
suffixIcon: IconButton(onPressed: (){},
icon: const Icon(Icons.remove_red_eye_outlined,color: Appcolors.black)
),
enabledBorder: OutlineInputBorder(
borderSide: const BorderSide(color: Appcolors.textfieldborder),
borderRadius: BorderRadius.circular(32)),
focusedBorder: OutlineInputBorder(
borderSide: const BorderSide(color: Appcolors.buttonColor),
borderRadius: BorderRadius.circular(32)),
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(150, 10, 0, 0),
child: TextButton(onPressed: (){},
child: const Text('Forgot password?',style: TextStyle(color: Appcolors.forgotpassword, fontSize: 15,fontWeight: FontWeight.w500),)
),
),
const SizedBox(height: 30,),
ElevatedButton(
style: ElevatedButton.styleFrom(
minimumSize: const Size(300, 56),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(32)),
elevation: 0,primary: Appcolors.buttonColor),
onPressed: (){},
child: const Text('Login',
style: TextStyle(shadows: [
Shadow(offset: Offset(5.0, 5.0),
blurRadius: 12.0)
],
fontSize: 16,
fontWeight: FontWeight.w700),
)
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text('Don't have any accont?',style: TextStyle(fontSize: 15,fontWeight: FontWeight.w500)),
TextButton(onPressed: (){},
child: const Text('Sign Up',style: TextStyle(fontSize: 15,fontWeight: FontWeight.w700, color: Appcolors.buttonColor),))
],
),
const SizedBox(height: 15,),
Row(
children: const [
Expanded(
child: Divider(thickness: 1.5,indent: 30,endIndent: 10,)),
Text('Sign in with',style: TextStyle(fontSize: 15),),
Expanded(
child: Divider(thickness: 1.5,indent: 10,endIndent: 30))
],
),
const SizedBox(height: 40,),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
InkWell(
onTap: () {
},
child: const Image(
image:
AssetImage('assets/images/Facebook_Logo.png'),height: 30,),
),
const SizedBox(width: 50,),
InkWell(
onTap: () {
},
child: const Image(
image:
AssetImage('assets/images/Google__Logo.png'),height: 30,),
)
],
)
],
),
),
),
);
}
}
4
Answers
You can create a local variable in the context of the build that gets the size of the screen.
After that you can always use the size relative to the context.
For example like here:
To add up a bit on the other answer, you can also create an abstract class that contains your dimensions
If you then want to change your layout whenever a certain threshold is passed, you can check this class for the current dimensions
Try the following code:
On advance handling on small/tab/desktop and foldable screens use code given below:
for dual screen use package
https://pub.dev/packages/dual_screen,
just adjust your widgets accordingly.