I am new to flutter. And I'm gaining more and more knowledge in a flutter.
I make A login screen long before for my Project But Someone suggest that your login screen not be scrolled up words should stick in the same position.
Brief about my screen.--
I added singleChildScrollview.I want to stop scrolling
below is my login screen. dart
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
),
body: Center(
child: SingleChildScrollView(
child: Container(
color: Colors.white12,
child: Padding(
padding: const EdgeInsets.all(36.0),
child: Form(
key: _formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
SizedBox(
height: 200,
child: Image.asset(
"assests/man.png",
fit: BoxFit.contain,
)),
SizedBox(height: 45),
emailField,
SizedBox(height: 25),
passwordField,
SizedBox(height: 35),
loginButton,
SizedBox(height: 15),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("Don't have an account ? "),
GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
RegistrationScreen()));
// Navigator.push(context, MaterialPageRoute(builder:(context)=>HomeScreen()));
},
child: Text(
"SignUp",
style: TextStyle(
color: Colors.redAccent,
fontWeight: FontWeight.w600,
fontSize: 15,
),
),
)
],
),
],
),
),
),
),
),
),
);
CodePudding user response:
Remove SingleChildScrollview
Like this
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
),
body: Center(
child: Container(
color: Colors.white12,
child: Padding(
padding: const EdgeInsets.all(36.0),
child: Form(
key: _formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
SizedBox(
height: 200,
child: Image.asset(
"assests/man.png",
fit: BoxFit.contain,
)),
SizedBox(height: 45),
emailField,
SizedBox(height: 25),
passwordField,
SizedBox(height: 35),
loginButton,
SizedBox(height: 15),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text("Don't have an account ? "),
GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
RegistrationScreen()));
// Navigator.push(context, MaterialPageRoute(builder:(context)=>HomeScreen()));
},
child: Text(
"SignUp",
style: TextStyle(
color: Colors.redAccent,
fontWeight: FontWeight.w600,
fontSize: 15,
),
),
)
],
),
],
),
),
),
),
),
);
CodePudding user response:
Add physics
to SingleChildScrollView
return SingleChildScrollView(
physics: const NeverScrollableScrollPhysics(),
// rest of the code here
);
Though i would not recommend it as if the screen size is small and if the keyboard opens up, a render overflow will occur.