Flutter Navigation undefined "context" - flutter

I´m new to flutter and dart and I´m trying to build a Sign up for an app.
I got a start screen (StartPage) with options "login", "login FB", "sign up with email".
When I hit "login" I can navigate to the signup_email_screen. From there I want to navigate to the signup_email_screen_two but it throws "undefined name context".
class StartPage extends StatefulWidget {
#override
_StartPageState createState() => _StartPageState();
}
class _StartPageState extends State<StartPage> {
bool isAuth = false; //isAuth provides a bool if the user is already signed in
Widget buildAuthScreen() {
return Text('Angemeldet');
}
Scaffold buildUnAuthScreen() {
return Scaffold(
body: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/tenor.gif'),
fit: BoxFit.cover)),
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(height: SizeConfig.blockSizeVertical * 10),
Container(
width: SizeConfig.blockSizeHorizontal * 65,
height: SizeConfig.blockSizeVertical * 20,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/Insta_transparent.png'),
fit: BoxFit.scaleDown,
),
),
),
SizedBox(height: SizeConfig.blockSizeVertical * 0),
Text(
'Nie mehr Langeweile',
style: TextStyle(
fontFamily: "Signatra",
fontSize: SizeConfig.blockSizeHorizontal *8,
color: Colors.white,
),
),
SizedBox(height: SizeConfig.blockSizeVertical * 7),
GestureDetector(
onTap: () => _navigateToLogin(context),
child: Container(
width: SizeConfig.blockSizeHorizontal * 70,
height: SizeConfig.blockSizeVertical * 7,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/Log_In_Button.png'),
fit: BoxFit.scaleDown,
),
),
)),
SizedBox(height: SizeConfig.blockSizeVertical * 2),
GestureDetector(
onTap: () => print('facebook signin'),
child: Container(
width: SizeConfig.blockSizeHorizontal * 70,
height: SizeConfig.blockSizeVertical * 7,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/Log_In_Button_FB.png'),
fit: BoxFit.scaleDown,
),
),
),
),
SizedBox(height: SizeConfig.blockSizeVertical * 2),
GestureDetector(
onTap: () => _navigateToEmailRegister(context),
child: Container(
width: SizeConfig.blockSizeHorizontal * 60,
height: SizeConfig.blockSizeVertical *7,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
'assets/images/button-email-registration.png'),
fit: BoxFit.scaleDown,
),
),
),
),
],
),
),
);
}
void _navigateToLogin(BuildContext context) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => LoginScreen(),
));
}
void _navigateToEmailRegister(BuildContext context) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SignupEmailScreen(),
));
}
#override
Widget build(BuildContext context) {
SizeConfig().init(context);
return isAuth ? buildAuthScreen() : buildUnAuthScreen();
}
}
class SignupEmailScreen extends StatelessWidget {
Scaffold signupEmailScreen() {
return Scaffold(
body: Stack(
children: [
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/StartPage_Background.jpg'),
fit: BoxFit.cover)),
alignment: Alignment.center,
),
//AppBar transparent and background full screen with Stack and Positioned
Positioned(
top: 0.0,
left: 0.0,
right: 0.0,
child: AppBar(
title: Text('Registrierung'),
backgroundColor: Colors.transparent, //transparent
elevation: 0.0, //Shadow gone
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
SizedBox(height: SizeConfig.blockSizeVertical * 15),
//Insta image
Container(
width: SizeConfig.blockSizeHorizontal * 50,
height: SizeConfig.blockSizeVertical * 10,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/Insta_transparent.png'),
fit: BoxFit.scaleDown,
),
),
),
SizedBox(height: SizeConfig.blockSizeVertical * 7),
//Email text field
Padding(
padding: EdgeInsets.symmetric(
horizontal: SizeConfig.safeBlockHorizontal * 5),
child: TextField(
keyboardType: TextInputType.text,
style: TextStyle(color: Colors.white, fontSize: 20.0),
decoration: InputDecoration(
labelText: "Accountname",
labelStyle: TextStyle(
color: Colors.white,
),
hasFloatingPlaceholder: true,
enabledBorder: UnderlineInputBorder(
//Enables the border to change color
borderSide:
BorderSide(color: Colors.white, width: 2.0)),
focusedBorder: UnderlineInputBorder(
borderSide:
BorderSide(color: Colors.white, width: 2.0)),
),
),
),
//Password text field
Padding(
padding: EdgeInsets.symmetric(
horizontal: SizeConfig.safeBlockHorizontal * 5),
child: TextField(
keyboardType: TextInputType.emailAddress,
style: TextStyle(color: Colors.white, fontSize: 20.0),
decoration: InputDecoration(
labelText: "Email",
labelStyle: TextStyle(
color: Colors.white,
),
hasFloatingPlaceholder: true,
enabledBorder: UnderlineInputBorder(
//Enables the border to change color
borderSide:
BorderSide(color: Colors.white, width: 2.0)),
focusedBorder: UnderlineInputBorder(
borderSide:
BorderSide(color: Colors.white, width: 2.0)),
),
),
),
Padding(
padding: EdgeInsets.symmetric(
horizontal: SizeConfig.safeBlockHorizontal * 5),
child: TextField(
keyboardType: TextInputType.visiblePassword,
style: TextStyle(color: Colors.white, fontSize: 20.0),
decoration: InputDecoration(
labelText: "Passwort",
labelStyle: TextStyle(
color: Colors.white,
),
hasFloatingPlaceholder: true,
enabledBorder: UnderlineInputBorder(
//Enables the border to change color
borderSide:
BorderSide(color: Colors.white, width: 2.0)),
focusedBorder: UnderlineInputBorder(
borderSide:
BorderSide(color: Colors.white, width: 2.0)),
),
),
),
Padding(
padding: EdgeInsets.symmetric(
horizontal: SizeConfig.safeBlockHorizontal * 5),
child: TextField(
keyboardType: TextInputType.visiblePassword,
style: TextStyle(color: Colors.white, fontSize: 20.0),
decoration: InputDecoration(
labelText: "Passwort wiederholen",
labelStyle: TextStyle(
color: Colors.white,
),
hasFloatingPlaceholder: true,
enabledBorder: UnderlineInputBorder(
//Enables the border to change color
borderSide:
BorderSide(color: Colors.white, width: 2.0)),
focusedBorder: UnderlineInputBorder(
borderSide:
BorderSide(color: Colors.white, width: 2.0)),
),
),
),
SizedBox(height: SizeConfig.blockSizeVertical * 10),
//log in button
GestureDetector(
onTap: () => _navigateToSignupEmailScreenTwo(context),
child: Container(
width: SizeConfig.blockSizeHorizontal * 70,
height: SizeConfig.blockSizeVertical * 7,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/Log_In_Button.png'),
fit: BoxFit.scaleDown,
),
),
)),
],
),
],
),
);
}
//ACTIONS
void _navigateToSignupEmailScreenTwo(BuildContext context) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SignupEmailScreenTwo(),
));
}
//BUILD
#override
Widget build(BuildContext context) {
return signupEmailScreen();
}
}
class SignupEmailScreenTwo extends StatelessWidget {
Scaffold signupEmailScreenTwo() {
return Scaffold(
body: Stack(
children: [
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/StartPage_Background.jpg'),
fit: BoxFit.cover)),
alignment: Alignment.center,
),
//AppBar transparent and background full screen with Stack and Positioned
Positioned(
top: 0.0,
left: 0.0,
right: 0.0,
child: AppBar(
title: Text('Registrierung'),
backgroundColor: Colors.transparent, //transparent
elevation: 0.0, //Shadow gone
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
SizedBox(height: SizeConfig.blockSizeVertical * 15),
Container(
width: SizeConfig.blockSizeHorizontal * 50,
height: SizeConfig.blockSizeVertical * 10,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/Insta_transparent.png'),
fit: BoxFit.scaleDown,
),
),
),
SizedBox(height: SizeConfig.blockSizeVertical * 7),
//Email text field
Padding(
padding: EdgeInsets.symmetric(
horizontal: SizeConfig.safeBlockHorizontal * 5),
child: TextField(
keyboardType: TextInputType.text,
style: TextStyle(color: Colors.white, fontSize: 20.0),
decoration: InputDecoration(
labelText: "Dein Vorname",
labelStyle: TextStyle(
color: Colors.white,
),
hasFloatingPlaceholder: true,
enabledBorder: UnderlineInputBorder(
//Enables the border to change color
borderSide:
BorderSide(color: Colors.white, width: 2.0)),
focusedBorder: UnderlineInputBorder(
borderSide:
BorderSide(color: Colors.white, width: 2.0)),
),
),
),
//Password text field
Padding(
padding: EdgeInsets.symmetric(
horizontal: SizeConfig.safeBlockHorizontal * 5),
child: TextField(
keyboardType: TextInputType.datetime,
style: TextStyle(color: Colors.white, fontSize: 20.0),
decoration: InputDecoration(
labelText: "Dein Geburtsdatum",
labelStyle: TextStyle(
color: Colors.white,
),
hasFloatingPlaceholder: true,
enabledBorder: UnderlineInputBorder(
//Enables the border to change color
borderSide:
BorderSide(color: Colors.white, width: 2.0)),
focusedBorder: UnderlineInputBorder(
borderSide:
BorderSide(color: Colors.white, width: 2.0)),
),
),
),
SizedBox(height: SizeConfig.blockSizeVertical * 10),
//log in button
GestureDetector(
onTap: () => print("Einlogggggeeeeeen"),
child: Container(
width: SizeConfig.blockSizeHorizontal * 70,
height: SizeConfig.blockSizeVertical * 7,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/Log_In_Button.png'),
fit: BoxFit.scaleDown,
),
),
)),
],
),
],
),
);
}
#override
Widget build(BuildContext context) {
return signupEmailScreenTwo();
}
}
Why is the context undefined?
Appreciate any help!

Because context undefined inside your function :)
**Edit: ** You cant reach context object inside StatelessWidget
These are what you can do:
1- Use StatefulWidget instead of StatelessWidget,
2- You can pass BuildContext context as a parameter into your functions.
3- You can write all widgets inside build method instead of extra function.

Related

How to design shadow with border look like below image using flutter?

How I design UI as like as below image using flutter,
Design page
import 'package:flutter/material.dart';
import 'package:shaon_project/themes/light_color.dart';
import '../wigets/apply_form.dart';
class ApplyNewScreen extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [LightColor.docBackStart, LightColor.docBackEnd])),
child: Scaffold(
backgroundColor: Colors.transparent,
appBar: AppBar(
title: const Text('Apply New'),
),
body: Center(
child: Container(
height: 430,
width: 310,
child: Stack(
children: [
Positioned(
top: 20,
left: 10,
child: SizedBox(
height: 410,
width: 300,
child: Card(
color: LightColor.cardBottomColor,
elevation: 20,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50),
side: BorderSide(color: Colors.white, width: 3),
),
),
),
),
SizedBox(
height: 420,
width: 300,
child: Card(
color: Colors.white,
elevation: 20,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50),
side: BorderSide(color: Colors.white, width: 3),
),
child: ApplyForm(),
),
),
],
),
),
),
),
);
}
}
Form page:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class ApplyForm extends StatelessWidget {
#override
Widget build(BuildContext context) {
return ListView(
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 20),
children: \[
TextFormField(
decoration: const InputDecoration(
border: UnderlineInputBorder(),
labelText: 'University Name',
),
),
SizedBox(
height: 10,
),
TextFormField(
decoration: const InputDecoration(
border: UnderlineInputBorder(),
labelText: 'Course Type',
),
),
SizedBox(
height: 10,
),
TextFormField(
decoration: const InputDecoration(
border: UnderlineInputBorder(),
labelText: 'Course Module',
),
),
SizedBox(
height: 10,
),
TextFormField(
decoration: const InputDecoration(
border: UnderlineInputBorder(),
labelText: 'Your IELTS Score',
),
),
SizedBox(
height: 20,
),
Center(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: RichText(
text: const TextSpan(
text: 'Status: ',
style: TextStyle(fontWeight: FontWeight.bold),
children: <TextSpan>\[
TextSpan(
text: 'Eligible',
style: TextStyle(
fontWeight: FontWeight.bold, color: Colors.teal)),
\],
),
),
),
),
SizedBox(
height: 20,
),
Column(
children: \[
ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.red, // background
onPrimary: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0),
),
), // foreground
onPressed: () {},
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
child: Text(
'Apply',
style: TextStyle(fontSize: 20),
),
),
)
\],
)
\],
);
}
}

I want to check my rules with Validator, but the validator is not working

I have a few rules for validator e-mail and password of my registration page and I want to check them. But it's not working.
import 'package:flutter/material.dart';
class register extends StatefulWidget {
register({Key? key}) : super(key: key);
#override
_registerState createState() => _registerState();
}
class _registerState extends State<register> {
late TextEditingController textController1;
late TextEditingController textController2;
late bool passwordVisibility1;
late TextEditingController textController3;
late bool passwordVisibility2;
final scaffoldKey = GlobalKey<ScaffoldState>();
String email = '';
String password = '';
String error = '';
#override
void initState() {
super.initState();
textController1 = TextEditingController();
textController2 = TextEditingController();
passwordVisibility1 = false;
textController3 = TextEditingController();
passwordVisibility2 = false;
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Stack(
children: [
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height * 1,
decoration: BoxDecoration(
color: Color(0xFFEEEEEE),
image: DecorationImage(
fit: BoxFit.cover,
image: Image.asset(
'assets/img/backgraund_page.jpg',
).image,
),
),
),
Align(
alignment: AlignmentDirectional(0, -0.8),
child: Image.asset(
'assets/logo/Aet_page-0001-removebg-preview.png',
width: 250,
height: 170,
fit: BoxFit.contain,
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 300, 0, 0),
child: Container(
width: MediaQuery.of(context).size.width,
height: 565,
decoration: const BoxDecoration(
color: Color(0xFFEEEEEE),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(0),
bottomRight: Radius.circular(0),
topLeft: Radius.circular(50),
topRight: Radius.circular(50),
),
),
child: Stack(
children: [
Padding(
padding: EdgeInsetsDirectional.fromSTEB(40, 70, 0, 0),
child: Container(
width: MediaQuery.of(context).size.width * 0.8,
height: 50,
decoration: const BoxDecoration(
color: Color(0xFFEEEEEE),
),
child: TextFormField(
validator: (val) =>
val!.isEmpty ? 'Enter an email' : null,
onChanged: (val) {
setState(() {
email = val;
});
},
controller: textController1,
obscureText: false,
decoration: const InputDecoration(
hintText: 'E-Posta',
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1,
),
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1,
),
),
),
keyboardType: TextInputType.emailAddress,
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(40, 120, 0, 0),
child: Container(
width: MediaQuery.of(context).size.width * 0.8,
height: 50,
decoration: const BoxDecoration(
color: Color(0xFFEEEEEE),
),
child: TextFormField(
validator: (val) => val!.length < 6
? 'Ender a password 6+ chars long'
: null,
onChanged: (val) {
setState(() {
password = val;
});
},
controller: textController2,
obscureText: !passwordVisibility1,
decoration: InputDecoration(
hintText: 'Password',
enabledBorder: const UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1,
),
),
focusedBorder: const UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1,
),
),
suffixIcon: InkWell(
onTap: () => setState(
() =>
passwordVisibility1 = !passwordVisibility1,
),
child: Icon(
passwordVisibility1
? Icons.visibility_outlined
: Icons.visibility_off_outlined,
color: Color(0xFF757575),
size: 22,
),
),
),
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(40, 170, 0, 0),
child: Container(
width: MediaQuery.of(context).size.width * 0.8,
height: 50,
decoration: BoxDecoration(
color: Color(0xFFEEEEEE),
),
child: TextFormField(
controller: textController3,
obscureText: !passwordVisibility2,
decoration: InputDecoration(
hintText: 'Confirm Password',
enabledBorder: const UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1,
),
),
focusedBorder: const UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1,
),
),
suffixIcon: InkWell(
onTap: () => setState(
() =>
passwordVisibility2 = !passwordVisibility2,
),
child: Icon(
passwordVisibility2
? Icons.visibility_outlined
: Icons.visibility_off_outlined,
color: Color(0xFF757575),
size: 22,
),
),
),
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(40, 120, 0, 0),
child: Container(
width: MediaQuery.of(context).size.width * 0.8,
height: 1,
decoration: BoxDecoration(
color: Color(0xFFEEEEEE),
border: Border.all(
color: Color(0xFFB9B7B7),
),
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(40, 170, 0, 0),
child: Container(
width: MediaQuery.of(context).size.width * 0.8,
height: 1,
decoration: BoxDecoration(
color: Color(0xFFEEEEEE),
border: Border.all(
color: Color(0xFFB9B7B7),
),
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(40, 220, 0, 0),
child: Container(
width: MediaQuery.of(context).size.width * 0.8,
height: 1,
decoration: BoxDecoration(
color: Color(0xFFEEEEEE),
border: Border.all(
color: Color(0xFFB9B7B7),
),
),
),
),
Padding(
// ignore: prefer_const_constructors
padding: EdgeInsetsDirectional.fromSTEB(40, 270, 0, 0),
// ignore: deprecated_member_use
child: SizedBox(
height: 40,
width: MediaQuery.of(context).size.width * 0.8,
child: RaisedButton(
onPressed: () {
print(email);
print(password);
},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
color: Color(0xFF36A8D3),
child: const Center(
child: Text(
"Sign In",
style: TextStyle(color: Colors.white),
),
),
),
),
),
const Padding(
padding: EdgeInsetsDirectional.fromSTEB(65, 512, 0, 0),
child: Text(
'Are you already a member?',
style: TextStyle(
fontFamily: 'Poppins',
fontSize: 15,
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(265, 512, 0, 0),
child: InkWell(
onTap: () async {
await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => loginpage(),
),
);
},
child: const Text(
'Login In',
style: TextStyle(
fontFamily: 'Poppins',
color: Colors.blue,
fontSize: 15,
),
),
),
),
],
),
),
),
],
),
),
);
}
}
hello everyone, above are the codes for my registration page. With Validator I have a few rules required for e-mail password and I want to check these rules, but the validator is not working at all. How can I fix this. Can you help me?
You have to wrap your TextFormField with Form.
import 'package:flutter/material.dart';
class register extends StatefulWidget {
register({Key? key}) : super(key: key);
#override
_registerState createState() => _registerState();
}
class _registerState extends State<register> {
late TextEditingController textController1;
late TextEditingController textController2;
late bool passwordVisibility1;
late TextEditingController textController3;
late bool passwordVisibility2;
final scaffoldKey = GlobalKey<ScaffoldState>();
final formKey = GlobalKey<FormState>();
String email = '';
String password = '';
String error = '';
#override
void initState() {
super.initState();
textController1 = TextEditingController();
textController2 = TextEditingController();
passwordVisibility1 = false;
textController3 = TextEditingController();
passwordVisibility2 = false;
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Stack(
children: [
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height * 1,
decoration: BoxDecoration(
color: Color(0xFFEEEEEE),
image: DecorationImage(
fit: BoxFit.cover,
image: Image.asset(
'assets/img/backgraund_page.jpg',
).image,
),
),
),
Align(
alignment: AlignmentDirectional(0, -0.8),
child: Image.asset(
'assets/logo/Aet_page-0001-removebg-preview.png',
width: 250,
height: 170,
fit: BoxFit.contain,
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 300, 0, 0),
child: Container(
width: MediaQuery.of(context).size.width,
height: 565,
decoration: const BoxDecoration(
color: Color(0xFFEEEEEE),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(0),
bottomRight: Radius.circular(0),
topLeft: Radius.circular(50),
topRight: Radius.circular(50),
),
),
child: Form(
key: formKey,
child: Stack(
children: [
Padding(
padding: EdgeInsetsDirectional.fromSTEB(40, 70, 0, 0),
child: Container(
width: MediaQuery.of(context).size.width * 0.8,
height: 50,
decoration: const BoxDecoration(
color: Color(0xFFEEEEEE),
),
child: TextFormField(
validator: (val) =>
val!.isEmpty ? 'Enter an email' : null,
onChanged: (val) {
setState(() {
email = val;
});
},
controller: textController1,
obscureText: false,
decoration: const InputDecoration(
hintText: 'E-Posta',
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1,
),
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1,
),
),
),
keyboardType: TextInputType.emailAddress,
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(40, 120, 0, 0),
child: Container(
width: MediaQuery.of(context).size.width * 0.8,
height: 50,
decoration: const BoxDecoration(
color: Color(0xFFEEEEEE),
),
child: TextFormField(
validator: (val) => val!.length < 6
? 'Ender a password 6+ chars long'
: null,
onChanged: (val) {
setState(() {
password = val;
});
},
controller: textController2,
obscureText: !passwordVisibility1,
decoration: InputDecoration(
hintText: 'Password',
enabledBorder: const UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1,
),
),
focusedBorder: const UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1,
),
),
suffixIcon: InkWell(
onTap: () => setState(
() =>
passwordVisibility1 = !passwordVisibility1,
),
child: Icon(
passwordVisibility1
? Icons.visibility_outlined
: Icons.visibility_off_outlined,
color: Color(0xFF757575),
size: 22,
),
),
),
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(40, 170, 0, 0),
child: Container(
width: MediaQuery.of(context).size.width * 0.8,
height: 50,
decoration: BoxDecoration(
color: Color(0xFFEEEEEE),
),
child: TextFormField(
controller: textController3,
obscureText: !passwordVisibility2,
decoration: InputDecoration(
hintText: 'Confirm Password',
enabledBorder: const UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1,
),
),
focusedBorder: const UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1,
),
),
suffixIcon: InkWell(
onTap: () => setState(
() =>
passwordVisibility2 = !passwordVisibility2,
),
child: Icon(
passwordVisibility2
? Icons.visibility_outlined
: Icons.visibility_off_outlined,
color: Color(0xFF757575),
size: 22,
),
),
),
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(40, 120, 0, 0),
child: Container(
width: MediaQuery.of(context).size.width * 0.8,
height: 1,
decoration: BoxDecoration(
color: Color(0xFFEEEEEE),
border: Border.all(
color: Color(0xFFB9B7B7),
),
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(40, 170, 0, 0),
child: Container(
width: MediaQuery.of(context).size.width * 0.8,
height: 1,
decoration: BoxDecoration(
color: Color(0xFFEEEEEE),
border: Border.all(
color: Color(0xFFB9B7B7),
),
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(40, 220, 0, 0),
child: Container(
width: MediaQuery.of(context).size.width * 0.8,
height: 1,
decoration: BoxDecoration(
color: Color(0xFFEEEEEE),
border: Border.all(
color: Color(0xFFB9B7B7),
),
),
),
),
Padding(
// ignore: prefer_const_constructors
padding: EdgeInsetsDirectional.fromSTEB(40, 270, 0, 0),
// ignore: deprecated_member_use
child: SizedBox(
height: 40,
width: MediaQuery.of(context).size.width * 0.8,
child: RaisedButton(
onPressed: () {
if(!formKey.currentState!.validate()) return;
print(email);
print(password);
},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
color: Color(0xFF36A8D3),
child: const Center(
child: Text(
"Sign In",
style: TextStyle(color: Colors.white),
),
),
),
),
),
const Padding(
padding: EdgeInsetsDirectional.fromSTEB(65, 512, 0, 0),
child: Text(
'Are you already a member?',
style: TextStyle(
fontFamily: 'Poppins',
fontSize: 15,
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(265, 512, 0, 0),
child: InkWell(
onTap: () async {
await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => loginpage(),
),
);
},
child: const Text(
'Login In',
style: TextStyle(
fontFamily: 'Poppins',
color: Colors.blue,
fontSize: 15,
),
),
),
),
],
),
),
),
),
],
),
),
);
}
}

Using Positioned inside Stack is not working properly

I am using a Stack which has Card and Positioned Elements as can be seen in the below image. These Positioned Elements contains the buttons. The issue I am facing is that the lower part of these buttons are hidden.
Also I have not given any extra margin. It might be because of Bottom Navigation Part.
image
This is the code
Stack(
children: <Widget>[
Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0)),
child: Padding(
padding: EdgeInsets.symmetric(
vertical: 40.0, horizontal: 20.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expanded(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Container(
width: size.width * 0.2,
child: StreamBuilder<String>(
stream: bloc.skills,
builder: (context, snapshot) {
return TextField(
onChanged: bloc.changeSkills,
decoration: new InputDecoration(
contentPadding:
EdgeInsets.symmetric(
vertical: 0,
horizontal: 15.0),
border: new OutlineInputBorder(
borderSide:
const BorderSide(
width: 2.0,
style:
BorderStyle
.solid),
borderRadius:
BorderRadius
.circular(
50.0)),
focusedBorder:
OutlineInputBorder(
borderSide:
const BorderSide(
color:
Colors.grey,
width: 2.0),
borderRadius:
BorderRadius.circular(
50.0),
),
hintText: 'Skills',
hintStyle: new TextStyle(
color: Colors.grey,
fontWeight:
FontWeight.bold),
errorText: snapshot.error),
);
}),
),
SizedBox(height: 20.0),
Container(
width: size.width * 0.2,
child: StreamBuilder<String>(
stream: bloc.role,
builder: (context, snapshot) {
return TextField(
onChanged: bloc.changeRole,
decoration: new InputDecoration(
contentPadding:
EdgeInsets.symmetric(
vertical: 0,
horizontal: 15.0),
border: new OutlineInputBorder(
borderSide:
const BorderSide(
width: 2.0,
style:
BorderStyle
.solid),
borderRadius:
BorderRadius
.circular(
50.0)),
focusedBorder:
OutlineInputBorder(
borderSide:
const BorderSide(
color:
Colors.grey,
width: 2.0),
borderRadius:
BorderRadius.circular(
50.0),
),
hintText: 'Role',
hintStyle: new TextStyle(
color: Colors.grey,
fontWeight:
FontWeight.bold),
errorText: snapshot.error),
);
}),
),
],
),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Container(
width: size.width * 0.2,
child: StreamBuilder<String>(
stream: bloc.language,
builder: (context, snapshot) {
return TextField(
onChanged: bloc.changeLanguage,
decoration: new InputDecoration(
contentPadding:
EdgeInsets.symmetric(
vertical: 0,
horizontal: 15.0),
border: new OutlineInputBorder(
borderSide:
const BorderSide(
width: 2.0,
style:
BorderStyle
.solid),
borderRadius:
BorderRadius
.circular(
50.0)),
focusedBorder:
OutlineInputBorder(
borderSide:
const BorderSide(
color:
Colors.grey,
width: 2.0),
borderRadius:
BorderRadius.circular(
50.0),
),
hintText: 'Language',
hintStyle: new TextStyle(
color: Colors.grey,
fontWeight:
FontWeight.bold),
errorText: snapshot.error),
);
}),
),
SizedBox(height: 20.0),
Container(
width: size.width * 0.2,
child: StreamBuilder<String>(
stream: bloc.gender,
builder: (context, snapshot) {
return DropdownButtonHideUnderline(
child:
new DropdownButtonFormField<
String>(
items: <String>[
'Female',
'Male',
'Other'
].map((String value) {
return new DropdownMenuItem<
String>(
value: value,
child: new Text(value),
);
}).toList(),
onChanged: bloc.changeGender,
decoration:
new InputDecoration(
contentPadding:
EdgeInsets
.symmetric(
vertical:
0,
horizontal:
15.0),
border: new OutlineInputBorder(
borderSide:
const BorderSide(
width:
2.0,
style: BorderStyle
.solid),
borderRadius:
BorderRadius
.circular(
50.0)),
focusedBorder:
OutlineInputBorder(
borderSide:
const BorderSide(
color: Colors
.grey,
width: 2.0),
borderRadius:
BorderRadius
.circular(
50.0),
),
hintText: 'Gender',
hintStyle:
new TextStyle(
color: Colors
.grey,
fontWeight:
FontWeight
.bold),
errorText:
snapshot.error),
),
);
}),
)
],
),
),
],
),
),
),
Positioned(
left: size.width * 0.02,
top: size.height * 0.58 + 2,
child: new Container(
width: 100.0,
height: 40.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(50.0),
color: Colors.white,
border: Border.all(
width: 2.0, color: Colors.grey)),
child: Align(
alignment: Alignment.center,
child: new Text(
'Back',
style: TextStyle(
color: Colors.grey,
fontWeight: FontWeight.bold),
),
),
)),
Positioned(
right: size.width * 0.02,
top: size.height * 0.58 + 2,
child: new Container(
width: 100.0,
height: 40.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(50.0),
color: primaryColor,
// border: Border.all(width: 2.0, color: Colors.grey)
),
child: Align(
alignment: Alignment.center,
child: new Text(
'Create',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold),
),
),
)),
],
),
Add overflow: Overflow.visible, to the Stack

Bottom overflowed by 182 pixels

I am trying to add textfields in a widget on Flutter, and it renders correctly, but when the text is pressed to enter the data, appears the following error:
"Bottom overflowed by 182 pixels"
The error is when the default keyboard appears. I don't know why is it happening since i am wrapping everything in a SingleChildScrollView widget, therefore, should work just fine.
Attached the code:
class TextFieldsState extends State<TextFields> {
#override
Widget build(BuildContext context) {
const colorRed = Color(0xFFF0786E);
return SingleChildScrollView(
child: Container(
margin: EdgeInsets.symmetric(
horizontal: 20.0,
vertical: 20.0,
),
//color: Colors.greenAccent,
height: 500,
child: Stack(
//alignment: Alignment.bottomCenter,
children: <Widget>[
Container (
height: 500,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(22.0),
color: colorRed,
),
child: Container (
height: 500,
margin: EdgeInsets.only(right: 10,),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(22),
),
),
),
Center(
child: Positioned (
child: SizedBox(
height: 136,
//width: size.width,
child: Column(
children: <Widget>[
Container(
height: 30,
width: 160,
child: TextField(
decoration: InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.blue,
),
borderRadius: BorderRadius.circular(10.0),
),
hintText: 'Name',
),
textAlign: TextAlign.center,
),
),
SizedBox(height: 20.0),
Container(
height: 30,
width: 160,
child: TextField(
decoration: InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.blue,
),
borderRadius: BorderRadius.circular(10.0),
),
hintText: 'Surname',
),
textAlign: TextAlign.center,
),
),
SizedBox(height: 20.0),
Container(
height: 30,
width: 160,
child: TextField(
decoration: InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.blue,
),
borderRadius: BorderRadius.circular(10.0),
),
hintText: 'Nationality',
),
textAlign: TextAlign.center,
),
),
],
),
),
),
),
],
),
),
);
}
}
What is the solution, please?
try this please
SingleChildScrollView(
column( // your column
)
)
overflow error is in column and you should add SingleChildScrollView as parent of this column.
Please check the edited below code.
class TextFieldsState extends State<TextFields> {
#override
Widget build(BuildContext context) {
const colorRed = Color(0xFFF0786E);
return Scaffold(
body: SingleChildScrollView(
child: Container(
margin: EdgeInsets.symmetric(
horizontal: 20.0,
vertical: 20.0,
),
//color: Colors.greenAccent,
height: 500,
child: Stack(
//alignment: Alignment.bottomCenter,
children: <Widget>[
Container(
height: 500,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(22.0),
color: colorRed,
),
child: Container(
height: 500,
margin: EdgeInsets.only(
right: 10,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(22),
),
),
),
Center(
child: SizedBox(
height: 136,
//width: size.width,
child: SingleChildScrollView(
child: Column(
children: <Widget>[
Container(
height: 30,
width: 160,
child: TextField(
decoration: InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.blue,
),
borderRadius: BorderRadius.circular(10.0),
),
hintText: 'Name',
),
textAlign: TextAlign.center,
),
),
SizedBox(height: 20.0),
Container(
height: 30,
width: 160,
child: TextField(
decoration: InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.blue,
),
borderRadius: BorderRadius.circular(10.0),
),
hintText: 'Surname',
),
textAlign: TextAlign.center,
),
),
SizedBox(height: 20.0),
Container(
height: 30,
width: 160,
child: TextField(
decoration: InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.blue,
),
borderRadius: BorderRadius.circular(10.0),
),
hintText: 'Nationality',
),
textAlign: TextAlign.center,
),
),
],
),
),
),
),
],
),
),
),
);
}
}
I ended up wrapping everything with a Expanded widget and the column with the Text fields I wrapped it with a SingleChilsScrollView and it worked perfectly.

Flutter :- How to scroll the sceen without shrink the screen on the Stack view?(Scroll the the whole screen when the keyboard appears )

Description I am creating the login screen in which I have used the Stack widget, Currently, everything works fine but only one issue of the shrinking the view. When I use the resizeToAvoidBottomPadding: false inside the Scaffold then screen shrinking disappear but another problem arise that whole screen scroll not working, please check below lines of code
class _LoginScreen extends State<LoginScreen> {
#override
Widget build(BuildContext context) {
// TODO: implement build
return Scaffold(
resizeToAvoidBottomPadding: false,
body: Stack(
children: <Widget>[
Container(
height: double.infinity,
width: double.infinity,
child: Column(
children: <Widget>[
Expanded(
flex: 4,
child: Column(
children: <Widget>[
Expanded(
flex: 9,
child: Container(
color: Colors.blue,
child: Align(
alignment: Alignment.centerLeft,
child: RotatedBox(
quarterTurns: 3,
child: Container(
child: Padding(
padding: EdgeInsets.all(5),
child: Text(
"Login !!",
style: TextStyle(
fontSize: 30.0,
color: Colors.white),
),
),
),
),
)),
),
Expanded(
flex: 1,
child: Container(
color: Colors.white,
),
)
],
)),
Expanded(
flex: 6,
child: Container(
color: Colors.white,
),
)
],
),
),
Padding(
padding: EdgeInsets.only(left: 20.0, right: 20.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Image(
image: new AssetImage("images/logo.png"),
color: null,
height: 100.0,
width: 100.0,
fit: BoxFit.scaleDown,
alignment: Alignment.center,
),
SizedBox(
height: 20.0,
),
TextField(
keyboardType: TextInputType.number,
inputFormatters: [
LengthLimitingTextInputFormatter(10),
],
decoration: new InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.blue, width: 2.0),
),
enabledBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.grey, width: 2.0),
),
hintText: "Please enter mobile number")),
SizedBox(
height: 10.0,
),
TextField(
obscureText: true,
inputFormatters: [
LengthLimitingTextInputFormatter(16),
],
keyboardType: TextInputType.visiblePassword,
decoration: new InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.blue, width: 2.0),
),
enabledBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.grey, width: 2.0),
),
hintText: "Password")),
SizedBox(
height: 3.0,
),
Align(
alignment: Alignment.topRight,
child: Text(
"Forgot Password?",
style: TextStyle(fontSize: 12.0),
)),
SizedBox(
height: 3.0,
),
SizedBox(
height: 10.0,
),
RaisedButton(
onPressed: () {},
color: Colors.blue,
child: const Text(
'Login',
style: TextStyle(fontSize: 15.0, color: Colors.black45),
),
)
],
),
),
],
));
}
}
From Above code, I am getting the following screen
I have used the ListView and SingleChildScrollView but it not working properly, please check my code with SingleChildScrollView, which i have tried
class _LoginScreen extends State<LoginScreen> {
#override
Widget build(BuildContext context) {
// TODO: implement build
return Scaffold(
resizeToAvoidBottomPadding: false,
body: SingleChildScrollView(
child: IntrinsicHeight(
child: Stack(
children: <Widget>[
Container(
height: double.infinity,
width: double.infinity,
child: Column(
children: <Widget>[
Expanded(
flex: 4,
child: Column(
children: <Widget>[
Expanded(
flex: 9,
child: Container(
color: Colors.blue,
child: Align(
alignment: Alignment.centerLeft,
child: RotatedBox(
quarterTurns: 3,
child: Container(
child: Padding(
padding: EdgeInsets.all(5),
child: Text(
"Login !!",
style: TextStyle(
fontSize: 30.0,
color: Colors.white),
),
),
),
),
)),
),
Expanded(
flex: 1,
child: Container(
color: Colors.white,
),
)
],
)),
Expanded(
flex: 6,
child: Container(
color: Colors.white,
),
)
],
),
),
Padding(
padding: EdgeInsets.only(left: 20.0, right: 20.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Image(
image: new AssetImage("images/logo.png"),
color: null,
height: 100.0,
width: 100.0,
fit: BoxFit.scaleDown,
alignment: Alignment.center,
),
SizedBox(
height: 20.0,
),
TextField(
keyboardType: TextInputType.number,
inputFormatters: [
LengthLimitingTextInputFormatter(10),
],
decoration: new InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.blue, width: 2.0),
),
enabledBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.grey, width: 2.0),
),
hintText: "Please enter mobile number")),
SizedBox(
height: 10.0,
),
TextField(
obscureText: true,
inputFormatters: [
LengthLimitingTextInputFormatter(16),
],
keyboardType: TextInputType.visiblePassword,
decoration: new InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.blue, width: 2.0),
),
enabledBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.grey, width: 2.0),
),
hintText: "Password")),
SizedBox(
height: 3.0,
),
Align(
alignment: Alignment.topRight,
child: Text(
"Forgot Password?",
style: TextStyle(fontSize: 12.0),
)),
SizedBox(
height: 3.0,
),
SizedBox(
height: 10.0,
),
RaisedButton(
onPressed: () {},
color: Colors.blue,
child: const Text(
'Login',
style: TextStyle(fontSize: 15.0, color: Colors.black45),
),
)
],
),
),
],
)),
));
}
}
And From the above code getting this result by using the SingleChildScrollView
Problem:- I want to scroll the whole screen when the keyboard appears, I have used all the Listview and SingleChildScrollView but not getting the solution, please help me on it. Thanks
The problem is you're using Expanded widgets, you see expanded widgets are flexible in nature they will consume and shrink according to the available space. If you don't want that you need to specify a height.
https://i.imgur.com/wVgAUlN.mp4
class StacScroll extends StatefulWidget {
StacScroll({Key key}) : super(key: key);
#override
_StacScrollState createState() => _StacScrollState();
}
class _StacScrollState extends State<StacScroll> {
#override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: true,
body: Container(
height: double.infinity,
width: double.infinity,
// margin:
// EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
child: SingleChildScrollView(
child: Stack(
children: <Widget>[
Container(
color: Colors.blue,
height: MediaQuery.of(context).size.height * 0.3,
width: MediaQuery.of(context).size.width,
child: RotatedBox(
quarterTurns: 3,
child: Container(
child: Padding(
padding: EdgeInsets.all(5),
child: Text(
"Login !!",
style:
TextStyle(fontSize: 30.0, color: Colors.white),
),
),
)),
),
Container(
margin: EdgeInsets.only(
top: MediaQuery.of(context).size.height * 0.3),
child: Padding(
padding: EdgeInsets.only(left: 20.0, right: 20.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Image(
image: new AssetImage("images/logo.png"),
color: null,
height: 100.0,
width: 100.0,
fit: BoxFit.scaleDown,
alignment: Alignment.center,
),
SizedBox(
height: 20.0,
),
TextField(
keyboardType: TextInputType.number,
decoration: new InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.blue, width: 2.0),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.grey, width: 2.0),
),
hintText: "Please enter mobile number")),
SizedBox(
height: 10.0,
),
TextField(
obscureText: true,
keyboardType: TextInputType.visiblePassword,
decoration: new InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.blue, width: 2.0),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.grey, width: 2.0),
),
hintText: "Password")),
SizedBox(
height: 3.0,
),
Align(
alignment: Alignment.topRight,
child: Text(
"Forgot Password?",
style: TextStyle(fontSize: 12.0),
)),
SizedBox(
height: 3.0,
),
SizedBox(
height: 10.0,
),
RaisedButton(
onPressed: () {},
color: Colors.blue,
child: const Text(
'Login',
style: TextStyle(
fontSize: 15.0, color: Colors.black45),
),
)
],
),
),
),
],
),
),
));
}
}
Thanks #Nadeem by which problem has resolved
Whenever we want to scroll the full screen when keyboard appear then we should not use the Expand widget for it.I was also doing the same mistake, for the other user i have modified the code for full scroll when keyboard appear, I have used the MediaQuery for it,Please check my below code of it.
import 'package:flutter/material.dart';
class LoginScreen extends StatefulWidget {
#override
State<StatefulWidget> createState() {
// TODO: implement createState
return _LoginScreen();
}
}
class _LoginScreen extends State<LoginScreen> {
#override
Widget build(BuildContext context) {
// TODO: implement build
return Scaffold(
appBar: AppBar(
title: Text("Login"),
),
body: Container(
height: double.infinity,
width: double.infinity,
child: SingleChildScrollView(
child: Stack(
children: <Widget>[
Container(
color: Colors.blue,
height: MediaQuery.of(context).size.height * 0.3,
),
Container(
color: Colors.white,
height: MediaQuery.of(context).size.height * 0.59,
padding: EdgeInsets.all(10.0),
margin: EdgeInsets.only(
top: MediaQuery.of(context).size.height * 0.3),
child: Container(
margin: EdgeInsets.only(top: 70.0),
child: Column(
children: <Widget>[
TextFormField(
decoration: InputDecoration(
labelText: 'Enter your username')),
TextFormField(
decoration: InputDecoration(labelText: 'Password')),
SizedBox(
height: 20.0,
),
RaisedButton(
color: Colors.yellow,
child: Text("Submit",
style: TextStyle(color: Colors.blue)),
onPressed: () {},
)
],
),
)),
Center(
child: Card(
color: Colors.yellow,
elevation: 8,
margin: EdgeInsets.only(
top: MediaQuery.of(context).size.height * .25),
child: Container(
child: Center(
child: Text(
"Radhe",
style: TextStyle(color: Colors.blue, fontSize: 20.0),
)),
height: MediaQuery.of(context).size.height * .1,
width: MediaQuery.of(context).size.width * .3,
),
),
)
],
),
),
),
);
}
}
Please check the output of it.