Template
Core 基础设施:Flavor 三包体系、Drift+SQLCipher 加密数据库 7 拦截器 Dio 网络栈、CrashReporter 崩溃日志、Sealed Failure 错误体系 5 色板主题系统、Auth 认证骨架(Clean Architecture)、Dev Panel、Mock Adapter 通过验证:flutter analyze(0 errors)、flutter test(全绿)、staging APK 74.8MB
61 lines
1.4 KiB
Dart
61 lines
1.4 KiB
Dart
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<String>? onChanged;
|
|
final ValueChanged<String>? 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: '',
|
|
),
|
|
);
|
|
}
|
|
}
|