@@ -1893,7 +1893,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
18931893 final GlobalKey _editableKey = GlobalKey ();
18941894
18951895 /// Detects whether the clipboard can paste.
1896- final ClipboardStatusNotifier ? clipboardStatus = kIsWeb ? null : ClipboardStatusNotifier ();
1896+ final ClipboardStatusNotifier clipboardStatus = ClipboardStatusNotifier ();
18971897
18981898 TextInputConnection ? _textInputConnection;
18991899 bool get _hasInputConnection => _textInputConnection? .attached ?? false ;
@@ -1996,8 +1996,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
19961996 return widget.toolbarOptions.paste && ! widget.readOnly;
19971997 }
19981998 return ! widget.readOnly
1999- && (clipboardStatus == null
2000- || clipboardStatus! .value == ClipboardStatus .pasteable);
1999+ && (clipboardStatus.value == ClipboardStatus .pasteable);
20012000 }
20022001
20032002 @override
@@ -2074,7 +2073,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
20742073 break ;
20752074 }
20762075 }
2077- clipboardStatus? .update ();
2076+ clipboardStatus.update ();
20782077 }
20792078
20802079 /// Cut current selection to [Clipboard] .
@@ -2099,7 +2098,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
20992098 });
21002099 hideToolbar ();
21012100 }
2102- clipboardStatus? .update ();
2101+ clipboardStatus.update ();
21032102 }
21042103
21052104 /// Paste text from [Clipboard] .
@@ -2285,7 +2284,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
22852284 },
22862285 type: ContextMenuButtonType .copy,
22872286 ),
2288- if (toolbarOptions.paste && clipboardStatus != null && pasteEnabled)
2287+ if (toolbarOptions.paste && pasteEnabled)
22892288 ContextMenuButtonItem (
22902289 onPressed: () {
22912290 pasteText (SelectionChangedCause .toolbar);
@@ -2386,7 +2385,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
23862385 /// button Widgets for the current platform given [ContextMenuButtonItem] s.
23872386 List <ContextMenuButtonItem > get contextMenuButtonItems {
23882387 return buttonItemsForToolbarOptions () ?? EditableText .getEditableButtonItems (
2389- clipboardStatus: clipboardStatus? .value,
2388+ clipboardStatus: clipboardStatus.value,
23902389 onCopy: copyEnabled
23912390 ? () => copySelection (SelectionChangedCause .toolbar)
23922391 : null ,
@@ -2407,7 +2406,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
24072406 @override
24082407 void initState () {
24092408 super .initState ();
2410- clipboardStatus? .addListener (_onChangedClipboardStatus);
2409+ clipboardStatus.addListener (_onChangedClipboardStatus);
24112410 widget.controller.addListener (_didChangeTextEditingValue);
24122411 widget.focusNode.addListener (_handleFocusChanged);
24132412 _scrollController.addListener (_onEditableScroll);
@@ -2531,8 +2530,8 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
25312530 final bool canPaste = widget.selectionControls is TextSelectionHandleControls
25322531 ? pasteEnabled
25332532 : widget.selectionControls? .canPaste (this ) ?? false ;
2534- if (widget.selectionEnabled && pasteEnabled && clipboardStatus != null && canPaste) {
2535- clipboardStatus! .update ();
2533+ if (widget.selectionEnabled && pasteEnabled && canPaste) {
2534+ clipboardStatus.update ();
25362535 }
25372536 }
25382537
@@ -2553,8 +2552,8 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
25532552 _selectionOverlay = null ;
25542553 widget.focusNode.removeListener (_handleFocusChanged);
25552554 WidgetsBinding .instance.removeObserver (this );
2556- clipboardStatus? .removeListener (_onChangedClipboardStatus);
2557- clipboardStatus? .dispose ();
2555+ clipboardStatus.removeListener (_onChangedClipboardStatus);
2556+ clipboardStatus.dispose ();
25582557 _cursorVisibilityNotifier.dispose ();
25592558 super .dispose ();
25602559 assert (_batchEditDepth <= 0 , 'unfinished batch edits: $_batchEditDepth ' );
@@ -3688,17 +3687,18 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
36883687 @override
36893688 bool showToolbar () {
36903689 // Web is using native dom elements to enable clipboard functionality of the
3691- // toolbar: copy, paste, select, cut. It might also provide additional
3692- // functionality depending on the browser (such as translate). Due to this
3693- // we should not show a Flutter toolbar for the editable text elements.
3694- if (kIsWeb) {
3690+ // context menu: copy, paste, select, cut. It might also provide additional
3691+ // functionality depending on the browser (such as translate). Due to this,
3692+ // we should not show a Flutter toolbar for the editable text elements
3693+ // unless the browser's context menu is explicitly disabled.
3694+ if (kIsWeb && BrowserContextMenu .enabled) {
36953695 return false ;
36963696 }
36973697
36983698 if (_selectionOverlay == null ) {
36993699 return false ;
37003700 }
3701- clipboardStatus? .update ();
3701+ clipboardStatus.update ();
37023702 _selectionOverlay! .showToolbar ();
37033703 return true ;
37043704 }
@@ -3912,7 +3912,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
39123912 && (widget.selectionControls is TextSelectionHandleControls
39133913 ? pasteEnabled
39143914 : pasteEnabled && (widget.selectionControls? .canPaste (this ) ?? false ))
3915- && (clipboardStatus == null || clipboardStatus ! .value == ClipboardStatus .pasteable)
3915+ && (clipboardStatus.value == ClipboardStatus .pasteable)
39163916 ? () {
39173917 controls? .handlePaste (this );
39183918 pasteText (SelectionChangedCause .toolbar);
0 commit comments