[Solved] Flutter - How can I dismiss SelectionControls when scrolling?

Question

Asked by burhanaksendir on January 12, 2022 (source).

I am using SelectableText inside SingleChildScrollView.

SingleChildScrollView(
  child: Container(
    padding: const EdgeInsets.all(20.0),
    child: SelectableText(loremipsum),
  ),
);

In selectionControls, when I select the property named ToolBarItemControl.copy, chaos ensues. If you look at the video here, you can see the exact problem. How can I dismiss SelectionControls when scrolling?

Answer

Question answered by Coral (source).

For this, simply add keyboardDismissBehavior to SingleChildScrollView. Like this:

SingleChildScrollView(
  keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
  child: Container(
    padding: const EdgeInsets.all(20.0),
    child: SelectableText(loremipsum),
  ),
);

Video Answers on YouTube

FLUTTER SINGLECHILDSCROLLVIEW
SHARE: