How can I limit the size of a text field in flutter?
Use inputFormatters property
example:
TextFormField(
inputFormatters: [
LengthLimitingTextInputFormatter(10),
]
)
namespace
import 'package:flutter/services.dart';
maxLength
property is available in Flutter.
https://docs.flutter.io/flutter/material/TextField/maxLength.html
TextField(
maxLength: 45,
)
You can use the maxLength
property and you can still hide the bottom counter text by setting the counterText
to empty string.
TextField(
maxLength: 10,
decoration: InputDecoration(
counterText: ''
),
)