fayeed / flutter_mentions

A simple flutter input widget to add @ mentions functionality to your app
MIT License
107 stars 122 forks source link

Clear text field #13

Closed JEuler closed 4 years ago

JEuler commented 4 years ago

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

fayeed commented 4 years ago

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 = '';

JEuler commented 4 years ago

Thank you very much!

loic-hamdi commented 4 years ago

@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 ?

loic-hamdi commented 4 years ago

@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 ?