fayeed/flutter_mentions

Clear text field

JEuler opened this issue · 4 comments

How I can clear text field after onEditingComplete callback? Setting defaultText not working

You could just set a key for the FlutterMention widget & then just use these two ways to clear the field.

  1. Using the controller's clear method:
    key.currentState.controller.clear();

  2. Using the controller's text property:
    key.currentState.controller.text = '';

Thank you very much!

@fayeed

Bringing the key in the parent widget creates me this error:

════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
Multiple widgets used the same GlobalKey.

How can we please access the key from a different widget ?

@fayeed

Bringing the key in the parent widget creates me this error:

════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
Multiple widgets used the same GlobalKey.

How can we please access the key from a different widget ?