title: Restrict Special Character Input Flutter
body: <p>I have a TextField that will only take numbers as an input.
  The Keyboard that appears allows for the input of the the following characters: "-(hyphen) ,(comma) .(period) and space". How can I prevent the user from entering all except the period.   </p>
  
  <pre><code>child: new TextField(
    controller: _controller,
    maxLengthEnforced: true,
    keyboardType: TextInputType.number,
    maxLength: 4, //9999 upper limit
    ), //TextField
  </code></pre>
  
  <p>I've tried to use RegExp to take the _controller text, remove the characters and place it back into to field without any luck.</p>
  
  <pre><code>...//Add Listener to _controller
  _controller.addListener(restrictCharacters);
  ...
  
  //Listener
  void restrictCharacters(){
    RegExp regexp = new RegExp(
      r"^|\-|\,|\ ",
      caseSensitive: false,
      multiLine: false,);
    String text = _controller.text;
    String chng = text.replaceaLL(regExp,"");
    _controller.text = chng;
  }
  </code></pre>
  
  <p>When applied the cursor moves to beginning and the field keeps the - (hyphen) for example. </p>