getInputFormatters method

List<TextInputFormatter> getInputFormatters(
  1. String fieldName
)

Implementation

List<TextInputFormatter> getInputFormatters(String fieldName) {
  final editorItem = getEditorItemByFieldName(fieldName);
  if (editorItem == null) return <TextInputFormatter>[];
  switch (editorItem.type) {
    case EEditorType.int:
      return <TextInputFormatter>[
        FilteringTextInputFormatter.digitsOnly,
      ];
    case EEditorType.money:
      return <TextInputFormatter>[
        FilteringTextInputFormatter.digitsOnly,
        PriceInputFormatter(),
      ];
    case EEditorType.phone:
      return <TextInputFormatter>[
        FilteringTextInputFormatter.allow(RegExp(r'[0-9+]')),
      ];
    case EEditorType.name:
      return <TextInputFormatter>[
        FilteringTextInputFormatter.allow(
          RegExp(
              '[a-zA-Z_ÀÁÂÃÈÉÊÌÍÒÓÔÕÙÚĂĐĨŨƠàáâãèéêìíòóôõùúăđĩũơƯĂẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼỀỀỂưăạảấầẩẫậắằẳẵặẹẻẽềềểỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪễếệỉịọỏốồổỗộớờởỡợụủứừỬỮỰỲỴÝỶỸửữựỳỵỷỹý  \t]'),
        ),
      ];
    case EEditorType.double:
      return <TextInputFormatter>[
        FilteringTextInputFormatter.allow(RegExp('[0-9.,]'))
      ];
    case EEditorType.email:
    case EEditorType.datetime:
    case EEditorType.bool:
    case EEditorType.image:
    case EEditorType.string:
    default:
      return <TextInputFormatter>[];
  }
}