File tree 2 files changed +19
-0
lines changed 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,9 @@ enum MaxLengthEnforcement {
88
88
/// * [FilteringTextInputFormatter] , a provided formatter for filtering
89
89
/// characters.
90
90
abstract class TextInputFormatter {
91
+ /// This constructor enables subclasses to provide const constructors so that they can be used in const expressions.
92
+ const TextInputFormatter ();
93
+
91
94
/// Called when text is being typed or cut/copy/pasted in the [EditableText] .
92
95
///
93
96
/// 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';
6
6
import 'package:flutter/services.dart' ;
7
7
import 'package:flutter_test/flutter_test.dart' ;
8
8
9
+ class TestTextInputFormatter extends TextInputFormatter {
10
+ const TestTextInputFormatter ();
11
+
12
+ @override
13
+ void noSuchMethod (Invocation invocation) {
14
+ super .noSuchMethod (invocation);
15
+ }
16
+ }
17
+
9
18
void main () {
10
19
TextEditingValue testOldValue = TextEditingValue .empty;
11
20
TextEditingValue testNewValue = TextEditingValue .empty;
12
21
22
+ test ('test const constructor' , () {
23
+ const TestTextInputFormatter testValue1 = TestTextInputFormatter ();
24
+ const TestTextInputFormatter testValue2 = TestTextInputFormatter ();
25
+
26
+ expect (testValue1, same (testValue2));
27
+ });
28
+
13
29
test ('withFunction wraps formatting function' , () {
14
30
testOldValue = TextEditingValue .empty;
15
31
testNewValue = TextEditingValue .empty;
You can’t perform that action at this time.
0 commit comments