I want to provide a limit to the textfield in flutter. For example, I want that the user can only type numbers between 0-5000. How can I achieve it?
child: TextField(
controller: sliderController,
onChanged: (value) {
setState(() {
amount = value;
sliderAmount = double.parse(value);
});
},
decoration: InputDecoration(
border: OutlineInputBorder(),
contentPadding: EdgeInsets.fromLTRB(15, 65, 15, 0),
prefixText: '₹',
prefixStyle: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 30,
),
),
keyboardType: TextInputType.number,
inputFormatters: [
LengthLimitingTextInputFormatter(6),
],
),