I have a textfield that crashes when I select the textfield to enter text. no keyboard appears and app crashes. Happens on iphones, textfield works fine on iPad.
SizedBox(
width: 140,
height: 38,
child: TextField(),
);
version:
Flutter 1.9.1+hotfix.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 2d2a1ffec9 (6 days ago) • 2019-09-06 18:39:49 -0700
Engine • revision b863200c37
Tools • Dart 2.5.0
stack trace:
*** First throw call stack:
(
0 CoreFoundation 0x000000010e0168db __exceptionPreprocess + 331
1 libobjc.A.dylib 0x000000010d5b9ac5 objc_exception_throw + 48
2 CoreFoundation 0x000000010e016735 +[NSException raise:format:] + 197
3 UIKitCore 0x000000011596d303 -[UIViewController __supportedInterfaceOrientations] + 921
4 UIKitCore 0x0000000115b2155d -[UIApplicationRotationFollowingController supportedInterfaceOrientations] + 101
5 UIKitCore 0x000000011596d237 -[UIViewController __supportedInterfaceOrientations] + 717
6 UIKitCore 0x000000011596d859 -[UIViewController __withSupportedInterfaceO<…>
Tested on iphone 8 simulator (fails), tested on iphone 7 physical device (fails), tested on iPad 2 simulator (works fine)
Solution 1: Aaron Halvorsen
Here is the textfield I used to resolve the issue I posted above.
SizedBox(
width: 180,
height: 28,
child: ClipRRect(
borderRadius: BorderRadius.circular(14),
child: TextField(
textAlign: TextAlign.center,
onChanged: (searchTerm) => bloc(context).add(SearchEvent(searchTerm)),
onEditingComplete: () => bloc(context).add(SearchEvent('')),
onSubmitted: null, //do nothing
decoration: InputDecoration(
hintStyle: textStyle,
labelStyle: textStyle,
fillColor: Colors.white,
filled: true,
border: InputBorder.none,
hintText: 'Enter search terms',
),
),
),
);