import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
TextField(
inputFormatters: [
WhitelistingTextInputFormatter(RegExp("[a-zA-Z]")),//只允许输入字母
],
),
TextField(
inputFormatters:[WhitelistingTextInputFormatter.digitsOnly],//只允许输入数字
),
TextField(
inputFormatters: [
WhitelistingTextInputFormatter(RegExp("[0-9.]")),//只允许输入小数
],
)
网友评论