title: How can I detect a Paste event in a TextEditingController?
body: <p>I have a TextEditingController which is for phone numbers. If text is pasted in it, I need to process and modify it, trimming whitespaces etc. But that should not happen if the user is typing in whitespaces. How can I differentiate between these two types of events, and call my function only when user pastes text into the field?</p>
  <p>Currently my code looks like this and uses <code>onChanged</code>. I'm looking for something like onPaste:</p>
  <pre><code>String getCorrectedPhone(String phone) {
      phone = phone.replaceAll(RegExp(r&quot;\s+&quot;), &quot;&quot;);
      return phone;
  }
  
  FormBuilderTextField(
      controller: _phoneController,
      name: &quot;phone&quot;,
      onChanged: (String txt) {
          print('Phone field changed! Is now $txt');
          _phoneController.text = getCorrectedPhone(txt);
      },
  ),
  </code></pre>
  <p><a href="https://i.stack.imgur.com/RdA0ym.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RdA0ym.jpg" alt="enter image description here" /></a></p>