PPTextField constructor

const PPTextField({
  1. Key? key,
  2. required TextEditingController controller,
  3. required String labelText,
  4. TextStyle labelStyle = const TextStyle(color: Colors.grey, fontSize: 18),
  5. Color fillColor = const Color(0xFFEEEEEE),
  6. double borderRadius = 12.0,
  7. BorderSide borderSide = BorderSide.none,
  8. BorderSide focusedBorderSide = const BorderSide(color: Colors.blue, width: 1.0),
  9. BorderSide errorBorderSide = const BorderSide(color: Colors.red, width: 1.0),
  10. Color clearColor = const Color(0xFFBDBDBD),
  11. int maxLength = 50,
  12. bool showCounter = false,
})

Implementation

const PPTextField({
  super.key,
  required this.controller,
  required this.labelText,
  this.labelStyle = const TextStyle(color: Colors.grey, fontSize: 18),
  this.fillColor = const Color(0xFFEEEEEE), // 默认灰色背景
  this.borderRadius = 12.0,
  this.borderSide = BorderSide.none,
  this.focusedBorderSide =
      const BorderSide(color: Colors.blue, width: 1.0), // 聚焦时的边框样式
  this.errorBorderSide =
      const BorderSide(color: Colors.red, width: 1.0), // 错误时的边框样式
  this.clearColor = const Color(0xFFBDBDBD), // 默认灰色取消按钮
  this.maxLength = 50, // 新增的最大长度属性
  this.showCounter = false, // 默认不显示计数器
});