I tried every possible answer on stackoverflow, still not able to solve this problem. Whenever I click on any TextFormField, it opens and closes keyboard immediately. And also keyboard tries covers password fields.
import 'package:flutter/material.dart';
import 'package:metro_prototype/pages/loginPage.dart';
import '../uiConstsants.dart';
class RegisterPage extends StatefulWidget {
static final String routeName = "/registerPage";
@override
_RegisterPageState createState() => _RegisterPageState();
}
class _RegisterPageState extends State<RegisterPage> {
@override
Widget build(BuildContext context) {
var width = MediaQuery.of(context).size.width;
FocusScope.of(context).unfocus();
return Scaffold(
body: GestureDetector(
onTap: () => FocusScope.of(context).unfocus(),
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Colors.white, color1])),
//#002D72
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Hero(
tag: 'logo',
child: Padding(
padding:
const EdgeInsets.only(left: 100, right: 100, bottom: 30),
child: ClipOval(
child: Image.asset(
'images/haiko1.jpg',
height: width / 4,
width: width / 4,
),
),
),
),
Padding(
padding: const EdgeInsets.all(20.0),
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(15)),
child: Padding(
padding: const EdgeInsets.all(25.0),
child: Column(
children: [
TextFormField(
decoration: textfield1Deco.copyWith(
prefixIcon: Icon(Icons.account_circle),
hintText: "Enter your name",
labelText: "Name",
),
),
SizedBox(height: 30),
TextFormField(
decoration: textfield1Deco.copyWith(
prefixIcon: Icon(Icons.phone),
hintText: "Enter your mobile number",
labelText: "Mobile Number"),
),
SizedBox(height: 30),
TextFormField(
decoration: textfield1Deco.copyWith(
prefixIcon: Icon(Icons.lock),
hintText: "Enter your password",
labelText: "Password",
),
),
SizedBox(height: 30),
TextFormField(
decoration: textfield1Deco.copyWith(
prefixIcon: Icon(Icons.lock),
hintText: "Enter your password",
labelText: "Password",
),
),
SizedBox(height: 30),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
getButton("Register", Icons.person_add, () {
Navigator.pop(
context,
PageRouteBuilder(
transitionDuration:
Duration(milliseconds: 2000),
pageBuilder: (_, __, ___) => LoginPage(),
));
})
],
)
],
),
),
),
)
],
),
),
),
);
}
}
I am getting render problem on column, I also tried putting it in SingleChildScrolView.
The following assertion was thrown during layout: A RenderFlex overflowed by 22 pixels on the bottom.
The relevant error-causing widget was: Column file:///D:/Android/FlutterApp/metro_prototype/lib/pages/registerPage.dart:29:18 The overflowing RenderFlex has an orientation of Axis.vertical. The edge of the RenderFlex that is overflowing has been marked in the rendering with a yellow and black striped pattern. This is usually caused by the contents being too big for the RenderFlex.
Consider applying a flex factor (e.g. using an Expanded widget) to force the children of the RenderFlex to fit within the available space instead of being sized to their natural size. This is considered an error condition because it indicates that there is content that cannot be seen. If the content is legitimately bigger than the available space, consider clipping it with a ClipRect widget before putting it in the flex, or using a scrollable container rather than a Flex, like a ListView.
The specific RenderFlex in question is: RenderFlex#ee67d relayoutBoundary=up4 OVERFLOWING ... needs compositing ... parentData: (can use size) ... constraints: BoxConstraints(0.0<=w<=411.4, 0.0<=h<=561.1) ... size: Size(411.4, 561.1) ... direction: vertical ... mainAxisAlignment: center ... mainAxisSize: max ... crossAxisAlignment: center ... verticalDirection: down