当我选择文本字段输入文本时,我有一个文本字段崩溃。没有键盘出现并且应用程序崩溃。发生在 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 模拟器上测试(工作正常)
最佳答案
这是我用来解决上面发布的问题的文本字段。
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',
),
),
),
);
关于flutter - 选择文本字段时 iPhone 上的应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57923798/