File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,9 @@ enum MaxLengthEnforcement {
8888/// * [FilteringTextInputFormatter] , a provided formatter for filtering
8989/// characters.
9090abstract class TextInputFormatter {
91+ /// This constructor enables subclasses to provide const constructors so that they can be used in const expressions.
92+ const TextInputFormatter ();
93+
9194 /// Called when text is being typed or cut/copy/pasted in the [EditableText] .
9295 ///
9396 /// You can override the resulting text based on the previous text value and
Original file line number Diff line number Diff line change @@ -6,10 +6,26 @@ import 'package:flutter/foundation.dart';
66import 'package:flutter/services.dart' ;
77import 'package:flutter_test/flutter_test.dart' ;
88
9+ class TestTextInputFormatter extends TextInputFormatter {
10+ const TestTextInputFormatter ();
11+
12+ @override
13+ void noSuchMethod (Invocation invocation) {
14+ super .noSuchMethod (invocation);
15+ }
16+ }
17+
918void main () {
1019 TextEditingValue testOldValue = TextEditingValue .empty;
1120 TextEditingValue testNewValue = TextEditingValue .empty;
1221
22+ test ('test const constructor' , () {
23+ const TestTextInputFormatter testValue1 = TestTextInputFormatter ();
24+ const TestTextInputFormatter testValue2 = TestTextInputFormatter ();
25+
26+ expect (testValue1, same (testValue2));
27+ });
28+
1329 test ('withFunction wraps formatting function' , () {
1430 testOldValue = TextEditingValue .empty;
1531 testNewValue = TextEditingValue .empty;
You can’t perform that action at this time.
0 commit comments