RangeError (length): Invalid value: Only valid value is 0: 1. 'ErrorDescription' 的实例抛出错误

RangeError (length): Invalid value: Only valid value is 0: 1. Error thrown Instance of 'ErrorDescription'

我们刚刚发布了我们的应用程序。并在生产中看到这些崩溃。但是堆栈跟踪并没有把我带到有用的地方。

RangeError(长度):无效值:唯一有效值为 0:1。错误抛出 'ErrorDescription

实例
Non-fatal Exception: FlutterError
0  ???                            0x0 first (dart:core)
1  ???                            0x0 assembleSemanticsNode + 436 (paragraph.dart:436)
2  ???                            0x0 compileChildren + 3717 (object.dart:3717)
3  ???                            0x0 compileChildren + 3709 (object.dart:3709)
4  ???                            0x0 compileChildren + 3709 (object.dart:3709)
5  ???                            0x0 compileChildren + 3709 (object.dart:3709)
6  ???                            0x0 compileChildren + 3709 (object.dart:3709)
7  ???                            0x0 compileChildren + 3709 (object.dart:3709)
8  ???                            0x0 compileChildren + 3709 (object.dart:3709)
9  ???                            0x0 compileChildren + 3709 (object.dart:3709)
10 ???                            0x0 compileChildren + 3663 (object.dart:3663)
11 ???                            0x0 compileChildren + 3709 (object.dart:3709)
12 ???                            0x0 compileChildren + 3587 (object.dart:3587)
13 ???                            0x0 _updateSemantics + 2631 (object.dart:2631)
14 ???                            0x0 flushSemantics + 1081 (object.dart:1081)
15 ???                            0x0 drawFrame + 441 (binding.dart:441)
16 ???                            0x0 drawFrame + 914 (binding.dart:914)
17 ???                            0x0 _handlePersistentFrameCallback + 302 (binding.dart:302)
18 ???                            0x0 _invokeFrameCallback + 1117 (binding.dart:1117)
19 ???                            0x0 handleDrawFrame + 1055 (binding.dart:1055)
20 ???                            0x0 _handleDrawFrame + 971 (binding.dart:971)

重现步骤

我无法重现该问题。我在 firebase 中看到这些崩溃。

日志
No problems with the analyzer
[✓] Flutter (Channel stable, 1.22.6, on Mac OS X 10.15.7 19H114 darwin-x64, locale en-BE)
    • Flutter version 1.22.6 at /Users/vanlooverenkoen/fvm/versions/stable
    • Framework revision 9b2d32b605 (5 weeks ago), 2021-01-22 14:36:39 -0800
    • Engine revision 2f0af37152
    • Dart version 2.10.5
                                                                                                                                                                                                                                                                                                                             [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/vanlooverenkoen/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.0.1, Build version 12A7300
    • CocoaPods version 1.10.0

[!] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[!] IntelliJ IDEA Community Edition (version 2020.3)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • For information about installing plugins, see
      https://flutter.dev/intellij-setup/#installing-the-plugins

[!] VS Code (version 1.53.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    ✗ Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

在我们的例子中,我们有一个带有可点击文本跨度的富文本。

这导致了一个问题。

https://github.com/flutter/flutter/issues/69787 https://github.com/flutter/flutter/issues/51936

更新到 flutter 2.0.0 以获得潜在修复

pre flutter 2.0.0 的解决方法:

ExcludeSemantics(
  excluding: true,
  child: RichText( ... ),
),