【问题标题】:App crash on iPhone when selecting textfield选择文本字段时 iPhone 上的应用程序崩溃
【发布时间】:2020-01-15 08:09:38
【问题描述】:

当我选择文本字段输入文本时,我有一个文本字段崩溃。没有键盘出现,应用程序崩溃。发生在 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 模拟器上测试(工作正常)

【问题讨论】:

  • 尝试 FLUTTER CLEAN 命令,然后重新运行并粘贴完整代码。
  • 我今天回到了这个问题,试图重现它并发布我的代码,但不能,当我在 9 月 14 日提出建议时,我尝试了flutter clean,但当时没有解决它。感谢@RutvikGumasana 的回复,这可能是某种编译问题。
  • 你的问题解决了吗??
  • 抱歉,我的评论不清楚,是的,崩溃已经消失,我会在未来继续测试,如果再次出现,请在此处评论。
  • @AaronHalvorsen 你能帮助我们吗,崩溃是如何消失的。它将帮助我们解决同样的问题。

标签: flutter flutter-layout


【解决方案1】:

这是我用来解决上面发布的问题的文本字段。

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',
          ),
        ),
      ),
    );

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-20
    • 2011-06-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多