How to limit the range of textfield in flutter?

Viewed 174

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),
  ],
  ),
0 Answers
Related