flutter - 选择文本字段时 iPhone 上的应用程序崩溃

标签 flutter flutter-layout

当我选择文本字段输入文本时,我有一个文本字段崩溃。没有键盘出现并且应用程序崩溃。发生在 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/

相关文章:

flutter - 没有 Java 运行时,请求安装 : Mac OS, Flutter

dart - 为什么 Flutter 中的列表项不保存 Dart 中变量的引用?

flutter - BLOC 状态更改后有状态小部件未重建

flutter - 行中可用空间内的中心小部件

flutter - 容器不会 flutter 地到达屏幕底部吗?

flutter - 如何在flutter应用程序中正确实现注销功能?

firebase - Flutter Firebase电话登录需要热重启才能通过身份验证

flutter - flutter 中对话框内的内容对齐?

flutter - 如何让一个Widget尽可能小(Android中的wrap_content)?

flutter - 如何在 flutter 的底部导航栏中应用高程?