From a82692fe58a8ecc123070b8b6441c5257a01949a Mon Sep 17 00:00:00 2001 From: X Code Date: Fri, 4 Feb 2022 10:53:17 -0800 Subject: [PATCH] Fix: Clicking on the Link icon without any text on a new line will crash --- lib/src/widgets/toolbar/link_style_button.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/src/widgets/toolbar/link_style_button.dart b/lib/src/widgets/toolbar/link_style_button.dart index 0ccdfc77..e479481c 100644 --- a/lib/src/widgets/toolbar/link_style_button.dart +++ b/lib/src/widgets/toolbar/link_style_button.dart @@ -114,8 +114,9 @@ class _LinkStyleButtonState extends State { } } - text ??= widget.controller.document - .getPlainText(index, widget.controller.selection.end - index); + final len = widget.controller.selection.end - index; + text ??= + len == 0 ? '' : widget.controller.document.getPlainText(index, len); return _LinkDialog( dialogTheme: widget.dialogTheme, link: link, text: text); },