@@ -41,20 +41,20 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
41
41
@override
42
42
BorderSide? get activeIndicatorBorder => MaterialStateBorderSide.resolveWith((Set<MaterialState> states) {
43
43
if (states.contains(MaterialState.error)) {
44
+ if (states.contains(MaterialState.focused)) {
45
+ return ${mergedBorder ('md.comp.filled-text-field.error.focus.active-indicator' ,'md.comp.filled-text-field.focus.active-indicator' )};
46
+ }
44
47
if (states.contains(MaterialState.hovered)) {
45
48
return ${border ('md.comp.filled-text-field.error.hover.active-indicator' )};
46
- }${border ('md.comp.filled-text-field.error.focus.active-indicator' ) == border ('md.comp.filled-text-field.error.active-indicator' ) ? '' : '''
47
- if (states.contains(MaterialState.focused)) {
48
- return ${border ('md.comp.filled-text-field.error.focus.active-indicator' )};
49
- }''' }
49
+ }
50
50
return ${border ('md.comp.filled-text-field.error.active-indicator' )};
51
51
}
52
- if (states.contains(MaterialState.hovered)) {
53
- return ${border ('md.comp.filled-text-field.hover.active-indicator' )};
54
- }
55
52
if (states.contains(MaterialState.focused)) {
56
53
return ${border ('md.comp.filled-text-field.focus.active-indicator' )};
57
54
}
55
+ if (states.contains(MaterialState.hovered)) {
56
+ return ${border ('md.comp.filled-text-field.hover.active-indicator' )};
57
+ }
58
58
if (states.contains(MaterialState.disabled)) {
59
59
return ${border ('md.comp.filled-text-field.disabled.active-indicator' )};
60
60
}
@@ -64,20 +64,20 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
64
64
@override
65
65
BorderSide? get outlineBorder => MaterialStateBorderSide.resolveWith((Set<MaterialState> states) {
66
66
if (states.contains(MaterialState.error)) {
67
+ if (states.contains(MaterialState.focused)) {
68
+ return ${mergedBorder ('md.comp.outlined-text-field.error.focus.outline' ,'md.comp.outlined-text-field.focus.outline' )};
69
+ }
67
70
if (states.contains(MaterialState.hovered)) {
68
71
return ${border ('md.comp.outlined-text-field.error.hover.outline' )};
69
- }${border ('md.comp.outlined-text-field.error.focus.outline' ) == border ('md.comp.outlined-text-field.error.outline' ) ? '' : '''
70
- if (states.contains(MaterialState.focused)) {
71
- return ${border ('md.comp.outlined-text-field.error.focus.outline' )};
72
- }''' }
72
+ }
73
73
return ${border ('md.comp.outlined-text-field.error.outline' )};
74
74
}
75
- if (states.contains(MaterialState.hovered)) {
76
- return ${border ('md.comp.outlined-text-field.hover.outline' )};
77
- }
78
75
if (states.contains(MaterialState.focused)) {
79
76
return ${border ('md.comp.outlined-text-field.focus.outline' )};
80
77
}
78
+ if (states.contains(MaterialState.hovered)) {
79
+ return ${border ('md.comp.outlined-text-field.hover.outline' )};
80
+ }
81
81
if (states.contains(MaterialState.disabled)) {
82
82
return ${border ('md.comp.outlined-text-field.disabled.outline' )};
83
83
}
@@ -90,19 +90,19 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
90
90
@override
91
91
Color? get prefixIconColor => MaterialStateColor.resolveWith((Set<MaterialState> states) {${componentColor ('md.comp.filled-text-field.error.leading-icon' ) == componentColor ('md.comp.filled-text-field.leading-icon' ) ? '' : '''
92
92
if(states.contains(MaterialState.error)) {
93
- if (states.contains(MaterialState.hovered)) {
94
- return ${componentColor ('md.comp.filled-text-field.error.hover.leading-icon' )};
95
- }
96
93
if (states.contains(MaterialState.focused)) {
97
94
return ${componentColor ('md.comp.filled-text-field.error.focus.leading-icon' )};
98
95
}
96
+ if (states.contains(MaterialState.hovered)) {
97
+ return ${componentColor ('md.comp.filled-text-field.error.hover.leading-icon' )};
98
+ }
99
99
return ${componentColor ('md.comp.filled-text-field.error.leading-icon' )};
100
- }''' }${componentColor ('md.comp.filled-text-field.hover.leading-icon' ) == componentColor ('md.comp.filled-text-field.leading-icon' ) ? '' : '''
101
- if (states.contains(MaterialState.hovered)) {
102
- return ${componentColor ('md.comp.filled-text-field.hover.leading-icon' )};
103
100
}''' }${componentColor ('md.comp.filled-text-field.focus.leading-icon' ) == componentColor ('md.comp.filled-text-field.leading-icon' ) ? '' : '''
104
101
if (states.contains(MaterialState.focused)) {
105
102
return ${componentColor ('md.comp.filled-text-field.focus.leading-icon' )};
103
+ }''' }${componentColor ('md.comp.filled-text-field.hover.leading-icon' ) == componentColor ('md.comp.filled-text-field.leading-icon' ) ? '' : '''
104
+ if (states.contains(MaterialState.hovered)) {
105
+ return ${componentColor ('md.comp.filled-text-field.hover.leading-icon' )};
106
106
}''' }
107
107
if (states.contains(MaterialState.disabled)) {
108
108
return ${componentColor ('md.comp.filled-text-field.disabled.leading-icon' )};
@@ -112,20 +112,20 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
112
112
113
113
@override
114
114
Color? get suffixIconColor => MaterialStateColor.resolveWith((Set<MaterialState> states) {
115
- if(states.contains(MaterialState.error)) {
116
- if (states.contains(MaterialState.hovered)) {
117
- return ${componentColor ('md.comp.filled-text-field.error.hover.trailing-icon' )};
118
- }${componentColor ('md.comp.filled-text-field.error.trailing-icon' ) == componentColor ('md.comp.filled-text-field.error.focus.trailing-icon' ) ? '' : '''
115
+ if(states.contains(MaterialState.error)) {${componentColor ('md.comp.filled-text-field.error.trailing-icon' ) == componentColor ('md.comp.filled-text-field.error.focus.trailing-icon' ) ? '' : '''
119
116
if (states.contains(MaterialState.focused)) {
120
117
return ${componentColor ('md.comp.filled-text-field.error.focus.trailing-icon' )};
121
118
}''' }
119
+ if (states.contains(MaterialState.hovered)) {
120
+ return ${componentColor ('md.comp.filled-text-field.error.hover.trailing-icon' )};
121
+ }
122
122
return ${componentColor ('md.comp.filled-text-field.error.trailing-icon' )};
123
- }${componentColor ('md.comp.filled-text-field.hover.trailing-icon' ) == componentColor ('md.comp.filled-text-field.trailing-icon' ) ? '' : '''
124
- if (states.contains(MaterialState.hovered)) {
125
- return ${componentColor ('md.comp.filled-text-field.hover.trailing-icon' )};
126
- }''' }${componentColor ('md.comp.filled-text-field.focus.trailing-icon' ) == componentColor ('md.comp.filled-text-field.trailing-icon' ) ? '' : '''
123
+ }${componentColor ('md.comp.filled-text-field.focus.trailing-icon' ) == componentColor ('md.comp.filled-text-field.trailing-icon' ) ? '' : '''
127
124
if (states.contains(MaterialState.focused)) {
128
125
return ${componentColor ('md.comp.filled-text-field.focus.trailing-icon' )};
126
+ }''' }${componentColor ('md.comp.filled-text-field.hover.trailing-icon' ) == componentColor ('md.comp.filled-text-field.trailing-icon' ) ? '' : '''
127
+ if (states.contains(MaterialState.hovered)) {
128
+ return ${componentColor ('md.comp.filled-text-field.hover.trailing-icon' )};
129
129
}''' }
130
130
if (states.contains(MaterialState.disabled)) {
131
131
return ${componentColor ('md.comp.filled-text-field.disabled.trailing-icon' )};
@@ -137,20 +137,20 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
137
137
TextStyle? get labelStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
138
138
final TextStyle textStyle= ${textStyle ("md.comp.filled-text-field.label-text" )} ?? const TextStyle();
139
139
if(states.contains(MaterialState.error)) {
140
- if (states.contains(MaterialState.hovered)) {
141
- return textStyle.copyWith(color:${componentColor ('md.comp.filled-text-field.error.hover.label-text' )});
142
- }
143
140
if (states.contains(MaterialState.focused)) {
144
141
return textStyle.copyWith(color:${componentColor ('md.comp.filled-text-field.error.focus.label-text' )});
145
142
}
143
+ if (states.contains(MaterialState.hovered)) {
144
+ return textStyle.copyWith(color:${componentColor ('md.comp.filled-text-field.error.hover.label-text' )});
145
+ }
146
146
return textStyle.copyWith(color:${componentColor ('md.comp.filled-text-field.error.label-text' )});
147
147
}
148
- if (states.contains(MaterialState.hovered)) {
149
- return textStyle.copyWith(color:${componentColor ('md.comp.filled-text-field.hover.label-text' )});
150
- }
151
148
if (states.contains(MaterialState.focused)) {
152
149
return textStyle.copyWith(color:${componentColor ('md.comp.filled-text-field.focus.label-text' )});
153
150
}
151
+ if (states.contains(MaterialState.hovered)) {
152
+ return textStyle.copyWith(color:${componentColor ('md.comp.filled-text-field.hover.label-text' )});
153
+ }
154
154
if (states.contains(MaterialState.disabled)) {
155
155
return textStyle.copyWith(color:${componentColor ('md.comp.filled-text-field.disabled.label-text' )});
156
156
}
@@ -161,20 +161,20 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
161
161
TextStyle? get floatingLabelStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
162
162
final TextStyle textStyle= ${textStyle ("md.comp.filled-text-field.label-text" )} ?? const TextStyle();
163
163
if(states.contains(MaterialState.error)) {
164
- if (states.contains(MaterialState.hovered)) {
165
- return textStyle.copyWith(color:${componentColor ('md.comp.filled-text-field.error.hover.label-text' )});
166
- }
167
164
if (states.contains(MaterialState.focused)) {
168
165
return textStyle.copyWith(color:${componentColor ('md.comp.filled-text-field.error.focus.label-text' )});
169
166
}
167
+ if (states.contains(MaterialState.hovered)) {
168
+ return textStyle.copyWith(color:${componentColor ('md.comp.filled-text-field.error.hover.label-text' )});
169
+ }
170
170
return textStyle.copyWith(color:${componentColor ('md.comp.filled-text-field.error.label-text' )});
171
171
}
172
- if (states.contains(MaterialState.hovered)) {
173
- return textStyle.copyWith(color:${componentColor ('md.comp.filled-text-field.hover.label-text' )});
174
- }
175
172
if (states.contains(MaterialState.focused)) {
176
173
return textStyle.copyWith(color:${componentColor ('md.comp.filled-text-field.focus.label-text' )});
177
174
}
175
+ if (states.contains(MaterialState.hovered)) {
176
+ return textStyle.copyWith(color:${componentColor ('md.comp.filled-text-field.hover.label-text' )});
177
+ }
178
178
if (states.contains(MaterialState.disabled)) {
179
179
return textStyle.copyWith(color:${componentColor ('md.comp.filled-text-field.disabled.label-text' )});
180
180
}
@@ -183,12 +183,12 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
183
183
184
184
@override
185
185
TextStyle? get helperStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
186
- final TextStyle textStyle= ${textStyle ("md.comp.filled-text-field.supporting-text" )} ?? const TextStyle();${componentColor ('md.comp.filled-text-field.hover.supporting-text' ) == componentColor ('md.comp.filled-text-field.supporting-text' ) ? '' : '''
187
- if (states.contains(MaterialState.hovered)) {
188
- return textStyle.copyWith(color:${componentColor ('md.comp.filled-text-field.hover.supporting-text' )});
189
- }''' }${componentColor ('md.comp.filled-text-field.focus.supporting-text' ) == componentColor ('md.comp.filled-text-field.supporting-text' ) ? '' : '''
186
+ final TextStyle textStyle= ${textStyle ("md.comp.filled-text-field.supporting-text" )} ?? const TextStyle();${componentColor ('md.comp.filled-text-field.focus.supporting-text' ) == componentColor ('md.comp.filled-text-field.supporting-text' ) ? '' : '''
190
187
if (states.contains(MaterialState.focused)) {
191
188
return textStyle.copyWith(color:${componentColor ('md.comp.filled-text-field.focus.supporting-text' )});
189
+ }''' }${componentColor ('md.comp.filled-text-field.hover.supporting-text' ) == componentColor ('md.comp.filled-text-field.supporting-text' ) ? '' : '''
190
+ if (states.contains(MaterialState.hovered)) {
191
+ return textStyle.copyWith(color:${componentColor ('md.comp.filled-text-field.hover.supporting-text' )});
192
192
}''' }
193
193
if (states.contains(MaterialState.disabled)) {
194
194
return textStyle.copyWith(color:${componentColor ('md.comp.filled-text-field.disabled.supporting-text' )});
@@ -198,15 +198,29 @@ class _${blockName}DefaultsM3 extends InputDecorationTheme {
198
198
199
199
@override
200
200
TextStyle? get errorStyle => MaterialStateTextStyle.resolveWith((Set<MaterialState> states) {
201
- final TextStyle textStyle= ${textStyle ("md.comp.filled-text-field.supporting-text" )} ?? const TextStyle();${componentColor ('md.comp.filled-text-field.error.hover.supporting-text' ) == componentColor ('md.comp.filled-text-field.error.supporting-text' ) ? '' : '''
202
- if (states.contains(MaterialState.hovered)) {
203
- return textStyle.copyWith(color:${componentColor ('md.comp.filled-text-field.error.hover.supporting-text' )});
204
- }''' }${componentColor ('md.comp.filled-text-field.error.focus.supporting-text' ) == componentColor ('md.comp.filled-text-field.error.supporting-text' ) ? '' : '''
201
+ final TextStyle textStyle= ${textStyle ("md.comp.filled-text-field.supporting-text" )} ?? const TextStyle();${componentColor ('md.comp.filled-text-field.error.focus.supporting-text' ) == componentColor ('md.comp.filled-text-field.error.supporting-text' ) ? '' : '''
205
202
if (states.contains(MaterialState.focused)) {
206
203
return textStyle.copyWith(color:${componentColor ('md.comp.filled-text-field.error.focus.supporting-text' )});
204
+ }''' }${componentColor ('md.comp.filled-text-field.error.hover.supporting-text' ) == componentColor ('md.comp.filled-text-field.error.supporting-text' ) ? '' : '''
205
+ if (states.contains(MaterialState.hovered)) {
206
+ return textStyle.copyWith(color:${componentColor ('md.comp.filled-text-field.error.hover.supporting-text' )});
207
207
}''' }
208
208
return textStyle.copyWith(color:${componentColor ('md.comp.filled-text-field.error.supporting-text' )});
209
209
});
210
210
}
211
211
''' ;
212
+
213
+ /// Generate a [BorderSide] for the given components.
214
+ String mergedBorder (String componentToken1, String componentToken2) {
215
+ final String borderColor = componentColor (componentToken1)!= 'null'
216
+ ? componentColor (componentToken1)
217
+ : componentColor (componentToken2);
218
+ final double width = (
219
+ tokens['$componentToken1 .width' ] ??
220
+ tokens['$componentToken1 .height' ] ??
221
+ tokens['$componentToken2 .width' ] ??
222
+ tokens['$componentToken2 .height' ] ??
223
+ 1.0 ) as double ;
224
+ return 'BorderSide(color: $borderColor ${width != 1.0 ? ", width: $width " : "" })' ;
225
+ }
212
226
}
0 commit comments