0

I'm facing an issue with the FormBuilderTextField widget in Flutter. I want to enable copy-paste interaction within the FormBuilderTextField when I long-press it, but it doesn't seem to work as expected. Here's my code:

FormBuilderTextField(
  name: 'pincode',
  style: const TextStyle(
    color: primaryColor,
    fontSize: 12,
    fontWeight: FontWeight.w400,
  ),
  onChanged: (value) {},
  maxLength: 6,
  decoration: InputDecoration(
    contentPadding: const EdgeInsets.only(left: 12),
    counterText: "",
    border: buildBorderDecoration(),
    enabledBorder: buildEnableAndDisabledBorder(),
    errorBorder: buildErrorBorder(),
    disabledBorder: buildEnableAndDisabledBorder(),
    floatingLabelBehavior: FloatingLabelBehavior.never,
    fillColor: Colors.white,
    filled: true,
    labelText: '680024',
    labelStyle: const TextStyle(
      color: lightGrey,
      fontSize: 12,
      fontWeight: FontWeight.w400,
    ),
  ),
),

Despite setting enableInteractiveSelection to true, the copy-paste interaction is not working. Any suggestions on how to resolve this issue would be greatly appreciated.

  • Flutter version: 3.10.2

  • Operating System: Windows

  • Any other relevant details or code snippets.

Please let me know if you have any insights or solutions to this problem. Thank you

1 Answer 1

1

It would seem this issue was known already.

Refer to this github link with the potential solution which is to add contextMenuBuilder to FormBuilderTextField.

FormBuilderTextField(
  name: "description",
  contextMenuBuilder: (context, editableTextState) {
    return AdaptiveTextSelectionToolbar.editableText(
        editableTextState: editableTextState,
    );
 }, 
);
Sign up to request clarification or add additional context in comments.

2 Comments

I have tried this solution, But it's not worked in my case, It seems I have a Listener widget around the Scaffold beneath the MaterialApp, intending to manage keyboard unfocusing, and this is making the issue, while I try to copy-past something into the field, before executing the past functionality keyboard unFocus function executing at first so the context to the active field is loosing while there. Thank you for your answer
Good to see you solved it. I mostly wrap the parent widget in a GestureDetector and in the onTap method call the unfocus. This hasn't interfered with contextual actions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.