@@ -220,7 +220,12 @@ void main() {
220220 );
221221
222222 RichText text = tester.widget (find.byType (RichText ));
223- expect (text.text.style! .fontVariations, < FontVariation > []);
223+ expect (text.text.style! .fontVariations, < FontVariation > [
224+ const FontVariation ('FILL' , 0.0 ),
225+ const FontVariation ('wght' , 400.0 ),
226+ const FontVariation ('GRAD' , 0.0 ),
227+ const FontVariation ('opsz' , 48.0 )
228+ ]);
224229
225230 await tester.pumpWidget (
226231 const Directionality (
@@ -239,6 +244,57 @@ void main() {
239244 ]);
240245 });
241246
247+ testWidgets ('Fill, weight, grade, and optical size can be set at the theme-level' , (WidgetTester tester) async {
248+ await tester.pumpWidget (
249+ const Directionality (
250+ textDirection: TextDirection .ltr,
251+ child: IconTheme (
252+ data: IconThemeData (
253+ fill: 0.2 ,
254+ weight: 3.0 ,
255+ grade: 4.0 ,
256+ opticalSize: 5.0 ,
257+ ),
258+ child: Icon (Icons .abc),
259+ ),
260+ ),
261+ );
262+
263+ final RichText text = tester.widget (find.byType (RichText ));
264+ expect (text.text.style! .fontVariations, < FontVariation > [
265+ const FontVariation ('FILL' , 0.2 ),
266+ const FontVariation ('wght' , 3.0 ),
267+ const FontVariation ('GRAD' , 4.0 ),
268+ const FontVariation ('opsz' , 5.0 )
269+ ]);
270+ });
271+
272+ testWidgets ('Theme-level fill, weight, grade, and optical size can be overriden' , (WidgetTester tester) async {
273+ await tester.pumpWidget (
274+ const Directionality (
275+ textDirection: TextDirection .ltr,
276+ child: IconTheme (
277+ data: IconThemeData (
278+ fill: 0.2 ,
279+ weight: 3.0 ,
280+ grade: 4.0 ,
281+ opticalSize: 5.0 ,
282+ ),
283+ child: Icon (Icons .abc, fill: 0.6 , weight: 7.0 , grade: 8.0 , opticalSize: 9.0 ),
284+ ),
285+ ),
286+ );
287+
288+ final RichText text = tester.widget (find.byType (RichText ));
289+ expect (text.text.style! .fontVariations, isNotNull);
290+ expect (text.text.style! .fontVariations, < FontVariation > [
291+ const FontVariation ('FILL' , 0.6 ),
292+ const FontVariation ('wght' , 7.0 ),
293+ const FontVariation ('GRAD' , 8.0 ),
294+ const FontVariation ('opsz' , 9.0 )
295+ ]);
296+ });
297+
242298 test ('Throws if given invalid values' , () {
243299 expect (() => Icon (Icons .abc, fill: - 0.1 ), throwsAssertionError);
244300 expect (() => Icon (Icons .abc, fill: 1.1 ), throwsAssertionError);
0 commit comments