import 'package:flutter/material.dart'; /// 带标签、错误提示、前/后缀的通用输入框。 class AppTextField extends StatelessWidget { const AppTextField({ super.key, this.controller, this.label, this.hint, this.errorText, this.prefixIcon, this.suffix, this.obscureText = false, this.keyboardType, this.onChanged, this.onSubmitted, this.maxLength, this.enabled = true, this.readOnly = false, this.focusNode, }); final TextEditingController? controller; final String? label; final String? hint; final String? errorText; final Widget? prefixIcon; final Widget? suffix; final bool obscureText; final TextInputType? keyboardType; final ValueChanged? onChanged; final ValueChanged? onSubmitted; final int? maxLength; final bool enabled; final bool readOnly; final FocusNode? focusNode; @override Widget build(BuildContext context) { return TextField( controller: controller, focusNode: focusNode, obscureText: obscureText, keyboardType: keyboardType, onChanged: onChanged, onSubmitted: onSubmitted, maxLength: maxLength, enabled: enabled, readOnly: readOnly, decoration: InputDecoration( labelText: label, hintText: hint, errorText: errorText, prefixIcon: prefixIcon, suffix: suffix, counterText: '', ), ); } }