Display the default/native context menu

82 Views Asked by At

I have an app with Flutter, which has a text field and button:

enter image description here

Row(
  children: [
    Expanded(
      child: TextFormField(),
    ),
    Expanded(
      child: ElevatedButton(
        onPressed: () {},
        child: const Text('Show menu'),
      ),
    ),
  ],
),

On iOS, when you long-press on the text field, it displays the controls/context menu:

enter image description here

On Android, with the equivalent Android gesture, it displays the Android controls/context menu.

I would like the "Show menu" button to display the corresponding menu when being clicked. I saw it was possible to customize the menu with TextField.contextMenuBuilder.

But don't want to customize it, I just want to trigger it.

How can I do that?

0

There are 0 best solutions below