MTextController constructor

MTextController({
  1. String? name,
  2. required int maxInput,
  3. bool mustInput = true,
  4. String? defText,
})

Implementation

MTextController(
    {this.name,
    required this.maxInput,
    this.mustInput = true,
    String? defText}) {
  if (GetUtils.isNullOrBlank(defText)?.not() ?? false) {
    text = defText!;
  }
  this.addListener(() {
    if (this.text.length > maxInput) {
      this.text = this.text.substring(0, maxInput);
      this.selection =
          TextSelection.fromPosition(TextPosition(offset: this.text.length));
      mShowCustomToast('Please enter less than $maxInput characters');
    }
  });
}