I am trying to create a form that has a card and a login button:
I have tried the following code:
import 'package:flutter/material.dart';
class LoginScreenDemo extends StatefulWidget {
#override
_LoginScreenState createState() => new _LoginScreenState();
}
class _LoginScreenState extends State<LoginScreenDemo> {
#override
Widget build(BuildContext context) {
final email = TextFormField(
keyboardType: TextInputType.emailAddress,
autofocus: false,
style: TextStyle(fontSize: 25.0),
decoration: InputDecoration(
labelText: 'Email',
contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
border: OutlineInputBorder(borderRadius: BorderRadius.circular(10.0)),
),
);
final password = TextFormField(
obscureText: true,
autofocus: false,
style: TextStyle(fontSize: 25.0),
decoration: InputDecoration(
labelText: 'Password',
contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
border: OutlineInputBorder(borderRadius: BorderRadius.circular(10.0)),
),
);
final loginButton = Padding(
padding: EdgeInsets.only(top: 10.0),
child: RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0),
),
onPressed: () {},
padding: EdgeInsets.symmetric(vertical: 12.0, horizontal: 30.0),
color: Colors.lightBlueAccent,
child: Text(
'LOGIN',
style: TextStyle(
color: Colors.white,
fontSize: 25.0,
fontWeight: FontWeight.bold,
),
),
),
);
final goToSignUpScreen = Padding(
padding: EdgeInsets.only(top: 5.0),
child: FlatButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0),
),
onPressed: () {
Navigator.of(context).pushNamed('/signup');
},
child: Text(
"New account? Sign Up",
style: TextStyle(
fontSize: 15.0,
),
),
),
);
final loginCard = Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.0),
),
color: Colors.white,
elevation: 4.0,
child: ListView(
shrinkWrap: true,
padding:
EdgeInsets.only(top: 100.0, left: 50.0, right: 50.0, bottom: 75.0),
children: <Widget>[
email,
SizedBox(height: 15.0),
password,
],
),
);
final buttonsContainer = Container(
alignment: Alignment.bottomCenter,
padding: EdgeInsets.only(
top: MediaQuery.of(context).orientation == Orientation.landscape
? MediaQuery.of(context).size.height * 0.35
: MediaQuery.of(context).size.height * 0.26,
),
child: Column(
children: <Widget>[
loginButton,
goToSignUpScreen,
],
),
);
final backgroundContainer = Container(
height: MediaQuery.of(context).size.height * 0.40,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/background_golf_course.jpeg'),
fit: BoxFit.cover,
),
),
);
final formContainer = Container(
alignment: Alignment.topCenter,
padding: EdgeInsets.only(
top: MediaQuery.of(context).size.height * 0.25,
right: 20.0,
left: 20.0,
),
child: Container(
width: MediaQuery.of(context).size.width * 0.75,
child: Stack(
children: <Widget>[
loginCard,
buttonsContainer,
],
),
),
);
return SafeArea(
child: Container(
color: Color(0xFFEEEEEE),
child: Stack(
children: <Widget>[
backgroundContainer,
formContainer,
],
),
),
);
}
}
I have placed the card and buttons in a stack widget and tried to place the buttons (as seen in buttonsContainer) above the card by defining their height and padding.
As, can be seen, I need to define different padding for portrait and landscape modes and also, it breaks if the screen size changes.
Is there a neater way to implement this?
Thanks
Container does have a property transform. Usage of this is an alternative to the top padding. Then buttonsContainer is placed relative to loginCard but is overlapping.
Widget buttonsContainer has a translation to the top.
final buttonsContainer = Container(
transform: Matrix4.translationValues(0.0, -34.0, 0.0),
alignment: Alignment.bottomCenter,
child: Column(
children: <Widget>[
loginButton,
goToSignUpScreen,
],
),
);
Widget formContainer then uses Column instead of Stack.
final formContainer = Container(
alignment: Alignment.topCenter,
padding: EdgeInsets.only(
top: MediaQuery.of(context).size.height * 0.25,
right: 20.0,
left: 20.0,
),
child: Container(
width: MediaQuery.of(context).size.width * 0.75,
child: Column(
children: <Widget>[
loginCard,
buttonsContainer,
],
),
),
);
Related
I have a CustomScrollView contains a SliverToBoxAdapter.I gave width as MediaQuery.of(context).size.width / 1.75.But it takes full width of screen .
enter image description here.
Width of container is working if it is placed outside of Customscrollview.
class ProfileView extends GetView<ProfileController> {
const ProfileView({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: Row(children: [
Expanded(
child: CustomScrollView(
shrinkWrap: true,
slivers: [
SliverToBoxAdapter(
child: Padding(
padding:
const EdgeInsets.only(top: 40.0, left: 45),
child: Container(
padding: EdgeInsets.only(top: 30),
width: MediaQuery.of(context).size.width / 1.75,
decoration: BoxDecoration(
border:
Border.all(color: Colors.red, width: 0.7),
color: Color(0xfffbfbfa),
),
child: Stack(
children: [
Positioned(
right: 0,
top: 0,
child: Align(
alignment: Alignment.topRight,
child: MouseRegion(
cursor: SystemMouseCursors.click,
child: Padding(
padding: const EdgeInsets.only(
right: 18.0),
child: Text(
"Edit",
textAlign: TextAlign.left,
style: GoogleFonts.inter(
color: AppColors.primaryColor,
fontSize: 13,
letterSpacing:
0
,
fontWeight: FontWeight.w400,
height: 1.5769230769230769),
),
),
),
),
),
Text("Text"),
],
),
),
),
)
],
),
)
])
);
}
you have to wrap your container with Align widget like this:
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.only(top: 40.0, left: 45),
child: Align(
alignment: Alignment.center,
child: Container(
padding: const EdgeInsets.only(top: 30),
width: MediaQuery.of(context).size.width / 1.75,
decoration: BoxDecoration(
border: Border.all(color: Colors.red, width: 0.7),
color: Colors.amber,
),
....
I just started learning flutter and am trying to build a todo app, the problem I encountered was the widget buildActionSwipeLeft() set as dismissible background goes up rather than left to right after the list item is dismissed although I set the direction of the dismissible from left to right or start to end. Any help would be appreciated.
My code:
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(
horizontal: 24.0,
),
color: const Color(0xfff6f6f6f6),
child: Stack(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
margin: const EdgeInsets.only(bottom: 32.0, top: 32.0),
child: const Text(
"Reminders",
style: TextStyle(
fontSize: 25.0,
fontWeight: FontWeight.bold
),
),
),
Expanded(
child: ListView.builder(
itemCount: todos.length,
physics: const BouncingScrollPhysics(),
itemBuilder: (BuildContext context, int index) {
return Padding(
padding: const EdgeInsets.only(
bottom: 15.0
),
child: Card(
color: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
elevation: 4,
child: ClipRRect(
clipBehavior: Clip.antiAlias,
child: Dismissible(
background: buildActionSwipeLeft(),
onDismissed: (direction) {
setState(() {
todos.removeAt(index);
_titleController.removeAt(index);
_detailController.removeAt(index);
});
},
direction: DismissDirection.startToEnd,
key: UniqueKey(),
child: Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(
vertical: 13.0,
horizontal: 24.0
),
margin: const EdgeInsets.only(
bottom: 20.0,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextField(
cursorColor: Colors.black,
controller: _titleController[index],
style: const TextStyle(
fontSize: 22.0,
fontWeight: FontWeight.bold
),
decoration: const InputDecoration(
hintText: "Enter a title",
border: InputBorder.none,
),
),
const Divider(
color: Colors.black,
),
Padding(
padding: const EdgeInsets.only(top: 0.0),
child: TextField(
controller: _detailController[index],
style: TextStyle(
fontSize: 20.0,
color: Colors.grey[900],
),
cursorColor: Colors.black,
maxLines: null,
decoration: const InputDecoration(
hintText: "Enter the description",
label: Text("description"),
border: InputBorder.none
),
),
),
],
),
),
),
),
),
);
},
),
)
],
),
Positioned(
bottom: 24.0,
right: 0.0,
child: GestureDetector(
onTap: () {
setState(() {
todos.add('');
_titleController.add(TextEditingController());
_detailController.add(TextEditingController());
});
},
child: Container(
width: 60.0,
height: 60.0,
decoration: BoxDecoration(
color: Colors.black87,
borderRadius: BorderRadius.circular(20.0),
),
child: const Icon(Icons.add, color: Colors.white, size: 35.0),
),
),
)
],
),
),
),
);
}
}
Widget buildActionSwipeLeft() => Container(
alignment: Alignment.centerLeft,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16.0),
color: Colors.redAccent,
),
padding: const EdgeInsets.symmetric(horizontal: 30),
child: const Icon(Icons.delete, color: Colors.white, size: 30),
);
I figured out that this was not an issue as this is the default animation thats played when a list tile wrapped in a dismissible widget is dismissed. And the dismiss direction just determines the direction in which you can swipe the widget and not the direction in which the widget animates after dismissal.
I just started learning flutter and am trying to build a todo app, the problem I encountered was the Dismissible container and the todo list view item have different heights and after trying everything I still couldn't fix it, the next problem was that the todo item would be dismissed from left to right whereas the container would go up. Any help would be much appreciated. My code:
class _HomePageState extends State<HomePage> {
List todos = [];
List<TextEditingController> _titleController = [];
List<TextEditingController> _detailController = [];
#override
void initState() {
super.initState();
todos.add('');
_titleController.add(TextEditingController());
_detailController.add(TextEditingController());
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(
horizontal: 24.0,
),
color: const Color(0xfff6f6f6f6),
child: Stack(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
margin: const EdgeInsets.only(bottom: 32.0, top: 32.0),
child: const Text(
"Reminders",
style: TextStyle(
fontSize: 25.0,
fontWeight: FontWeight.bold
),
),
),
Expanded(
child: ListView.builder(
itemCount: todos.length,
physics: const BouncingScrollPhysics(),
itemBuilder: (BuildContext context, int index) {
return Dismissible(
background: buildActionSwipeLeft(),
onDismissed: (direction) {
setState(() {
todos.removeAt(index);
_titleController.removeAt(index);
_detailController.removeAt(index);
DismissDirection.startToEnd;
});
},
direction: DismissDirection.startToEnd,
key: Key(todos[index]),
child: Padding(
padding: const EdgeInsets.only(
bottom: 15.0
),
child: Card(
color: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
elevation: 4,
child: Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(
vertical: 15.0,
horizontal: 24.0
),
margin: const EdgeInsets.only(
bottom: 20.0,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextField(
cursorColor: Colors.black,
controller: _titleController[index],
style: const TextStyle(
fontSize: 22.0,
fontWeight: FontWeight.bold
),
decoration: const InputDecoration(
hintText: "Enter a title",
border: InputBorder.none,
),
),
const Divider(
color: Colors.black,
),
Padding(
padding: const EdgeInsets.only(top: 0.0),
child: TextField(
controller: _detailController[index],
style: TextStyle(
fontSize: 20.0,
color: Colors.grey[900],
),
cursorColor: Colors.black,
maxLines: null,
decoration: const InputDecoration(
hintText: "Enter the description",
label: Text("description"),
border: InputBorder.none
),
),
),
],
),
),
),
),
);
},
),
)
],
),
Positioned(
bottom: 24.0,
right: 0.0,
child: GestureDetector(
onTap: () {
setState(() {
todos.add('');
_titleController.add(TextEditingController());
_detailController.add(TextEditingController());
});
},
child: Container(
width: 60.0,
height: 60.0,
decoration: BoxDecoration(
color: Colors.black87,
borderRadius: BorderRadius.circular(20.0),
),
child: const Icon(Icons.add, color: Colors.white, size: 35.0),
),
),
)
],
),
),
),
);
}
}
Widget buildActionSwipeLeft() => Container(
alignment: Alignment.centerLeft,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0),
color: Colors.red,
),
padding: const EdgeInsets.symmetric(horizontal: 30),
child: const Icon(Icons.delete, color: Colors.white, size: 30),
);
class _HomePageState extends State<HomePage> {
List todos = [];
List<TextEditingController> _titleController = [];
List<TextEditingController> _detailController = [];
#override
void initState() {
super.initState();
todos.add('');
_titleController.add(TextEditingController());
_detailController.add(TextEditingController());
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(
horizontal: 24.0,
),
color: const Color(0xfff6f6f6f6),
child: Stack(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
margin: const EdgeInsets.only(bottom: 32.0, top: 32.0),
child: const Text(
"Reminders",
style: TextStyle(
fontSize: 25.0, fontWeight: FontWeight.bold),
),
),
Expanded(
child: ListView.builder(
itemCount: todos.length,
physics: const BouncingScrollPhysics(),
itemBuilder: (BuildContext context, int index) {
return Stack(
clipBehavior: Clip.hardEdge,
children: [
Padding(
padding: const EdgeInsets.only(top:10.0,left: 8.0, right: 8.0),
child: buildActionSwipeLeft(),
),
Dismissible(
onDismissed: (direction) {
setState(() {
todos.removeAt(index);
_titleController.removeAt(index);
_detailController.removeAt(index);
DismissDirection.startToEnd;
});
},
direction: DismissDirection.startToEnd,
key: UniqueKey(),
child: Padding(
padding: const EdgeInsets.only(bottom: 15.0),
child: Card(
color: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
elevation: 4,
child: Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(
vertical: 15.0, horizontal: 24.0),
margin: const EdgeInsets.only(
bottom: 20.0,
),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
TextField(
cursorColor: Colors.black,
controller: _titleController[index],
style: const TextStyle(
fontSize: 22.0,
fontWeight: FontWeight.bold),
decoration: const InputDecoration(
hintText: "Enter a title",
border: InputBorder.none,
),
),
const Divider(
color: Colors.black,
),
Padding(
padding:
const EdgeInsets.only(top: 0.0),
child: TextField(
controller:
_detailController[index],
style: TextStyle(
fontSize: 20.0,
color: Colors.grey[900],
),
cursorColor: Colors.black,
maxLines: null,
decoration: const InputDecoration(
hintText:
"Enter the description",
label: Text("description"),
border: InputBorder.none),
),
),
],
),
),
),
),
)
],
);
},
),
)
],
),
Positioned(
bottom: 24.0,
right: 0.0,
child: GestureDetector(
onTap: () {
setState(() {
todos.add('');
_titleController.add(TextEditingController());
_detailController.add(TextEditingController());
});
},
child: Container(
width: 60.0,
height: 60.0,
decoration: BoxDecoration(
color: Colors.black87,
borderRadius: BorderRadius.circular(20.0),
),
child:
const Icon(Icons.add, color: Colors.white, size: 35.0),
),
),
)
],
),
),
),
);
}
}
Widget buildActionSwipeLeft() => Container(
height: 180,
alignment: Alignment.centerLeft,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0),
color: Colors.red,
),
padding: const EdgeInsets.only(left: 30),
child: const Icon(Icons.delete, color: Colors.white, size: 30),
);
Achieving this has a disadvantage of loosing a few animation. Will research more:
I am running into issues pushing down the listview out of view of the draggablescrollablesheet (sheet) while still being able to scroll the sheet. So in simpler words I do not want the blue container to show up when the sheet is at the bottom.
I have tried to edit the height of the listview container and that makes it go offscreen therefore unscrollable.
I have also tried wrapping the sheet in a singlechildscrollview with no luck. I am trying to avoid using a button at all possible costs!
import 'package:flutter/material.dart';
import 'package:photosgroup2/chat/message_model.dart';
import 'package:photosgroup2/chat/user_model.dart';
class FeedTest extends StatefulWidget {
FeedTest({Key key}) : super(key: key);
#override
_FeedTest createState() => _FeedTest();
}
class _FeedTest extends State<FeedTest> {
_buildMessage(
Message message,
User user,
) {
//Reply reply){
String time= message.time;
return Container(
// color: Colors.yellow,
child: Padding(
padding: EdgeInsets.only(left: 0), //5
child: Column(
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(left: 5 ,top: 3.5), //10
child: new CircleAvatar(
radius: (17.5),
backgroundImage: AssetImage(
user.profilePic,
),
),
),
SizedBox(
width: 5,
),
Container(
//width: MediaQuery.of(context).size.width,
// width: 300,
child: Material(
color:Color(0x00000000) , //TRANSPARENT
//color: const Color(0xf2ffffff),
///Color(0xe6ffffff) // ! REVISIT Change color of boxes???
/*borderRadius: BorderRadius.only(
topRight: Radius.circular(16.0),
bottomRight: Radius.circular(16.0),
bottomLeft: Radius.circular(16.0),
),*/
child: Padding(
padding: EdgeInsets.only(
left: 10.0), //Revisit
child: Column(
//mainAxisSize: MainAxisSize.min,
mainAxisSize: MainAxisSize.min,
//crossAxis
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 5,
),
Text(
user.name,
style: TextStyle(
fontFamily: 'Lato-Bold',
fontSize: 13 ,
color: const Color(0xd9343f4b),
),
textAlign: TextAlign.left,
),
SizedBox(width: 8),
Padding(
padding: const EdgeInsets.only(left:8.0),
child: Text(
'$time hours ago',
style: TextStyle(
fontFamily: 'Lato',
fontSize: 12 ,
color: const Color(0xff5a6978),
),
textAlign: TextAlign.left,
),
),
SizedBox(
height: 5,
),
//SizedBox(height: 10,),//if(message.imageUrl!='') {
//hasReplies(message, user, reply)
//},
//}
],
),
),
),
),
],
),
SizedBox(height:5),
Container(
//color:Colors.blue,
//: EdgeInsets.only(right:10
//right: 10 * SizeConfig.widthRatio,
//),
child: Container(
//color: Colors.green,
margin: EdgeInsets.only(left:5,right:15),
child: Text(
message.text,
style: TextStyle(
fontFamily: 'Lato',
fontSize: 13 ,
color: const Color(0xff5a6978),
height: 1.5384615384615385
),
textAlign: TextAlign.left,
),
),
),
SizedBox(//color:Colors.amber,
height:15),
Transform.translate(
offset: Offset(-6,0),
child: Container(
width: 350.0,
height: 0.5,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(1.0),
color: const Color(0x40343f4b),
),
),
),
SizedBox(//color:Colors.amber,
height:5),
],
),
),
);
}
#override
Widget build(BuildContext context) {
// visibility of reply button in top right corner
return Scaffold(
backgroundColor: const Color(0xfffafafa),
body: SafeArea(
bottom: false,
top: false,
child: //Column(
//mainAxisAlignment: MainAxisAlignment.spaceAround,
//children: <Widget>[
Stack(
children: <Widget>[
DraggableScrollableSheet(
initialChildSize: 0.068,
minChildSize: 0.068,
maxChildSize: 0.71,
builder: (context, scrollController) {
return Container(
//padding: EdgeInsets.symmetric(horizontal: 20),
child: Stack(
children: [
Padding(
padding: const EdgeInsets.only(top: 20.0),
child: ClipRRect(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(32),
topRight: Radius.circular(32),
),
child: Container(
width: 375, //screen width
height: 812 * 0.71, //screen height *
color: Color(0xffdfdfdf),
),
),
),
Stack(
children: [
Padding(
padding: const EdgeInsets.only(left: 10, top: 20.0),
child: ClipRRect(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(27.5),
topRight: Radius.circular(27.5),
),
child: Container(
//margin: EdgeInsets.only(),
width:340,
//height: 515,
color: Colors.yellow,
child: ClipRRect(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(27.5),
topRight: Radius.circular(27.5),),
child: Container(
// padding: EdgeInsets.only(top:40),
color: Colors.blue,
child: ListView.builder(
//reverse: true,
controller: scrollController,
itemCount: comments.length,
itemBuilder: (BuildContext context, int index) {
final User messenger = comments[index].sender;
final Message message = comments[index];
//final Reply reply = replies[index];
return Column(children: <Widget>[
_buildMessage(
message,
messenger,
), //reply),
SizedBox(
height: 8,
) // !COME BACK TO SPACE BETWEEN
]);
},
),
),
),
),),
),
],
),
Stack(
children: <Widget>[
//67
Padding(
padding: EdgeInsets.only(left: 141, top: 6),
child: SizedBox(
width: 93.0,
height: 29.0,
child: Stack(
children: <Widget>[
SizedBox(
width: 93.0,
height: 29.0,
child: Stack(
children: <Widget>[
// Adobe XD layer: 'Rectangle' (shape)
Container(
width: 93,
height: 29.0,
child: Padding(
padding: EdgeInsets.only(
left: 1, top: 6),
child: Text(
'Place Holder',
style: TextStyle(
fontFamily: 'Lato',
fontSize: 12,
color: const Color(0xffffffff),
),
textAlign: TextAlign.center,
),
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(27.5),
color: const Color(0xf2343f4b),
),
),
],
),
),
],
),
),
),
],
),
],
),
);
},
),
],
),
// ],
//),
),
);
}
}
Can you help me to implement the scroll View inside the Stack After the keyboard has rendered for the TextField
I have put more textFields inside the column widget,But when the keyboard has been rendered it is covering the text Field so how to put the screen under scrolling after keyboard has rendered
As this is stack singleChildScrollView is not funtioning
Widget build(BuildContext context) {
return SafeArea(
child:Stack(children: <Widget>[
Align(
alignment: Alignment.topCenter,
child: Container(
child: Padding(
padding: EdgeInsets.only(top: 20.0),
child: Center(
child: Image.asset(
"img/xyzlogo.jpg",
width: Short.w * 0.4,
),
),
),
width: Short.w,
height: MediaQuery.of(context).size.height * 0.20,
color: Colors.blue[800],
),
),
Align(
alignment: Alignment.bottomLeft,
child: Container(
height: Short.h * 0.82,
width: Short.w,
color: Colors.white,
child:new LayoutBuilder(
builder:
(BuildContext contex, BoxConstraints viewportConstraints) {
return SingleChildScrollView(
child: ConstrainedBox(
constraints:
BoxConstraints(
maxHeight: viewportConstraints.maxHeight,
// minHeight:viewportConstraints.minHeight
),
child: Column(children: [Form(
key: _formKey,
child: Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Flexible(
child: Padding(
padding: EdgeInsets.only(
top: 18,left: Short.w * 0.03,
),
child: Material(
shape: Border(
left: BorderSide(
width: 5.0, color: Colors.blue[800]),
bottom: BorderSide(
width: 1.8, color: Colors.blue[800]),
),
color: Colors.white,
child: Padding(
padding: EdgeInsets.only(left: 9.0),
child: TextFormField(
decoration: InputDecoration(
labelStyle: TextStyle(
color: Colors.grey,
fontSize: Short.h * 0.02),
labelText: ' Email/Phone',
hintText: " Enter your email /Phone",
hintStyle: TextStyle(
color: Colors.grey,
fontSize: Short.h * 0.02),
// border: OutlineInputBorder(
// borderRadius: BorderRadius.circular(
// Short.h * 2.5)),
),
controller: email,
keyboardType:
TextInputType.emailAddress,
),
),
),
),
),
Flexible(
child: Padding(
padding: EdgeInsets.only(
top: 18,
left: Short.w * 0.03,
right: Short.w * 0.02),
child: Material(
shape: Border(
left: BorderSide(
width: 5.0, color: Colors.blue[800]),
bottom: BorderSide(
width: 1.8, color: Colors.blue[800]),
),
color: Colors.white,
child: Padding(
padding: EdgeInsets.only(left: 9.0),
child: TextFormField(
decoration: InputDecoration(
labelStyle: TextStyle(
color: Colors.grey,
fontSize: Short.h * 0.02),
labelText: ' Password',
hintText: " Enter your Password",
hintStyle: TextStyle(
color: Colors.grey,
fontSize: Short.h * 0.02),
),
controller: pwd,
keyboardType:
TextInputType.visiblePassword,
// validator: pwdValidator,
),
),
),
),
),
],
), ]), ), ); },) ), ),
After rendering the keyboard, you cannot use the SingleChildScrollView widget inside the stack or column because the SinglechildScrollView is used when you have a single box that is entirely visible unlike the rendering of any other widget on it. This can be solved by using the stack widget inside the SingleChildSrollView widget into the scaffold through which the entire stack could be scrolled.
Scaffold(
body: SingleChildScrollView(
child: Stack(children: <Widget>[
Align(
alignment: Alignment.topCenter,
child: Container(
child: Padding(
padding: EdgeInsets.only(top: 20.0),
child: Center(
child: Image.asset(
"img/xyzlogo.jpg",
width: Short.w * 0.4,
),
),
),
width: Short.w,
height: MediaQuery.of(context).size.height * 0.20,
color: Colors.blue[800],
),
),
Align(
alignment: Alignment.bottomLeft,
child: Container(
margin: EdgeInsets.only(top: 150),
height: Short.h * 0.75,
width: Short.w,
color: Colors.white,
child: new Column(children: [
Form(
key: _formKey,
child: Column(
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Flexible(
child: Padding(
padding: EdgeInsets.only(
top: 18,
left: Short.w * 0.03,
),
child: Material(
shape: Border(
left: BorderSide(
width: 5.0, color: Colors.blue[800]),
bottom: BorderSide(
width: 1.8, color: Colors.blue[800]),
),
color: Colors.white,
child: Padding(
padding: EdgeInsets.only(left: 9.0),
child: TextFormField(
decoration: InputDecoration(
labelStyle: TextStyle(
color: Colors.grey,
fontSize: Short.h * 0.02),
labelText: ' Email/Phone',
hintText: " Enter your email /Phone",
hintStyle: TextStyle(
color: Colors.grey,
fontSize: Short.h * 0.02),
),
controller: email,
keyboardType: TextInputType.emailAddress,
),
),
),
),
),
Flexible(
child: Padding(
padding: EdgeInsets.only(
top: 18,
left: Short.w * 0.03,
right: Short.w * 0.02),
child: Material(
shape: Border(
left: BorderSide(
width: 5.0, color: Colors.blue[800]),
bottom: BorderSide(
width: 1.8, color: Colors.blue[800]),
),
color: Colors.white,
child: Padding(
padding: EdgeInsets.only(left: 9.0),
child: TextFormField(
decoration: InputDecoration(
labelStyle: TextStyle(
color: Colors.grey,
fontSize: Short.h * 0.02),
labelText: ' Password',
hintText: " Enter your Password",
hintStyle: TextStyle(
color: Colors.grey,
fontSize: Short.h * 0.02),
),
controller: pwd,
keyboardType: TextInputType.visiblePassword,
),
),
),
),
),
],
),
],
),
),
]),
),
),
]),
),
));
After that, inside the container use margin which provides space outside the border that makes your screen look good.