我有一个文本字段,当我选择该文本字段以输入文本时会崩溃。没有键盘出现,应用崩溃。发生在iPhone上,文本字段在iPad上运行良好。
SizedBox(
width: 140,
height: 38,
child: TextField(),
);
版本:
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
堆栈跟踪:
*** 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<…>
在iphone 8模拟器上测试(失败),在iphone 7物理设备上测试(失败),在iPad 2模拟器上测试(正常)
答案 0 :(得分:0)
这是我用来解决上述问题的文本字段。
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',
),
),
),
);