Skip to content

[flutter_markdown] Null check operator used on a null value in MarkdownBuilder._buildRichText.<fn>(builder.dart:957) #149817

@jimmyff

Description

@jimmyff

(Same issue as #146282 which was reported back in April and closed by bot)

After updating my production app I've been getting crashlytics reports:

Fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: Null check operator used on a null value. Error thrown .
       at MarkdownBuilder._buildRichText.<fn>(builder.dart:957)
       at _SelectableTextState._handleSelectionChanged(selectable_text.dart:628)
       at EditableTextState._handleSelectionChanged(editable_text.dart:3976)
       at EditableTextState._formatAndSetValue(editable_text.dart:4184)
       at EditableTextState.userUpdateTextEditingValue(editable_text.dart:4554)
       at RenderEditable._setTextEditingValue(editable.dart:719)
       at RenderEditable._setSelection(editable.dart:738)
       at RenderEditable.selectWordsInRange(editable.dart:2117)
       at RenderEditable.selectWord(editable.dart:2098)
       at _SelectableTextSelectionGestureDetectorBuilder.onSingleLongTapStart(selectable_text.dart:105)
       at _TextSelectionGestureDetectorState._handleLongPressStart(text_selection.dart:3332)
       at LongPressGestureRecognizer._checkLongPressStart.<fn>(long_press.dart:703)
       at GestureRecognizer.invokeCallback(recognizer.dart:344)
       at LongPressGestureRecognizer._checkLongPressStart(long_press.dart:703)
       at LongPressGestureRecognizer.didExceedDeadline(long_press.dart:607)
       at PrimaryPointerGestureRecognizer.didExceedDeadlineWithEvent(recognizer.dart:724)
       at PrimaryPointerGestureRecognizer.addAllowedPointer.<fn>(recognizer.dart:667)   
Fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: Null check operator used on a null value. Error thrown .
       at MarkdownBuilder._buildRichText.<fn>(builder.dart:957)
       at _SelectableTextState._handleSelectionChanged(selectable_text.dart:628)
       at EditableTextState._handleSelectionChanged(editable_text.dart:3976)
       at EditableTextState._formatAndSetValue(editable_text.dart:4184)
       at EditableTextState.userUpdateTextEditingValue(editable_text.dart:4554)
       at RenderEditable._setTextEditingValue(editable.dart:719)
       at RenderEditable._setSelection(editable.dart:738)
       at RenderEditable.selectPositionAt(editable.dart:2088)
       at RenderEditable.selectPosition(editable.dart:2065)
       at _SelectableTextSelectionGestureDetectorBuilder.onSingleTapUp(selectable_text.dart:145)
       at _TextSelectionGestureDetectorState._handleTapUp(text_selection.dart:3299)
       at BaseTapAndDragGestureRecognizer._checkTapUp.<fn>(tap_and_drag.dart:1198)
       at GestureRecognizer.invokeCallback(recognizer.dart:344)
       at BaseTapAndDragGestureRecognizer._checkTapUp(tap_and_drag.dart:1198)
       at BaseTapAndDragGestureRecognizer.acceptGesture(tap_and_drag.dart:996)
       at GestureArenaManager.sweep(arena.dart:167)
       at GestureBinding.handleEvent(binding.dart:499)
       at GestureBinding.dispatchEvent(binding.dart:475)
       at RendererBinding.dispatchEvent(binding.dart:425)
       at GestureBinding._handlePointerEventImmediately(binding.dart:420)
       at GestureBinding.handlePointerEvent(binding.dart:383)
       at GestureBinding._flushPointerEventQueue(binding.dart:330)
       at GestureBinding._handlePointerDataPacket(binding.dart:299)

I'm unsure where in my app this is being generated as the stacktrace seems entirely outside of my codebase. So until these customers contact me and report where in the app the problem is occurring I'm unable to create a reproducible example. As this issue was reported back in #146282 with the same error it seems to be a genuine bug. They highlighted the code:

319922844-39632c84-49c0-4d4a-b2c5-78a1c38e4a3c

It looks like onSelectionChanged is not always set?

Flutter doctor

[✓] Flutter (Channel stable, 3.22.1, on macOS 14.2.1 23C71 darwin-arm64, locale en-GB)
    • Flutter version 3.22.1 on channel stable at /Users/jimmyff/sdks/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision a14f74ff3a (2 weeks ago), 2024-05-22 11:08:21 -0500
    • Engine revision 55eae6864b
    • Dart version 3.4.1
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/jimmyff/Library/Android/sdk
    • Platform android-34, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

[✓] VS Code (version 1.89.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.90.0

[✓] Connected device (4 available)
    • Pixel 5 (mobile)                • 09021FDD40027X        • android-arm64  • Android 14 (API 34)
    • macOS (desktop)                 • macos                 • darwin-arm64   • macOS 14.2.1 23C71 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         • macOS 14.2.1 23C71 darwin-arm64
    • Chrome (web)                    • chrome                • web-javascript • Google Chrome 125.0.6422.142

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: productionIssues experienced in live production appsc: crashStack traces logged to the consoleneeds repro infoAutomated crash report whose cause isn't yet knownp: flutter_markdownflutter/packages flutter_markdownpackageflutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer versionteam-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions