singerdmx / flutter-quill

Rich text editor for Flutter
https://pub.dev/packages/flutter_quill
MIT License
2.6k stars 840 forks source link

Null check operator is used on a null value when long press a link #2271

Open tschiekdev opened 2 months ago

tschiekdev commented 2 months ago

Is there an existing issue for this?

Flutter Quill version

10.7.5

Steps to reproduce

dont know

Expected results

no error

Actual results

Null check operator used on a null value

0 _TextLineState._longPressLink (package:flutter_quill/src/editor/widgets/text/text_line.dart:656)#1 _TextLineState._getRecognizer. (package:flutter_quill/src/editor/widgets/text/text_line.dart:623)

2 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:351)

3 LongPressGestureRecognizer._checkLongPressStart (package:flutter/src/gestures/long_press.dart:709)

4 LongPressGestureRecognizer.didExceedDeadline (package:flutter/src/gestures/long_press.dart:610)

5 PrimaryPointerGestureRecognizer.didExceedDeadlineWithEvent (package:flutter/src/gestures/recognizer.dart:731)

6 PrimaryPointerGestureRecognizer.addAllowedPointer. (package:flutter/src/gestures/recognizer.dart:674)

7 _rootRun (dart:async/zone.dart:1391)

8 _CustomZone.run (dart:async/zone.dart:1301)

9 _CustomZone.runGuarded (dart:async/zone.dart:1209)

10 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1249)

11 _rootRun (dart:async/zone.dart:1399)

12 _CustomZone.run (dart:async/zone.dart:1301)

13 _CustomZone.bindCallback. (dart:async/zone.dart:1233)

14 Timer._createTimer. (dart:async-patch/timer_patch.dart:18)

15 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398)

16 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429)

17 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184)

Additional Context

Screenshots / Video demonstration [Upload media here]
Logs ```console [Paste your logs here] ```
EchoEllet commented 2 months ago

This line is causing the issue. Need to handle this in a better way without using the null check operator, if we're not sure why then should use assert or throw an exception with a clear message instead of return and then causing unexpected behavior that's more difficult to trace.

This commit is related.

I would avoid using dynamic in Dart (and any other language) when possible which is something that's used in Delta and Attribute, instead manually cast and handle exceptions.