Flutter screen overflow from bottom and not scrolling - flutter

I have a simple form screen issue is it just sticks and showing overflow on the bottom and not scrolling. I have added SingleChildScrollView but it's not working. Try to remove and added Expanded also Try to give height also cant divided height so give first contact full height but not working.
My code
body: SingleChildScrollView(
child: Container(
height: Height * 1,
child: Column(
children: <Widget>[
Container(
color: kPrimaryColor,
child: Column(
children: [
SizedBox(
height: Status * 1,
),
SizedBox(
height: Height * 0.065,
),
Padding(
padding: const EdgeInsets.only(left: 13, bottom: 13),
child: Align(
alignment: Alignment.centerLeft,
child: Text(
'Create Account',
style: TextStyle(
color: Colors.white,
fontSize: 30,
fontFamily: 'SegoeUI-SemiBold'),
),
),
),
Padding(
padding: const EdgeInsets.only(left: 13),
child: Text(
"Please create an account in order to start using your StalkMe Profile.",
style: TextStyle(
color: Colors.white,
fontSize: 16,
fontFamily: 'SegoeUI'),
),
),
SizedBox(
height: Height * 0.04,
),
],
),
),
Expanded(
child: Container(
color: kPrimaryColor,
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30),
topRight: Radius.circular(30))),
child: Form(
key: _formKey,
child: Column(
children: [
GestureDetector(
onTap: () {
print('Login print');
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => LoginScreen()),
);
},
child: Padding(
padding: const EdgeInsets.only(
top: 17, right: 17, bottom: 17),
child: Align(
alignment: Alignment.centerRight,
child: Text(
'LOGIN',
style: TextStyle(
color: kPrimaryColor,
fontSize: 16,
fontFamily: 'SegoeUI-SemiBold',
),
)),
),
),
Container(
height: 1,
width: double.infinity,
color: Color(0xffE6E6E6),
),
SizedBox(
height: Height * 0.03,
),
Container(
width: Width * 0.9,
child: Align(
alignment: Alignment.centerLeft,
child: Text(
'Name',
style: TextStyle(
color: textGreyColor,
fontSize: 16,
fontFamily: 'SegoeUI'),
),
),
),
Padding(
padding: const EdgeInsets.only(top: 11),
child: Container(
width: Width * 0.9,
child: TextFormField(
controller: userName,
validator: (value) {
if (value!.isEmpty) {
return 'Please enter a name';
}
return null;
},
style: TextStyle(
color: textGreyColor,
fontFamily: 'SegoeUI'),
decoration: new InputDecoration(
enabledBorder: new OutlineInputBorder(
borderSide: const BorderSide(
color: Color(0xffE6E6E6), width: 1),
),
filled: true,
hintStyle: new TextStyle(
color: textGreyColor, fontSize: 15),
hintText: "Enter Name",
fillColor: Colors.white,
focusedBorder: OutlineInputBorder(
borderSide: const BorderSide(
color: Color(0xffE6E6E6), width: 1),
borderRadius: const BorderRadius.all(
const Radius.circular(10.0),
),
),
),
),
),
),
SizedBox(
height: Height * 0.02,
),
Container(
width: Width * 0.9,
child: Align(
alignment: Alignment.centerLeft,
child: Text(
'Email Address',
style: TextStyle(
color: textGreyColor,
fontSize: 16,
fontFamily: 'SegoeUI'),
),
),
),
Padding(
padding: const EdgeInsets.only(top: 11),
child: Container(
width: Width * 0.9,
child: TextFormField(
controller: userEmail,
validator: (value) {
if (value!.isEmpty || !value.contains('#')) {
return 'Please enter a valid email address';
}
return null;
},
style: TextStyle(
color: textGreyColor,
fontFamily: 'SegoeUI'),
decoration: new InputDecoration(
enabledBorder: new OutlineInputBorder(
borderSide: const BorderSide(
color: Color(0xffE6E6E6), width: 1),
),
filled: true,
hintStyle: new TextStyle(
color: textGreyColor, fontSize: 15),
hintText: "Enter Email Address",
fillColor: Colors.white,
focusedBorder: OutlineInputBorder(
borderSide: const BorderSide(
color: Color(0xffE6E6E6), width: 1),
borderRadius: const BorderRadius.all(
const Radius.circular(10.0),
),
),
),
),
),
),
SizedBox(
height: Height * 0.02,
),
Container(
width: Width * 0.9,
child: Align(
alignment: Alignment.centerLeft,
child: Text(
'Password',
style: TextStyle(
color: textGreyColor,
fontSize: 16,
fontFamily: 'SegoeUI'),
),
),
),
Padding(
padding: const EdgeInsets.only(top: 11),
child: Container(
width: Width * 0.9,
child: TextFormField(
controller: userPassword,
validator: (value) {
if (value!.isEmpty || value.length < 6) {
return 'Please enter a 6 digit password';
}
return null;
},
obscureText: true,
key: ValueKey('name'),
style: TextStyle(
color: textGreyColor,
fontFamily: 'SegoeUI'),
decoration: new InputDecoration(
enabledBorder: new OutlineInputBorder(
borderSide: const BorderSide(
color: Color(0xffE6E6E6), width: 1),
),
filled: true,
hintStyle: new TextStyle(
color: textGreyColor, fontSize: 15),
hintText: "Enter Password",
fillColor: Colors.white,
focusedBorder: OutlineInputBorder(
borderSide: const BorderSide(
color: Color(0xffE6E6E6), width: 1),
borderRadius: const BorderRadius.all(
const Radius.circular(10.0),
),
),
),
),
),
),
SizedBox(
height: Height * 0.02,
),
Spacer(),
GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: Container(
width: Width * 0.9,
height: Height * 0.06,
decoration: BoxDecoration(
color: Color(0xffebf7f7),
borderRadius: BorderRadius.circular(5)),
child: Center(
child: Text(
'GO BACK',
style: TextStyle(
color: kPrimaryColor,
fontSize: 16,
fontFamily: 'SegoeUI'),
),
),
),
),
GestureDetector(
child: Padding(
padding:
const EdgeInsets.only(top: 8, bottom: 18),
child: Container(
width: Width * 0.9,
height: Height * 0.06,
decoration: BoxDecoration(
color: kPrimaryColor,
borderRadius: BorderRadius.circular(5)),
child: Center(
child: Text(
'CREATE ACCOUNT',
style: TextStyle(
color: Colors.white,
fontSize: 16,
fontFamily: 'SegoeUI'),
),
),
),
),
),
],
),
),
),
),
),
],
),
),
),

There are few things wrong with the code.
Using a Container for spacing is heavy. Use SizedBox with height instead.
Don't limit the height of SingleChildScrollView, when you want infinite height.
Since the Expanded widget takes up infinite space available, wrapping a widget in it will make that widget take up an infinite size, which Flutter will not allow. So, avoid using any flex widget inside scroll views.
Spacer is an expanded widget. This implies it follows point 3.
There are few code styling tips:
Use the const keyword with a constant constructor wherever possible.
Variables in Flutter follow the camelCase convention.
Here's the code I edited and it worked. I have changed some variables and properties to reproduce the working code.
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: MyWidget(),
),
);
}
}
class MyWidget extends StatelessWidget {
final _formKey = GlobalKey();
final textGreyColor = Colors.grey;
final kPrimaryColor = Colors.teal;
final userName = TextEditingController();
final userEmail = TextEditingController();
final userPassword = TextEditingController();
#override
Widget build(BuildContext context) {
// not optimal, but will do
var height = MediaQuery.of(context).size.height;
var width = MediaQuery.of(context).size.width;
var status = height / 10;
return SingleChildScrollView(
// sized box nullifies the usage of scroll view
child: Column(
children: <Widget>[
Container(
color: kPrimaryColor,
child: Column(
children: [
SizedBox(
height: status * 1,
),
SizedBox(
height: height * 0.065,
),
const Padding(
padding: EdgeInsets.only(left: 13, bottom: 13),
child: Align(
alignment: Alignment.centerLeft,
child: Text(
'Create Account',
style: TextStyle(
color: Colors.white,
fontSize: 30,
fontFamily: 'SegoeUI-SemiBold'),
),
),
),
const Padding(
padding: EdgeInsets.only(left: 13),
child: Text(
"Please create an account in order to start using your StalkMe Profile.",
style: TextStyle(
color: Colors.white,
fontSize: 16,
fontFamily: 'SegoeUI'),
),
),
SizedBox(
height: height * 0.04,
),
],
),
),
// don's use Expanded in scrollable views
Container(
color: kPrimaryColor,
child: Container(
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30),
topRight: Radius.circular(30))),
child: Form(
key: _formKey,
child: Column(
children: [
GestureDetector(
onTap: () {
print('Login print');
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => LoginScreen()),
// );
},
child: Padding(
padding: const EdgeInsets.only(
top: 17, right: 17, bottom: 17),
child: Align(
alignment: Alignment.centerRight,
child: Text(
'LOGIN',
style: TextStyle(
color: kPrimaryColor,
fontSize: 16,
fontFamily: 'SegoeUI-SemiBold',
),
)),
),
),
Container(
height: 1,
width: double.infinity,
color: const Color(0xffE6E6E6),
),
SizedBox(
height: height * 0.03,
),
SizedBox(
width: width * 0.9,
child: Align(
alignment: Alignment.centerLeft,
child: Text(
'Name',
style: TextStyle(
color: textGreyColor,
fontSize: 16,
fontFamily: 'SegoeUI'),
),
),
),
Padding(
padding: const EdgeInsets.only(top: 11),
child: SizedBox(
width: width * 0.9,
child: TextFormField(
controller: userName,
validator: (value) {
if (value!.isEmpty) {
return 'Please enter a name';
}
return null;
},
style: TextStyle(
color: textGreyColor, fontFamily: 'SegoeUI'),
decoration: InputDecoration(
enabledBorder: const OutlineInputBorder(
borderSide: BorderSide(
color: Color(0xffE6E6E6), width: 1),
),
filled: true,
hintStyle:
TextStyle(color: textGreyColor, fontSize: 15),
hintText: "Enter Name",
fillColor: Colors.white,
focusedBorder: const OutlineInputBorder(
borderSide: BorderSide(
color: Color(0xffE6E6E6), width: 1),
borderRadius: BorderRadius.all(
Radius.circular(10.0),
),
),
),
),
),
),
SizedBox(
height: height * 0.02,
),
SizedBox(
width: width * 0.9,
child: Align(
alignment: Alignment.centerLeft,
child: Text(
'Email Address',
style: TextStyle(
color: textGreyColor,
fontSize: 16,
fontFamily: 'SegoeUI'),
),
),
),
Padding(
padding: const EdgeInsets.only(top: 11),
child: SizedBox(
width: width * 0.9,
child: TextFormField(
controller: userEmail,
validator: (value) {
if (value!.isEmpty || !value.contains('#')) {
return 'Please enter a valid email address';
}
return null;
},
style: TextStyle(
color: textGreyColor, fontFamily: 'SegoeUI'),
decoration: InputDecoration(
enabledBorder: const OutlineInputBorder(
borderSide: BorderSide(
color: Color(0xffE6E6E6), width: 1),
),
filled: true,
hintStyle:
TextStyle(color: textGreyColor, fontSize: 15),
hintText: "Enter Email Address",
fillColor: Colors.white,
focusedBorder: const OutlineInputBorder(
borderSide: BorderSide(
color: Color(0xffE6E6E6), width: 1),
borderRadius: BorderRadius.all(
Radius.circular(10.0),
),
),
),
),
),
),
SizedBox(
height: height * 0.02,
),
SizedBox(
width: width * 0.9,
child: Align(
alignment: Alignment.centerLeft,
child: Text(
'Password',
style: TextStyle(
color: textGreyColor,
fontSize: 16,
fontFamily: 'SegoeUI'),
),
),
),
Padding(
padding: const EdgeInsets.only(top: 11),
child: SizedBox(
width: width * 0.9,
child: TextFormField(
controller: userPassword,
validator: (value) {
if (value!.isEmpty || value.length < 6) {
return 'Please enter a 6 digit password';
}
return null;
},
obscureText: true,
key: const ValueKey('name'),
style: TextStyle(
color: textGreyColor, fontFamily: 'SegoeUI'),
decoration: InputDecoration(
enabledBorder: const OutlineInputBorder(
borderSide: BorderSide(
color: Color(0xffE6E6E6), width: 1),
),
filled: true,
hintStyle:
TextStyle(color: textGreyColor, fontSize: 15),
hintText: "Enter Password",
fillColor: Colors.white,
focusedBorder: const OutlineInputBorder(
borderSide: BorderSide(
color: Color(0xffE6E6E6), width: 1),
borderRadius: BorderRadius.all(
Radius.circular(10.0),
),
),
),
),
),
),
SizedBox(
height: height * 0.02,
),
// const Spacer(), // --> this is an expanded widget
GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: Container(
width: width * 0.9,
height: height * 0.06,
decoration: BoxDecoration(
color: const Color(0xffebf7f7),
borderRadius: BorderRadius.circular(5)),
child: Center(
child: Text(
'GO BACK',
style: TextStyle(
color: kPrimaryColor,
fontSize: 16,
fontFamily: 'SegoeUI'),
),
),
),
),
GestureDetector(
child: Padding(
padding: const EdgeInsets.only(top: 8, bottom: 18),
child: Container(
width: width * 0.9,
height: height * 0.06,
decoration: BoxDecoration(
color: kPrimaryColor,
borderRadius: BorderRadius.circular(5)),
child: const Center(
child: Text(
'CREATE ACCOUNT',
style: TextStyle(
color: Colors.white,
fontSize: 16,
fontFamily: 'SegoeUI'),
),
),
),
),
),
],
),
),
),
),
],
),
);
}
}

body: SingleChildScrollView(
child: Container(
height: Height * 1,
I think height wents wrong
because
double Height = 500.0;
double Width = 300.0;
final kPrimaryColor = Colors.blue;
return MaterialApp(
home: Scaffold(
body: SingleChildScrollView(
child: Container(
height: Height * 1.3,
It's working
But I know this is not a proper answer but you have to work in height. and keep move your project

Related

Border around DropdownMenu

I want to give border to DropdownButton and DropdownMenu like below image along with height itemHeight of 21px and some background color to DropdownMenuItem on mouse hover and on keyboard up or down keys:
Here is what I have tried till now:
var genderList = [
'Female',
'Male',
'Other',
];
String? selection;
final border = const OutlineInputBorder(
borderSide: BorderSide(
width: 1,
color: Color(0xFF00AFEF),
),
borderRadius: BorderRadius.all(Radius.circular(7)),
);
...
SizedBox(
height: 38.h,
// color: Colors.blue,
child: InputDecorator(
decoration: InputDecoration(
contentPadding: EdgeInsets.zero,
border: border,
enabledBorder: border,
),
child: DropdownButtonHideUnderline(
child: DropdownButton(
isExpanded: true,
hint: Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 13.w),
child: const Text(
'Gender',
style: TextStyle(
fontSize: 14,
color: Color(0xFF606060),
),
),
),
),
value: selection,
icon: Container(
margin: EdgeInsets.symmetric(horizontal: 13.w),
height: 10.r,
width: 16.r,
alignment: Alignment.center,
child: SvgPicture.asset(
AppIcons.arrowDown,
),
),
onChanged: (String? val) {
setState(() => selection = val);
},
items: genderList.map((option) {
return DropdownMenuItem(
value: option,
child: Container(
width: double.infinity,
height: 21.h,
alignment: Alignment.center,
decoration: BoxDecoration(
color: Color(0xFFCBF1FF),
border: Border.all(
color: Color(0xFF00AFEF), width: 1)),
child: Text(
option,
style: TextStyle(
fontSize: 12,
color: Color(0xFF606060),
),
),
),
);
}).toList(),
selectedItemBuilder: (con) {
return genderList.map((val) {
return Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: EdgeInsets.only(left: 13.w),
child: Text(
val,
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 14,
color: Color(0xFF606060),
),
),
),
);
}).toList();
},
),
),
),
);
What I got,
DropDownButton:
DropdownMenu:
How can I get the desired design?
I was able to get the desired result using dropdown_button2
You can use dropdownXXXX parameters for editing related dropdown menu properties.
Only issue I find is that when giving dropdown menu border some radius its covered by selectedItemHighlightColor. So I have used some padding to overcome it.
SizedBox(
height: 38,
child: InputDecorator(
decoration: InputDecoration(
contentPadding: EdgeInsets.zero,
border: border,
enabledBorder: border,
),
child: DropdownButtonHideUnderline(
child: DropdownButton2(
selectedItemHighlightColor: AppColors.lightBackground,
itemHighlightColor: AppColors.lightBackground,
dropdownDecoration: BoxDecoration(
border: Border.all(
color: AppColors.primary,
width: 1,
),
borderRadius: BorderRadius.circular(4),
),
dropdownElevation: 0,
dropdownPadding: const EdgeInsets.symmetric(
horizontal: 1.5,
vertical: 1.5,
),
itemPadding: EdgeInsets.zero,
customItemsHeights: [21, 21, 21],
isExpanded: true,
hint: const Padding(
padding: EdgeInsets.symmetric(horizontal: 14),
child: Text(
'Gender',
style: TextStyle(
fontSize: 14,
color: AppColors.secondaryText,
),
),
),
value: widget.value,
icon: Container(
margin: const EdgeInsets.symmetric(horizontal: 14),
height: 10,
width: 16,
alignment: Alignment.center,
child: SvgPicture.asset(
AppIcons.arrowDown,
),
),
onChanged: widget.onChanged,
items: widget.list.map((option) {
return DropdownMenuItem(
value: option,
child: Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(horizontal: 14),
child: Text(
option,
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
color: AppColors.secondaryText,
),
),
),
);
}).toList(),
selectedItemBuilder: (con) {
return widget.list.map((val) {
return Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: const EdgeInsets.only(left: 14),
child: Text(
val,
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 14,
color: AppColors.secondaryText,
),
),
),
);
}).toList();
},
),
),
),
);

How to Place Text Widget at the Bottom of Flutter Page?

I have an application like this:
I want to place a Text widget at the bottom of the page. How can I do that?
Codes:
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:teen_browser/pages/LoginAndRegister/LoginPage.dart';
import 'package:teen_browser/pages/LoginAndRegister/RegisterPage.dart';
class RegisterPage extends StatelessWidget {
const RegisterPage({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color.fromARGB(255, 25, 25, 25),
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: MediaQuery.of(context).size.height * 0.05,
),
Center(
child: Image.asset("assets/Logo.png", height: MediaQuery.of(context).size.height * 0.1),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.07,
),
const Padding(
padding: EdgeInsets.only(left: 15),
child: Text("Ad:", style: TextStyle(fontSize: 20, color: Colors.white)),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.01,
),
Padding(
padding: EdgeInsets.only(left: 15, right: 15),
child: TextFormField(
style: const TextStyle(color: Colors.white, fontSize: 18, fontFamily: "Montserrat"),
decoration: InputDecoration(
prefixIcon: const Icon(Icons.person),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
),
filled: true,
hintStyle: TextStyle(color: Colors.grey[600], fontFamily: "Montserrat"),
hintText: "Ad",
fillColor: Color.fromARGB(179, 55, 55, 55)
),
),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.02,
),
const Padding(
padding: EdgeInsets.only(left: 15),
child: Text("Soyad:", style: TextStyle(fontSize: 20, color: Colors.white)),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.01,
),
Padding(
padding: EdgeInsets.only(left: 15, right: 15),
child: TextFormField(
style: const TextStyle(color: Colors.white, fontSize: 18, fontFamily: "Montserrat"),
decoration: InputDecoration(
prefixIcon: const Icon(Icons.person),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
),
filled: true,
hintStyle: TextStyle(color: Colors.grey[600], fontFamily: "Montserrat"),
hintText: "Soyad",
fillColor: Color.fromARGB(179, 55, 55, 55)
),
),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.02,
),
const Padding(
padding: EdgeInsets.only(left: 15),
child: Text("E-Posta:", style: TextStyle(fontSize: 20, color: Colors.white)),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.01,
),
Padding(
padding: EdgeInsets.only(left: 15, right: 15),
child: TextFormField(
style: const TextStyle(color: Colors.white, fontSize: 18, fontFamily: "Montserrat"),
decoration: InputDecoration(
prefixIcon: const Icon(Icons.mail),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
),
filled: true,
hintStyle: TextStyle(color: Colors.grey[600], fontFamily: "Montserrat"),
hintText: "E-Posta",
fillColor: const Color.fromARGB(179, 55, 55, 55)
),
),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.02,
),
const Padding(
padding: EdgeInsets.only(left: 15),
child: Text("Parola:", style: TextStyle(fontSize: 20, color: Colors.white)),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.01,
),
Padding(
padding: const EdgeInsets.only(left: 15, right: 15),
child: TextFormField(
style: const TextStyle(color: Colors.white, fontSize: 18, fontFamily: "Montserrat"),
decoration: InputDecoration(
prefixIcon: const Icon(Icons.lock),
prefixIconColor: const Color.fromARGB(255, 162, 162, 162),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
),
filled: true,
hintStyle: TextStyle(color: Colors.grey[600], fontFamily: "Montserrat"),
prefixStyle: TextStyle(color: Colors.grey[600]),
hintText: "Parola",
fillColor: const Color.fromARGB(179, 55, 55, 55)
),
),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.03,
),
Padding(
padding: const EdgeInsets.only(left: 15, right: 15),
child: Center(
child: Container(
width: MediaQuery.of(context).size.width * 0.8,
height: MediaQuery.of(context).size.height * 0.05,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: const Color.fromARGB(255, 47, 47, 47),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16), // <-- Radius
),
),
child: const Text("Hesap Oluştur", style: TextStyle(color: Colors.white, fontSize: 20, fontFamily: "Montserrat")),
onPressed: () {},
),
),
),
),
],
),
),
);
}
}
I tried with code like this:
Align(
alignment: Alignment.bottomCenter,
child: Text("Test"),
),
But this code didn't work. He settled into the regular Column row. It's not at the bottom of the page.
Thanks for help.
Using another column with MainAxisAlignment.spaceBetween, works, also you can replace MediaQuery size with `LayoutBuilder.
class RegisterPage extends StatelessWidget {
const RegisterPage({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color.fromARGB(255, 25, 25, 25),
body: LayoutBuilder(
builder: (context, constraints) => SingleChildScrollView(
child: SizedBox(
height: constraints.maxHeight,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: MediaQuery.of(context).size.height * 0.05,
),
Center(
child: Image.asset("assets/Logo.png",
height: MediaQuery.of(context).size.height * 0.1),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.07,
),
const Padding(
padding: EdgeInsets.only(left: 15),
child: Text("Ad:",
style: TextStyle(fontSize: 20, color: Colors.white)),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.01,
),
Padding(
padding: EdgeInsets.only(left: 15, right: 15),
child: TextFormField(
style: const TextStyle(
color: Colors.white,
fontSize: 18,
fontFamily: "Montserrat"),
decoration: InputDecoration(
prefixIcon: const Icon(Icons.person),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
),
filled: true,
hintStyle: TextStyle(
color: Colors.grey[600],
fontFamily: "Montserrat"),
hintText: "Ad",
fillColor: Color.fromARGB(179, 55, 55, 55)),
),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.02,
),
const Padding(
padding: EdgeInsets.only(left: 15),
child: Text("Soyad:",
style: TextStyle(fontSize: 20, color: Colors.white)),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.01,
),
Padding(
padding: EdgeInsets.only(left: 15, right: 15),
child: TextFormField(
style: const TextStyle(
color: Colors.white,
fontSize: 18,
fontFamily: "Montserrat"),
decoration: InputDecoration(
prefixIcon: const Icon(Icons.person),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
),
filled: true,
hintStyle: TextStyle(
color: Colors.grey[600],
fontFamily: "Montserrat"),
hintText: "Soyad",
fillColor: Color.fromARGB(179, 55, 55, 55)),
),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.02,
),
const Padding(
padding: EdgeInsets.only(left: 15),
child: Text("E-Posta:",
style: TextStyle(fontSize: 20, color: Colors.white)),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.01,
),
Padding(
padding: EdgeInsets.only(left: 15, right: 15),
child: TextFormField(
style: const TextStyle(
color: Colors.white,
fontSize: 18,
fontFamily: "Montserrat"),
decoration: InputDecoration(
prefixIcon: const Icon(Icons.mail),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
),
filled: true,
hintStyle: TextStyle(
color: Colors.grey[600],
fontFamily: "Montserrat"),
hintText: "E-Posta",
fillColor: const Color.fromARGB(179, 55, 55, 55)),
),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.02,
),
const Padding(
padding: EdgeInsets.only(left: 15),
child: Text("Parola:",
style: TextStyle(fontSize: 20, color: Colors.white)),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.01,
),
Padding(
padding: const EdgeInsets.only(left: 15, right: 15),
child: TextFormField(
style: const TextStyle(
color: Colors.white,
fontSize: 18,
fontFamily: "Montserrat"),
decoration: InputDecoration(
prefixIcon: const Icon(Icons.lock),
prefixIconColor:
const Color.fromARGB(255, 162, 162, 162),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20.0),
),
filled: true,
hintStyle: TextStyle(
color: Colors.grey[600],
fontFamily: "Montserrat"),
prefixStyle: TextStyle(color: Colors.grey[600]),
hintText: "Parola",
fillColor: const Color.fromARGB(179, 55, 55, 55)),
),
),
SizedBox(
height: MediaQuery.of(context).size.height * 0.03,
),
Padding(
padding: const EdgeInsets.only(left: 15, right: 15),
child: Center(
child: Container(
width: MediaQuery.of(context).size.width * 0.8,
height: MediaQuery.of(context).size.height * 0.05,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16), // <-- Radius
),
),
child: const Text("Hesap Oluştur",
style: TextStyle(color: Colors.white, fontSize: 20, fontFamily: "Montserrat")),
onPressed: () {},
),
),
),
),
],
),
Text("dsadas"),
],
),
),
),
),
);
}
}

flutter Error: Two TextField in a single Row Getting Error

I want two TextField in row then I am getting error.When I am using Row
I want two TextField in row then I am getting error.I want two TextField in row then I am getting error.I want two TextField in row then I am getting error.
I want two TextField in row then I am getting error.I want two TextField in row then I am getting error.
This is my code.
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
class EnterDetails extends StatefulWidget {
const EnterDetails({Key? key}) : super(key: key);
#override
_EnterDetailsState createState() => _EnterDetailsState();
}
class _EnterDetailsState extends State<EnterDetails> {
TextEditingController nameController = TextEditingController();
TextEditingController zipCodeController = TextEditingController();
TextEditingController cityController = TextEditingController();
TextEditingController stateController = TextEditingController();
TextEditingController countryController = TextEditingController();
var _formKey = GlobalKey<FormState>();
var CountryList = ["India", "USA", "Africa","England"];
final focus = FocusNode();
#override
void initState() {
_formKey = GlobalKey<FormState>();
super.initState();
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
height: MediaQuery.of(context).size.height,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/bg.png"),
fit: BoxFit.cover,
),
),
width: double.infinity,
child: SafeArea(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 80,
),
Center(
child: Image.asset(
'assets/logo.png',
width: 115,
height: 80,
),
),
SizedBox(
height: 37,
),
Center(
child: Text(
"We are keen to know\nabout you",
style: GoogleFonts.poppins(
fontSize: 26,
fontWeight: FontWeight.w600,
color: Colors.white,
),
textAlign: TextAlign.center,
),
),
Padding(
padding: const EdgeInsets.fromLTRB(36, 0, 36, 0),
child: Form(
key: _formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 43,
),
Padding(
padding: const EdgeInsets.all(1.0),
child: Text(
"Enter Full Name",
style: GoogleFonts.poppins(
fontSize: 14,
color: Colors.white,
),
),
),
SizedBox(
height: 3.7,
),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8)),
child: TextFormField(
controller: nameController,
textAlign: TextAlign.left,
keyboardType: TextInputType.text,
decoration: const InputDecoration(
fillColor: Colors.white,
hintText: 'Enter your Full Name',
hintStyle: TextStyle(fontSize: 16),
border: OutlineInputBorder(
borderRadius:
BorderRadius.all(Radius.circular(8.0)),
borderSide: BorderSide.none,
),
filled: false,
contentPadding: EdgeInsets.all(16),
),
),
),
SizedBox(
height: 16,
),
Padding(
padding: const EdgeInsets.all(1.0),
child: Text(
"Zip Code",
style: GoogleFonts.poppins(
fontSize: 14,
color: Colors.white,
),
),
),
SizedBox(
height: 3.7,
),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8)),
child: TextFormField(
controller: zipCodeController,
obscureText: true,
textAlign: TextAlign.left,
keyboardType: TextInputType.number,
decoration: const InputDecoration(
fillColor: Colors.white,
hintText: 'Enter your Zip Code',
hintStyle: TextStyle(fontSize: 16),
border: OutlineInputBorder(
borderRadius:
BorderRadius.all(Radius.circular(8.0)),
borderSide: BorderSide.none,
),
filled: false,
contentPadding: EdgeInsets.all(16),
),
),
),
SizedBox(
height: 16,
),
Padding(
padding: const EdgeInsets.all(1.0),
child: Text(
"City",
style: GoogleFonts.poppins(
fontSize: 14,
color: Colors.white,
),
),
),
SizedBox(
height: 3.7,
),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8)),
child: TextFormField(
controller: cityController,
textAlign: TextAlign.left,
keyboardType: TextInputType.text,
decoration: const InputDecoration(
fillColor: Colors.white,
hintText: 'Enter your city',
hintStyle: TextStyle(fontSize: 16),
border: OutlineInputBorder(
borderRadius:
BorderRadius.all(Radius.circular(8.0)),
borderSide: BorderSide.none,
),
filled: false,
contentPadding: EdgeInsets.all(16),
),
),
),
SizedBox(
height: 16,
),
Padding(
padding: const EdgeInsets.all(1.0),
child: Text(
"State",
style: GoogleFonts.poppins(
fontSize: 14,
color: Colors.white,
),
),
),
SizedBox(
height: 3.7,
),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8)),
child: TextFormField(
controller: cityController,
textAlign: TextAlign.left,
keyboardType: TextInputType.text,
decoration: const InputDecoration(
fillColor: Colors.white,
hintText: 'Enter your state',
hintStyle: TextStyle(fontSize: 16),
border: OutlineInputBorder(
borderRadius:
BorderRadius.all(Radius.circular(8.0)),
borderSide: BorderSide.none,
),
filled: false,
contentPadding: EdgeInsets.all(16),
),
),
),
SizedBox(
height: 16,
),
Padding(
padding: const EdgeInsets.all(1.0),
child: Text(
"Country",
style: GoogleFonts.poppins(
fontSize: 14,
color: Colors.white,
),
),
),
SizedBox(
height: 3.7,
),
Container(
height: 50,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8)
),
child: Padding(
padding: const EdgeInsets.only(left: 16.0, right: 8,top: 2),
child: Stack(
children: [
TextFormField(
cursorColor: Colors.white,
controller: countryController,
enabled: true,
validator: (value) {
if (value!.length != 0) {
return null;
}
return "please select country";
},
decoration: const InputDecoration(
suffixIcon: Icon(Icons.keyboard_arrow_down),
hintText: 'Country',
hintStyle: TextStyle(fontSize: 16),
border: UnderlineInputBorder(borderSide: BorderSide.none)),
style: TextStyle(
fontSize: 16,
color: Colors.grey[900],),
),
Container(
color: Colors.transparent,
width: MediaQuery.of(context).size.width,
child: PopupMenuButton<String>(
icon: const Icon(
Icons.arrow_drop_down,
color: Colors.transparent,
),
onSelected: (String value) {
setState(() {
countryController.text = value;
});
},
itemBuilder: (BuildContext context) {
return CountryList
.map<PopupMenuItem<String>>((String value) {
FocusScope.of(context).unfocus();
return new PopupMenuItem(
child: Container(
width: MediaQuery.of(context).size.width,
child: new Text(value)),
value: value);
}).toList();
},
),
)
],
),
),
),
SizedBox(height: 16,),
SizedBox(
height: 48,
width: double.infinity,
child: ElevatedButton(
style: ButtonStyle(
elevation: MaterialStateProperty.all(0),
foregroundColor:
MaterialStateProperty.all<Color>(Colors.white),
backgroundColor: MaterialStateProperty.all<Color>(
Color(0xFFF2A6A4)),
shape: MaterialStateProperty.all<
RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
side: BorderSide(color: Color(0xFFF2A6A4)),
),
),
),
onPressed: () {
},
child: Text(
'Sign Up',
style: GoogleFonts.poppins(
fontSize: 14, color: Colors.white),
),
),
),
SizedBox(
height: 42,
),
],
),
),
),
],
),
),
),
),
bottomNavigationBar: Container(
color: Color(0xff3a99a4),
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(topLeft: Radius.circular(60))),
width: double.infinity,
height: 57,
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Already have an account? ',
style: GoogleFonts.poppins(fontSize: 14, color: Colors.black),
),
GestureDetector(
onTap: () {
// Navigator.pushReplacement(
// context,
// MaterialPageRoute(
// builder: (context) => LoginPage(),
// ),
// );
},
child: Text(
"Let's Go",
style: GoogleFonts.poppins(
fontSize: 14, color: Color(0xFF158998)),
))
],
)),
),
),
);
}
}
In actuall i want to make like this
but it is becoming
To have multiple items in a row you need to use Row() widget inside your Column and after that to get equal width for your inline widgets you need to use Expanded widget inside Row and then you can add another widget as child of Expanded. I have made changes in your code just copy and paste below code and observe the changes for next time.
class EnterDetails extends StatefulWidget {
const EnterDetails({Key? key}) : super(key: key);
#override
_EnterDetailsState createState() => _EnterDetailsState();
}
class _EnterDetailsState extends State<EnterDetails> {
TextEditingController nameController = TextEditingController();
TextEditingController zipCodeController = TextEditingController();
TextEditingController cityController = TextEditingController();
TextEditingController stateController = TextEditingController();
TextEditingController countryController = TextEditingController();
var _formKey = GlobalKey<FormState>();
var CountryList = ["India", "USA", "Africa", "England"];
final focus = FocusNode();
#override
void initState() {
_formKey = GlobalKey<FormState>();
super.initState();
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
height: MediaQuery.of(context).size.height,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/bg.png"),
fit: BoxFit.cover,
),
),
width: double.infinity,
child: SafeArea(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 80,
),
Center(
child: Image.asset(
'assets/logo.png',
width: 115,
height: 80,
),
),
SizedBox(
height: 37,
),
Center(
child: Text(
"We are keen to know\nabout you",
style: GoogleFonts.poppins(
fontSize: 26,
fontWeight: FontWeight.w600,
color: Colors.white,
),
textAlign: TextAlign.center,
),
),
Padding(
padding: const EdgeInsets.fromLTRB(36, 0, 36, 0),
child: Form(
key: _formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 43,
),
Padding(
padding: const EdgeInsets.all(1.0),
child: Text(
"Enter Full Name",
style: GoogleFonts.poppins(
fontSize: 14,
color: Colors.white,
),
),
),
SizedBox(
height: 3.7,
),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8)),
child: TextFormField(
controller: nameController,
textAlign: TextAlign.left,
keyboardType: TextInputType.text,
decoration: const InputDecoration(
fillColor: Colors.white,
hintText: 'Enter your Full Name',
hintStyle: TextStyle(fontSize: 16),
border: OutlineInputBorder(
borderRadius:
BorderRadius.all(Radius.circular(8.0)),
borderSide: BorderSide.none,
),
filled: false,
contentPadding: EdgeInsets.all(16),
),
),
),
SizedBox(
height: 16,
),
Row(
children: [
Expanded(
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(1.0),
child: Text(
"Zip Code",
style: GoogleFonts.poppins(
fontSize: 14,
color: Colors.white,
),
),
),
SizedBox(
height: 3.7,
),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8)),
child: TextFormField(
controller: zipCodeController,
obscureText: true,
textAlign: TextAlign.left,
keyboardType: TextInputType.number,
decoration: const InputDecoration(
fillColor: Colors.white,
hintText: 'Enter your Zip Code',
hintStyle: TextStyle(fontSize: 16),
border: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(8.0)),
borderSide: BorderSide.none,
),
filled: false,
contentPadding: EdgeInsets.all(16),
),
),
),
],
)),
VerticalDivider(),
Expanded(
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(1.0),
child: Text(
"City",
style: GoogleFonts.poppins(
fontSize: 14,
color: Colors.white,
),
),
),
SizedBox(
height: 3.7,
),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8)),
child: TextFormField(
controller: cityController,
textAlign: TextAlign.left,
keyboardType: TextInputType.text,
decoration: const InputDecoration(
fillColor: Colors.white,
hintText: 'Enter your city',
hintStyle: TextStyle(fontSize: 16),
border: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(8.0)),
borderSide: BorderSide.none,
),
filled: false,
contentPadding: EdgeInsets.all(16),
),
),
),
],
))
],
),
SizedBox(
height: 16,
),
Row(
children: [
Expanded(
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(1.0),
child: Text(
"State",
style: GoogleFonts.poppins(
fontSize: 14,
color: Colors.white,
),
),
),
SizedBox(
height: 3.7,
),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8)),
child: TextFormField(
controller: cityController,
textAlign: TextAlign.left,
keyboardType: TextInputType.text,
decoration: const InputDecoration(
fillColor: Colors.white,
hintText: 'Enter your state',
hintStyle: TextStyle(fontSize: 16),
border: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(8.0)),
borderSide: BorderSide.none,
),
filled: false,
contentPadding: EdgeInsets.all(16),
),
),
),
],
)),
VerticalDivider(),
Expanded(
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(1.0),
child: Text(
"Country",
style: GoogleFonts.poppins(
fontSize: 14,
color: Colors.white,
),
),
),
SizedBox(
height: 3.7,
),
Container(
height: 50,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8)),
child: Padding(
padding: const EdgeInsets.only(
left: 16.0, right: 8, top: 2),
child: Stack(
children: [
TextFormField(
cursorColor: Colors.white,
controller: countryController,
enabled: true,
validator: (value) {
if (value!.length != 0) {
return null;
}
return "please select country";
},
decoration: const InputDecoration(
suffixIcon: Icon(
Icons.keyboard_arrow_down),
hintText: 'Country',
hintStyle:
TextStyle(fontSize: 16),
border: UnderlineInputBorder(
borderSide: BorderSide.none)),
style: TextStyle(
fontSize: 16,
color: Colors.grey[900],
),
),
Container(
color: Colors.transparent,
width:
MediaQuery.of(context).size.width,
child: PopupMenuButton<String>(
icon: const Icon(
Icons.arrow_drop_down,
color: Colors.transparent,
),
onSelected: (String value) {
setState(() {
countryController.text = value;
});
},
itemBuilder:
(BuildContext context) {
return CountryList.map<
PopupMenuItem<String>>(
(String value) {
FocusScope.of(context)
.unfocus();
return new PopupMenuItem(
child: Container(
width: MediaQuery.of(
context)
.size
.width,
child: new Text(value)),
value: value);
}).toList();
},
),
)
],
),
),
)
],
)),
],
),
SizedBox(
height: 16,
),
SizedBox(
height: 16,
),
SizedBox(
height: 48,
width: double.infinity,
child: ElevatedButton(
style: ButtonStyle(
elevation: MaterialStateProperty.all(0),
foregroundColor: MaterialStateProperty.all<Color>(
Colors.white),
backgroundColor: MaterialStateProperty.all<Color>(
Color(0xFFF2A6A4)),
shape: MaterialStateProperty.all<
RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
side: BorderSide(color: Color(0xFFF2A6A4)),
),
),
),
onPressed: () {},
child: Text(
'Sign Up',
style: GoogleFonts.poppins(
fontSize: 14, color: Colors.white),
),
),
),
SizedBox(
height: 42,
),
],
),
),
),
],
),
),
),
),
bottomNavigationBar: Container(
color: Color(0xff3a99a4),
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(topLeft: Radius.circular(60))),
width: double.infinity,
height: 57,
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Already have an account? ',
style: GoogleFonts.poppins(fontSize: 14, color: Colors.black),
),
GestureDetector(
onTap: () {
// Navigator.pushReplacement(
// context,
// MaterialPageRoute(
// builder: (context) => LoginPage(),
// ),
// );
},
child: Text(
"Let's Go",
style: GoogleFonts.poppins(
fontSize: 14, color: Color(0xFF158998)),
))
],
)),
),
),
);
}
}
If you want to place widgets next to each other you need to use a Row-Widget. You can place that Row inside your Column.
https://api.flutter.dev/flutter/widgets/Row-class.html
Please Refer Below Code:-
import 'package:flutter/cupertino.dart';
class EnterDetails extends StatefulWidget {
const EnterDetails({Key? key}) : super(key: key);
#override
_EnterDetailsState createState() => _EnterDetailsState();
}
class _EnterDetailsState extends State<EnterDetails> {
TextEditingController nameController = TextEditingController();
TextEditingController zipCodeController = TextEditingController();
TextEditingController cityController = TextEditingController();
TextEditingController stateController = TextEditingController();
TextEditingController countryController = TextEditingController();
var _formKey = GlobalKey<FormState>();
var CountryList = ["India", "USA", "Africa", "England"];
final focus = FocusNode();
#override
void initState() {
_formKey = GlobalKey<FormState>();
super.initState();
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
height: MediaQuery.of(context).size.height,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/bg.png"),
fit: BoxFit.cover,
),
),
width: double.infinity,
child: SafeArea(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 80,
),
Center(
child: Image.asset(
'assets/logo.png',
width: 115,
height: 80,
),
),
SizedBox(
height: 37,
),
Center(
child: Text(
"We are keen to know\nabout you",
style: GoogleFonts.poppins(
fontSize: 26,
fontWeight: FontWeight.w600,
color: Colors.white,
),
textAlign: TextAlign.center,
),
),
Padding(
padding: const EdgeInsets.fromLTRB(36, 0, 36, 0),
child: Form(
key: _formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 43,
),
Padding(
padding: const EdgeInsets.all(1.0),
child: Text(
"Enter Full Name",
style: GoogleFonts.poppins(
fontSize: 14,
color: Colors.white,
),
),
),
SizedBox(
height: 3.7,
),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8)),
child: TextFormField(
controller: nameController,
textAlign: TextAlign.left,
keyboardType: TextInputType.text,
decoration: const InputDecoration(
fillColor: Colors.white,
hintText: 'Enter your Full Name',
hintStyle: TextStyle(fontSize: 16),
border: OutlineInputBorder(
borderRadius:
BorderRadius.all(Radius.circular(8.0)),
borderSide: BorderSide.none,
),
filled: false,
contentPadding: EdgeInsets.all(16),
),
),
),
SizedBox(
height: 16,
),
Row(
children: [
Flexible(
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(1.0),
child: Text(
"Zip Code",
style: GoogleFonts.poppins(
fontSize: 14,
color: Colors.white,
),
),
),
SizedBox(
height: 3.7,
),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8)),
child: TextFormField(
controller: zipCodeController,
obscureText: true,
textAlign: TextAlign.left,
keyboardType: TextInputType.number,
decoration: const InputDecoration(
fillColor: Colors.white,
hintText: 'Enter your Zip Code',
hintStyle: TextStyle(fontSize: 16),
border: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(8.0)),
borderSide: BorderSide.none,
),
filled: false,
contentPadding: EdgeInsets.all(16),
),
),
),
],
)),
SizedBox(width: 10,),
Flexible(
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(1.0),
child: Text(
"City",
style: GoogleFonts.poppins(
fontSize: 14,
color: Colors.white,
),
),
),
SizedBox(
height: 3.7,
),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8)),
child: TextFormField(
controller: cityController,
textAlign: TextAlign.left,
keyboardType: TextInputType.text,
decoration: const InputDecoration(
fillColor: Colors.white,
hintText: 'Enter your city',
hintStyle: TextStyle(fontSize: 16),
border: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(8.0)),
borderSide: BorderSide.none,
),
filled: false,
contentPadding: EdgeInsets.all(16),
),
),
),
],
))
],
),
SizedBox(
height: 16,
),
Row(
children: [
Flexible(
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(1.0),
child: Text(
"State",
style: GoogleFonts.poppins(
fontSize: 14,
color: Colors.white,
),
),
),
SizedBox(
height: 3.7,
),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8)),
child: TextFormField(
controller: cityController,
textAlign: TextAlign.left,
keyboardType: TextInputType.text,
decoration: const InputDecoration(
fillColor: Colors.white,
hintText: 'Enter your state',
hintStyle: TextStyle(fontSize: 16),
border: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(8.0)),
borderSide: BorderSide.none,
),
filled: false,
contentPadding: EdgeInsets.all(16),
),
),
),
],
)),
SizedBox(width: 10,),
Flexible(
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(1.0),
child: Text(
"Country",
style: GoogleFonts.poppins(
fontSize: 14,
color: Colors.white,
),
),
),
SizedBox(
height: 3.7,
),
Container(
height: 50,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8)),
child: Padding(
padding: const EdgeInsets.only(
left: 16.0, right: 8, top: 2),
child: Stack(
children: [
TextFormField(
cursorColor: Colors.white,
controller: countryController,
enabled: true,
validator: (value) {
if (value!.length != 0) {
return null;
}
return "please select country";
},
decoration: const InputDecoration(
suffixIcon: Icon(
Icons.keyboard_arrow_down),
hintText: 'Country',
hintStyle:
TextStyle(fontSize: 16),
border: UnderlineInputBorder(
borderSide: BorderSide.none)),
style: TextStyle(
fontSize: 16,
color: Colors.grey[900],
),
),
Container(
color: Colors.transparent,
width:
MediaQuery.of(context).size.width,
child: PopupMenuButton<String>(
icon: const Icon(
Icons.arrow_drop_down,
color: Colors.transparent,
),
onSelected: (String value) {
setState(() {
countryController.text = value;
});
},
itemBuilder:
(BuildContext context) {
return CountryList.map<
PopupMenuItem<String>>(
(String value) {
FocusScope.of(context)
.unfocus();
return new PopupMenuItem(
child: Container(
width: MediaQuery.of(
context)
.size
.width,
child: new Text(value)),
value: value);
}).toList();
},
),
)
],
),
),
)
],
)),
],
),
SizedBox(
height: 16,
),
SizedBox(
height: 16,
),
SizedBox(
height: 48,
width: double.infinity,
child: ElevatedButton(
style: ButtonStyle(
elevation: MaterialStateProperty.all(0),
foregroundColor: MaterialStateProperty.all<Color>(
Colors.white),
backgroundColor: MaterialStateProperty.all<Color>(
Color(0xFFF2A6A4)),
shape: MaterialStateProperty.all<
RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
side: BorderSide(color: Color(0xFFF2A6A4)),
),
),
),
onPressed: () {},
child: Text(
'Sign Up',
style: GoogleFonts.poppins(
fontSize: 14, color: Colors.white),
),
),
),
SizedBox(
height: 42,
),
],
),
),
),
],
),
),
),
),
bottomNavigationBar: Container(
color: Color(0xff3a99a4),
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(topLeft: Radius.circular(60))),
width: double.infinity,
height: 57,
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Already have an account? ',
style: GoogleFonts.poppins(fontSize: 14, color: Colors.black),
),
GestureDetector(
onTap: () {
// Navigator.pushReplacement(
// context,
// MaterialPageRoute(
// builder: (context) => LoginPage(),
// ),
// );
},
child: Text(
"Let's Go",
style: GoogleFonts.poppins(
fontSize: 14, color: Color(0xFF158998)),
))
],
)),
),
),
);
}
}
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
void main() => runApp(Myapp11());
class Myapp11 extends StatelessWidget {
const Myapp11({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return EnterDetails();
}
}
class EnterDetails extends StatefulWidget {
const EnterDetails({Key? key}) : super(key: key);
#override
_EnterDetailsState createState() => _EnterDetailsState();
}
class _EnterDetailsState extends State<EnterDetails> {
TextEditingController nameController = TextEditingController();
TextEditingController zipCodeController = TextEditingController();
TextEditingController cityController = TextEditingController();
TextEditingController stateController = TextEditingController();
TextEditingController countryController = TextEditingController();
var _formKey = GlobalKey<FormState>();
var CountryList = ["India", "USA", "Africa", "England"];
final focus = FocusNode();
#override
void initState() {
_formKey = GlobalKey<FormState>();
super.initState();
}
#override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.teal,
body: Container(
height: 2222,
//MediaQuery.of(context).size.height,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/bg.png"),
fit: BoxFit.cover,
),
),
width: double.infinity,
child: SafeArea(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 80,
),
Center(
child: Image.asset(
'assets/logo.png',
width: 115,
height: 80,
),
),
SizedBox(
height: 37,
),
Center(
child: Text(
"We are keen to know\nabout you",
style: GoogleFonts.poppins(
fontSize: 26,
fontWeight: FontWeight.w600,
color: Colors.white,
),
textAlign: TextAlign.center,
),
),
Padding(
padding: const EdgeInsets.fromLTRB(36, 0, 36, 0),
child: Form(
key: _formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 43,
),
Padding(
padding: const EdgeInsets.all(1.0),
child: Text(
"Enter Full Name",
style: GoogleFonts.poppins(
fontSize: 14,
color: Colors.white,
),
),
),
SizedBox(
height: 3.7,
),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8)),
child: TextFormField(
controller: nameController,
textAlign: TextAlign.left,
keyboardType: TextInputType.text,
decoration: const InputDecoration(
fillColor: Colors.white,
hintText: 'Enter your Full Name',
hintStyle: TextStyle(fontSize: 16),
border: OutlineInputBorder(
borderRadius:
BorderRadius.all(Radius.circular(8.0)),
borderSide: BorderSide.none,
),
filled: false,
contentPadding: EdgeInsets.all(16),
),
),
),
SizedBox(
height: 16,
),
Padding(
padding: const EdgeInsets.all(1.0),
child: Text(
"Zip Code",
style: GoogleFonts.poppins(
fontSize: 14,
color: Colors.white,
),
),
),
SizedBox(
height: 3.7,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Expanded(
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8)),
child: TextFormField(
controller: zipCodeController,
obscureText: true,
textAlign: TextAlign.left,
keyboardType: TextInputType.number,
decoration: const InputDecoration(
fillColor: Colors.white,
hintText: 'Enter your Zip Code',
hintStyle: TextStyle(fontSize: 16),
border: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(8.0)),
borderSide: BorderSide.none,
),
filled: false,
contentPadding: EdgeInsets.all(16),
),
),
),
),
SizedBox(
width: 22,
),
Expanded(
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8)),
child: TextFormField(
controller: cityController,
textAlign: TextAlign.left,
keyboardType: TextInputType.text,
decoration: const InputDecoration(
fillColor: Colors.white,
hintText: 'Enter your city',
hintStyle: TextStyle(fontSize: 16),
border: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(8.0)),
borderSide: BorderSide.none,
),
filled: false,
contentPadding: EdgeInsets.all(16),
),
),
),
),
],
),
SizedBox(
height: 16,
),
Padding(
padding: const EdgeInsets.all(1.0),
child: Text(
"City",
style: GoogleFonts.poppins(
fontSize: 14,
color: Colors.white,
),
),
),
SizedBox(
height: 3.7,
),
SizedBox(
height: 16,
),
Padding(
padding: const EdgeInsets.all(1.0),
child: Text(
"State",
style: GoogleFonts.poppins(
fontSize: 14,
color: Colors.white,
),
),
),
SizedBox(
height: 3.7,
),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8)),
child: TextFormField(
controller: cityController,
textAlign: TextAlign.left,
keyboardType: TextInputType.text,
decoration: const InputDecoration(
fillColor: Colors.white,
hintText: 'Enter your state',
hintStyle: TextStyle(fontSize: 16),
border: OutlineInputBorder(
borderRadius:
BorderRadius.all(Radius.circular(8.0)),
borderSide: BorderSide.none,
),
filled: false,
contentPadding: EdgeInsets.all(16),
),
),
),
SizedBox(
height: 16,
),
Padding(
padding: const EdgeInsets.all(1.0),
child: Text(
"Country",
style: GoogleFonts.poppins(
fontSize: 14,
color: Colors.white,
),
),
),
SizedBox(
height: 3.7,
),
Container(
height: 50,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8)),
child: Padding(
padding: const EdgeInsets.only(
left: 16.0, right: 8, top: 2),
child: Stack(
children: [
TextFormField(
cursorColor: Colors.white,
controller: countryController,
enabled: true,
validator: (value) {
if (value!.length != 0) {
return null;
}
return "please select country";
},
decoration: const InputDecoration(
suffixIcon:
Icon(Icons.keyboard_arrow_down),
hintText: 'Country',
hintStyle: TextStyle(fontSize: 16),
border: UnderlineInputBorder(
borderSide: BorderSide.none)),
style: TextStyle(
fontSize: 16,
color: Colors.grey[900],
),
),
Container(
color: Colors.transparent,
width: 2222,
//MediaQuery.of(context).size.width,
child: PopupMenuButton<String>(
icon: const Icon(
Icons.arrow_drop_down,
color: Colors.transparent,
),
onSelected: (String value) {
setState(() {
countryController.text = value;
});
},
itemBuilder: (BuildContext context) {
return CountryList.map<
PopupMenuItem<String>>(
(String value) {
FocusScope.of(context).unfocus();
return new PopupMenuItem(
child: Container(
width: 1111,
//MediaQuery.of(context).size.width,
child: new Text(value)),
value: value);
}).toList();
},
),
)
],
),
),
),
SizedBox(
height: 16,
),
SizedBox(
height: 48,
width: double.infinity,
child: ElevatedButton(
style: ButtonStyle(
elevation: MaterialStateProperty.all(0),
foregroundColor:
MaterialStateProperty.all<Color>(
Colors.white),
backgroundColor:
MaterialStateProperty.all<Color>(
Color(0xFFF2A6A4)),
shape: MaterialStateProperty.all<
RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
side: BorderSide(color: Color(0xFFF2A6A4)),
),
),
),
onPressed: () {},
child: Text(
'Sign Up',
style: GoogleFonts.poppins(
fontSize: 14, color: Colors.white),
),
),
),
SizedBox(
height: 42,
),
],
),
),
),
],
),
),
),
),
bottomNavigationBar: Container(
color: Color(0xff3a99a4),
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(topLeft: Radius.circular(60))),
width: double.infinity,
height: 57,
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Already have an account? ',
style: GoogleFonts.poppins(fontSize: 14, color: Colors.black),
),
GestureDetector(
onTap: () {
// Navigator.pushReplacement(
// context,
// MaterialPageRoute(
// builder: (context) => LoginPage(),
// ),
// );
},
child: Text(
"Let's Go",
style: GoogleFonts.poppins(
fontSize: 14, color: Color(0xFF158998)),
))
],
)),
),
),
),
);
}
}

Flutter screen overflow from bottom

I have a simple page in which I am using SingleChildScrollView to scroll the page so it will not show overflow and show the content of the bottom.
But it's showing an error also the page is not scrollable due to which I can't see the bottom 2 buttons
My code
SingleChildScrollView(
child: Container(
height: Height * 1,
child: Column(
children: <Widget>[
Container(
color: kPrimaryColor,
child: Column(
children: [
SizedBox(
height: Status * 1,
),
SizedBox(
height: Height * 0.065,
),
Padding(
padding: const EdgeInsets.only(left: 13, bottom: 13),
child: Align(
alignment: Alignment.centerLeft,
child: Text(
'Create Account',
style: TextStyle(
color: Colors.white,
fontSize: 30,
fontFamily: 'SegoeUI-SemiBold'),
),
),
),
Padding(
padding: const EdgeInsets.only(left: 13),
child: Text(
"Please create an account in order to start using your StalkMe Profile.",
style: TextStyle(
color: Colors.white,
fontSize: 16,
fontFamily: 'SegoeUI'),
),
),
SizedBox(
height: Height * 0.04,
),
],
),
),
Expanded(
child: Container(
color: kPrimaryColor,
child: Container(
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30),
topRight: Radius.circular(30))),
child: Form(
key: _formKey,
child: Column(
children: [
GestureDetector(
onTap: () {
print('Login print');
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => LoginScreen()),
);
},
child: Padding(
padding: const EdgeInsets.only(
top: 17, right: 17, bottom: 17),
child: Align(
alignment: Alignment.centerRight,
child: Text(
'LOGIN',
style: TextStyle(
color: kPrimaryColor,
fontSize: 16,
fontFamily: 'SegoeUI-SemiBold',
),
)),
),
),
Container(
height: 1,
width: double.infinity,
color: Color(0xffE6E6E6),
),
SizedBox(
height: Height * 0.03,
),
Container(
width: Width * 0.9,
child: Align(
alignment: Alignment.centerLeft,
child: Text(
'Name',
style: TextStyle(
color: textGreyColor,
fontSize: 16,
fontFamily: 'SegoeUI'),
),
),
),
Padding(
padding: const EdgeInsets.only(top: 11),
child: Container(
width: Width * 0.9,
child: TextFormField(
controller: userName,
validator: (value) {
if (value!.isEmpty) {
return 'Please enter a name';
}
return null;
},
style: TextStyle(
color: textGreyColor,
fontFamily: 'SegoeUI'),
decoration: new InputDecoration(
enabledBorder: new OutlineInputBorder(
borderSide: const BorderSide(
color: Color(0xffE6E6E6), width: 1),
),
filled: true,
hintStyle: new TextStyle(
color: textGreyColor, fontSize: 15),
hintText: "Enter Name",
fillColor: Colors.white,
focusedBorder: OutlineInputBorder(
borderSide: const BorderSide(
color: Color(0xffE6E6E6), width: 1),
borderRadius: const BorderRadius.all(
const Radius.circular(10.0),
),
),
),
),
),
),
SizedBox(
height: Height * 0.02,
),
Container(
width: Width * 0.9,
child: Align(
alignment: Alignment.centerLeft,
child: Text(
'Email Address',
style: TextStyle(
color: textGreyColor,
fontSize: 16,
fontFamily: 'SegoeUI'),
),
),
),
Padding(
padding: const EdgeInsets.only(top: 11),
child: Container(
width: Width * 0.9,
child: TextFormField(
controller: userEmail,
validator: (value) {
if (value!.isEmpty || !value.contains('#')) {
return 'Please enter a valid email address';
}
return null;
},
style: TextStyle(
color: textGreyColor,
fontFamily: 'SegoeUI'),
decoration: new InputDecoration(
enabledBorder: new OutlineInputBorder(
borderSide: const BorderSide(
color: Color(0xffE6E6E6), width: 1),
),
filled: true,
hintStyle: new TextStyle(
color: textGreyColor, fontSize: 15),
hintText: "Enter Email Address",
fillColor: Colors.white,
focusedBorder: OutlineInputBorder(
borderSide: const BorderSide(
color: Color(0xffE6E6E6), width: 1),
borderRadius: const BorderRadius.all(
const Radius.circular(10.0),
),
),
),
),
),
),
SizedBox(
height: Height * 0.02,
),
Container(
width: Width * 0.9,
child: Align(
alignment: Alignment.centerLeft,
child: Text(
'Password',
style: TextStyle(
color: textGreyColor,
fontSize: 16,
fontFamily: 'SegoeUI'),
),
),
),
Padding(
padding: const EdgeInsets.only(top: 11),
child: Container(
width: Width * 0.9,
child: TextFormField(
controller: userPassword,
validator: (value) {
if (value!.isEmpty || value.length < 6) {
return 'Please enter a 6 digit password';
}
return null;
},
obscureText: true,
key: ValueKey('name'),
style: TextStyle(
color: textGreyColor,
fontFamily: 'SegoeUI'),
decoration: new InputDecoration(
enabledBorder: new OutlineInputBorder(
borderSide: const BorderSide(
color: Color(0xffE6E6E6), width: 1),
),
filled: true,
hintStyle: new TextStyle(
color: textGreyColor, fontSize: 15),
hintText: "Enter Password",
fillColor: Colors.white,
focusedBorder: OutlineInputBorder(
borderSide: const BorderSide(
color: Color(0xffE6E6E6), width: 1),
borderRadius: const BorderRadius.all(
const Radius.circular(10.0),
),
),
),
),
),
),
SizedBox(
height: Height * 0.02,
),
Spacer(),
GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: Container(
width: Width * 0.9,
height: Height * 0.06,
decoration: BoxDecoration(
color: Color(0xffebf7f7),
borderRadius: BorderRadius.circular(5)),
child: Center(
child: Text(
'GO BACK',
style: TextStyle(
color: kPrimaryColor,
fontSize: 16,
fontFamily: 'SegoeUI'),
),
),
),
),
GestureDetector(
child: Padding(
padding:
const EdgeInsets.only(top: 8, bottom: 18),
child: Container(
width: Width * 0.9,
height: Height * 0.06,
decoration: BoxDecoration(
color: kPrimaryColor,
borderRadius: BorderRadius.circular(5)),
child: Center(
child: Text(
'CREATE ACCOUNT',
style: TextStyle(
color: Colors.white,
fontSize: 16,
fontFamily: 'SegoeUI'),
),
),
),
),
),
],
),
),
),
),
),
],
),
),
),
On small devices, it's not scrollable I try everything to try to give full height but now nothing works for me.
Try putting the Column directly below the SingleChildScrollView.
Like this:
SingleChildScrollView(
child: Column(
children: <Widget>[
Container(
color: kPrimaryColor,
height: Height * 1, // if its still needed
child: Column(
Remove the first container(Wrapped by SingleChildScrollView with height, "height: Height * 1")
Remove the Expanded widget.
Give required size to enbounded Container(
Container with color: kPrimaryColor,)

Flutter TextField Hint Text Not Align Center

Container(
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(5.0),
bottomLeft: Radius.circular(5.0)
),
color: Colors.white,
),
padding: EdgeInsets.only(left: 15.w, right: 15.w),
child: TextField(
maxLines: 1,
style: TextStyle(
fontSize: 12, //This line!!!!!!!!!
textBaseline: TextBaseline.alphabetic,
),
decoration: InputDecoration(
border: InputBorder.none,
hintText: configNotifier.translationObject["SearchOrder"],
hintStyle: TextStyle(
color: fromCSSColor("#808080"),
textBaseline: TextBaseline.alphabetic
),
),
),
)
Before I add "fontSize: 12"
After I add "fontSize: 12"
How to apply font size to textfield with vertical center alignment?
Remark: I've tried "textAlignVertical: TextAlignVertical.center" and hint->textstyle "height:1.0" which is not working
========Edit 1===========
IOS Device is work fine but not on Samsung Galaxy Tab A (8.0", 2019) which model is SM-T295C).
========Edit 2===========
With Parent Widget
Container(
margin: EdgeInsets.only(left: 70, right: 70),
height: 50.h,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Container(
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(5.0),
bottomLeft: Radius.circular(5.0)
),
color: Colors.white,
),
padding: EdgeInsets.only(left: 15.w, right: 15.w),
child: TextField(
maxLines: 1,
style: TextStyle(
fontSize: 12, //This line!!!!!!!!!
textBaseline: TextBaseline.alphabetic,
),
decoration: InputDecoration(
border: InputBorder.none,
hintText: configNotifier.translationObject["SearchOrder"],
hintStyle: TextStyle(
color: fromCSSColor("#808080"),
textBaseline: TextBaseline.alphabetic
),
),
),
),
),
GestureDetector(
onTap: (){
//...
},
child: Container(
width: 100.w,
height: 50.h,
margin: EdgeInsets.only(right: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5.0),
color: fromCSSColor("#000000"),
),
child: Center(
child: Text(
"Submit",
style: TextStyle(
color: fromCSSColor("#000000"),
fontSize: 12
),
textAlign: TextAlign.center,
),
)
)
),
GestureDetector(
onTap: (){
//...
},
child: Container(
width: 65.w,
height: 50.h,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5.0),
color: fromCSSColor("#000000"),
),
child: Center(
child: Container(
width: 41.w,
height: 41.h,
alignment: Alignment.center,
child: Image.asset('assets/images/icon_scan_white.png', fit: BoxFit.contain),
),
),
)
)
],
)
)
Try to textalign.center in TextField like below
TextField(
textAlign : TextAlign.center,
),
your screen look like this-
try contentPadding inside decoration. and dont need to use padding on Expanded Container.
import 'package:flutter/material.dart';
class CounterList extends StatefulWidget {
#override
_CounterListState createState() => _CounterListState();
}
class _CounterListState extends State<CounterList> {
#override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.red,
body: Padding(
padding: const EdgeInsets.all(8.0),
child: ListView(
children: [
CustomField(
fontSize: 17,
),
SizedBox(
height: 22,
),
CustomField(
fontSize: 37,
),
SizedBox(
height: 20,
),
CustomField(
fontSize: 11,
),
SizedBox(
height: 20,
),
CustomField(
fontSize: 22,
),
],
),
));
}
}
class CustomField extends StatelessWidget {
final double fontSize;
CustomField({
Key? key,
required this.fontSize,
}) : super(key: key);
#override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(left: 70, right: 70),
height: 50,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Container(
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(5.0),
bottomLeft: Radius.circular(5.0)),
color: Colors.white,
),
// padding: EdgeInsets.only(left: 15.w, right: 15.w),
child: TextField(
maxLines: 1,
style: TextStyle(
fontSize: fontSize, //This line!!!!!!!!!
textBaseline: TextBaseline.alphabetic,
),
decoration: InputDecoration(
contentPadding: EdgeInsets.only(left: 15, right: 15),
border: InputBorder.none,
hintText: "search",
// hintText: configNotifier.translationObject["SearchOrder"],
hintStyle: TextStyle(
// color: fromCSSColor("#808080"),
color: Colors.grey,
textBaseline: TextBaseline.alphabetic,
),
),
),
),
),
GestureDetector(
onTap: () {
//...
},
child: Container(
width: 100,
height: 50,
margin: EdgeInsets.only(right: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5.0),
// color: fromCSSColor("#000000"),
color: Colors.black,
),
child: Center(
child: Text(
"Submit",
style: TextStyle(
// color: fromCSSColor("#000000"),
color: Colors.black,
fontSize: 12,
),
textAlign: TextAlign.center,
),
))),
GestureDetector(
onTap: () {
//...
},
child: Container(
width: 65,
height: 50,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5.0),
// color: fromCSSColor("#000000"),
color: Colors.black,
),
child: Center(
child: Container(
width: 41,
height: 41,
alignment: Alignment.center,
child: Image.asset(
// 'assets/images/icon_scan_white.png',
"assets/me.jpg",
fit: BoxFit.contain,
),
),
),
))
],
));
}
}
Try it:
TextField(
textAlign : TextAlign.center,
textAlignVertical: TextAlignVertical.center,
),