浏览代码

Update.

/main
Yuncong Zhang 5 年前
当前提交
78a53637
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 4
      Runtime/service/text_formatter.cs

4
Runtime/service/text_formatter.cs


public class LengthLimitingTextInputFormatter : TextInputFormatter {
public LengthLimitingTextInputFormatter(int? maxLength) {
D.assert(maxLength == null || maxLength > 0);
D.assert(maxLength == null || maxLength == -1 || maxLength > 0);
this.maxLength = maxLength;
}

if (this.maxLength != null && newValue.text.Length > this.maxLength) {
if (this.maxLength != null && this.maxLength > 0 && newValue.text.Length > this.maxLength) {
TextSelection newSelection = newValue.selection.copyWith(
baseOffset: Math.Min(newValue.selection.start, this.maxLength.Value),
extentOffset: Math.Min(newValue.selection.end, this.maxLength.Value)

正在加载...
取消
保存