title: Only allow number input in flutter text field Flutter
body: <p>I have created my text field which should only allow number input for the purpose of some computing i will later do after the value has been input. Its almost working fine but there is one issue though.</p>
  <p><strong>Here is the code for the field</strong></p>
  <pre><code>var numberInputFormatters = [new FilteringTextInputFormatter.allow(RegExp(&quot;[0-9]&quot;)),];
  
  
    String _tip='2';
    Widget _buildOtherTipInput() {
      return TextFormField(
        style: inputTextStyle,
        inputFormatters: numberInputFormatters,
        keyboardType: TextInputType.number,
        decoration: formInputDecoration.copyWith(
            prefix: Text('\$'),
            labelText: 'Enter Custom Tip Amount ',
            hintStyle: TextStyle(fontWeight: FontWeight.w600)
        ),
        onChanged: (val){
         setState(() {
           val!=null?_tip=val:_tip='0';
         });
        },
  
      );
    }
  </code></pre>
  <p>So when you input a number then try to input a non number character, it will not take the input but if i try to input a character that is not a number as the first, i get this error thrown</p>
  <pre><code>Invalid double
  </code></pre>
  <p>I do know that it comes from this code below that converts the string input to a double. What i don't understand is why it receives the invalid double in the first place yet i have set blockers for invalid(non number) input in my text field.</p>
  <pre><code>  String getTotal(){
      String theTip=_tip??'0';
       double  newTip = double.parse(theTip).truncateToDouble();
      return newTip.toStringAsFixed(2);
    }
  </code></pre>