allow only numbers in textfield flutter code example
Example 1: flutter textfield number only
import 'package:flutter/services.dart';
keyboardType: TextInputType.number,
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
Example 2: allow only integer input flutter
import 'package:flutter/services.dart';
new TextField(
decoration: new InputDecoration(labelText: "Enter any number"),
keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.digitsOnly
], // Only numbers can be entered in this input field
),