Reputation: 31
I'm trying to build a simple form in Flutter, however, I keep on running into an issue. Every time I tap on the TextFormField
, the app crashes or kicks me out.
I don't even get the chance to type anything as the keyboard doesn't fully come up. I can see the keyboard quickly come up halfway and then I'm kicked out.
There is no error at all to help me debug. And Flutter doctor's result looks great. This happens in both the Flutter master channel and the stable channel as well (They are both upgraded to the latest versions).
I switched to the master channel in an effort to see if that would fix it but it did not. Would love some help.
Flutter Doctor:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 1.21.0-8.0.pre.176, on Mac OS X 10.15.3 19D76, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 11.6)
[✓] Android Studio (version 4.0)
[✓] VS Code (version 1.47.3)
[✓] Connected device (1 available)
Code:
class RegisterDeviceForm extends StatefulWidget {
@override
_RegisterDeviceFormState createState() => _RegisterDeviceFormState();
}
class _RegisterDeviceFormState extends State<RegisterDeviceForm> {
final _formKey = GlobalKey<FormState>();
@override
Widget build(BuildContext context) {
return Container(
child: Form(
key: _formKey,
child: Column(
children: <Widget>[
TextFormField(
decoration: InputDecoration(
labelText: "First Name",
),
validator: (String value) {
if (value.isEmpty) {
return 'Name is Required';
}
return null;
},
),
TextFormField(
decoration: InputDecoration(
labelText: "Last Name",
),
validator: (String value) {
if (value.isEmpty) {
return 'Last Name is Required';
}
return null;
},
),
],
))); //Column // Form // Container
}
}
Upvotes: 3
Views: 1485
Reputation: 61
Well, I tried a lot of approaches to fix this issue and none of them really worked for me. Later I found this issue only occurs in the latest android version. So, what I did was simple. I went to my app > find > build.gradle file and changed mine compileSdkVersion and targetSdkVersion to 33
Upvotes: 2