@@ -194,10 +194,10 @@ class CupertinoTextField extends StatefulWidget {
194194 /// must not be null.
195195 ///
196196 /// The [autocorrect] , [autofocus] , [clearButtonMode] , [dragStartBehavior] ,
197- /// [expands] , [obscureText ] , [prefixMode ] , [readOnly ] , [scrollPadding ] ,
198- /// [suffixMode ] , [textAlign ] , [selectionHeightStyle ] , [selectionWidthStyle ] ,
199- /// [enableSuggestions] , and [enableIMEPersonalizedLearning] properties must
200- /// not be null.
197+ /// [expands] , [maxLengthEnforced ] , [obscureText ] , [prefixMode ] , [readOnly ] ,
198+ /// [scrollPadding ] , [suffixMode ] , [textAlign ] , [selectionHeightStyle ] ,
199+ /// [selectionWidthStyle] , [ enableSuggestions] , and [enableIMEPersonalizedLearning]
200+ /// properties must not be null.
201201 ///
202202 /// See also:
203203 ///
@@ -244,6 +244,12 @@ class CupertinoTextField extends StatefulWidget {
244244 this .minLines,
245245 this .expands = false ,
246246 this .maxLength,
247+ @Deprecated (
248+ 'Use maxLengthEnforcement parameter which provides more specific '
249+ 'behavior related to the maxLength limit. '
250+ 'This feature was deprecated after v1.25.0-5.0.pre.' ,
251+ )
252+ this .maxLengthEnforced = true ,
247253 this .maxLengthEnforcement,
248254 this .onChanged,
249255 this .onEditingComplete,
@@ -278,6 +284,11 @@ class CupertinoTextField extends StatefulWidget {
278284 smartDashesType = smartDashesType ?? (obscureText ? SmartDashesType .disabled : SmartDashesType .enabled),
279285 smartQuotesType = smartQuotesType ?? (obscureText ? SmartQuotesType .disabled : SmartQuotesType .enabled),
280286 assert (enableSuggestions != null ),
287+ assert (maxLengthEnforced != null ),
288+ assert (
289+ maxLengthEnforced || maxLengthEnforcement == null ,
290+ 'maxLengthEnforced is deprecated, use only maxLengthEnforcement' ,
291+ ),
281292 assert (scrollPadding != null ),
282293 assert (dragStartBehavior != null ),
283294 assert (selectionHeightStyle != null ),
@@ -359,9 +370,9 @@ class CupertinoTextField extends StatefulWidget {
359370 /// must not be null.
360371 ///
361372 /// The [autocorrect] , [autofocus] , [clearButtonMode] , [dragStartBehavior] ,
362- /// [expands] , [obscureText ] , [prefixMode ] , [readOnly ] , [scrollPadding ] ,
363- /// [suffixMode ] , [textAlign ] , [selectionHeightStyle ] , [selectionWidthStyle ] ,
364- /// and [enableSuggestions] properties must not be null.
373+ /// [expands] , [maxLengthEnforced ] , [obscureText ] , [prefixMode ] , [readOnly ] ,
374+ /// [scrollPadding ] , [suffixMode ] , [textAlign ] , [selectionHeightStyle ] ,
375+ /// [selectionWidthStyle] , and [enableSuggestions] properties must not be null.
365376 ///
366377 /// See also:
367378 ///
@@ -405,6 +416,12 @@ class CupertinoTextField extends StatefulWidget {
405416 this .minLines,
406417 this .expands = false ,
407418 this .maxLength,
419+ @Deprecated (
420+ 'Use maxLengthEnforcement parameter which provides more specific '
421+ 'behavior related to the maxLength limit. '
422+ 'This feature was deprecated after v1.25.0-5.0.pre.' ,
423+ )
424+ this .maxLengthEnforced = true ,
408425 this .maxLengthEnforcement,
409426 this .onChanged,
410427 this .onEditingComplete,
@@ -439,6 +456,11 @@ class CupertinoTextField extends StatefulWidget {
439456 smartDashesType = smartDashesType ?? (obscureText ? SmartDashesType .disabled : SmartDashesType .enabled),
440457 smartQuotesType = smartQuotesType ?? (obscureText ? SmartQuotesType .disabled : SmartQuotesType .enabled),
441458 assert (enableSuggestions != null ),
459+ assert (maxLengthEnforced != null ),
460+ assert (
461+ maxLengthEnforced || maxLengthEnforcement == null ,
462+ 'maxLengthEnforced is deprecated, use only maxLengthEnforcement' ,
463+ ),
442464 assert (scrollPadding != null ),
443465 assert (dragStartBehavior != null ),
444466 assert (selectionHeightStyle != null ),
@@ -666,6 +688,18 @@ class CupertinoTextField extends StatefulWidget {
666688 /// {@macro flutter.services.lengthLimitingTextInputFormatter.maxLength}
667689 final int ? maxLength;
668690
691+ /// If [maxLength] is set, [maxLengthEnforced] indicates whether or not to
692+ /// enforce the limit.
693+ ///
694+ /// If true, prevents the field from allowing more than [maxLength]
695+ /// characters.
696+ @Deprecated (
697+ 'Use maxLengthEnforcement parameter which provides more specific '
698+ 'behavior related to the maxLength limit. '
699+ 'This feature was deprecated after v1.25.0-5.0.pre.' ,
700+ )
701+ final bool maxLengthEnforced;
702+
669703 /// Determines how the [maxLength] limit should be enforced.
670704 ///
671705 /// If [MaxLengthEnforcement.none] is set, additional input beyond [maxLength]
@@ -804,6 +838,7 @@ class CupertinoTextField extends StatefulWidget {
804838 properties.add (IntProperty ('minLines' , minLines, defaultValue: null ));
805839 properties.add (DiagnosticsProperty <bool >('expands' , expands, defaultValue: false ));
806840 properties.add (IntProperty ('maxLength' , maxLength, defaultValue: null ));
841+ properties.add (FlagProperty ('maxLengthEnforced' , value: maxLengthEnforced, ifTrue: 'max length enforced' ));
807842 properties.add (EnumProperty <MaxLengthEnforcement >('maxLengthEnforcement' , maxLengthEnforcement, defaultValue: null ));
808843 properties.add (DoubleProperty ('cursorWidth' , cursorWidth, defaultValue: 2.0 ));
809844 properties.add (DoubleProperty ('cursorHeight' , cursorHeight, defaultValue: null ));
@@ -1157,7 +1192,7 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio
11571192 final Offset cursorOffset = Offset (_iOSHorizontalCursorOffsetPixels / MediaQuery .of (context).devicePixelRatio, 0 );
11581193 final List <TextInputFormatter > formatters = < TextInputFormatter > [
11591194 ...? widget.inputFormatters,
1160- if (widget.maxLength != null )
1195+ if (widget.maxLength != null && widget.maxLengthEnforced )
11611196 LengthLimitingTextInputFormatter (
11621197 widget.maxLength,
11631198 maxLengthEnforcement: _effectiveMaxLengthEnforcement,
0 commit comments