1- import 'package:checks/checks.dart' ;
21import 'package:dartx/dartx.dart' ;
32import 'package:flutter/foundation.dart' ;
43import 'package:flutter/widgets.dart' ;
@@ -40,14 +39,15 @@ extension DiagnosticPropWidgetSelector<W extends Widget> on WidgetSelector<W> {
4039 String propName,
4140 MatchProp <T > match,
4241 ) {
43- final ConditionSubject <T > nameSubject = it ();
44- nameSubject.context.nest <T >(
45- () => ['with prop "$propName "' ],
46- (value) => Extracted .value (value),
47- );
48- match (nameSubject);
49- final name =
50- describe (nameSubject).map ((it) => it.trim ()).toList ().join (' ' );
42+ void condition (Subject <T ?> subject) {
43+ subject.hideNullability ().context.nest <T >(
44+ () => ['with prop "$propName "' ],
45+ (value) => Extracted .value (value),
46+ );
47+ match (subject.hideNullability ());
48+ }
49+
50+ final name = describe (condition).map ((it) => it.trim ()).toList ().join (' ' );
5151
5252 return whereElement (
5353 (element) {
@@ -60,29 +60,31 @@ extension DiagnosticPropWidgetSelector<W extends Widget> on WidgetSelector<W> {
6060 overrideQuantityConstraint (QuantityConstraint .unconstrained);
6161 final actual = prop? .value as T ? ?? prop? .getDefaultValue <T >();
6262
63- final ConditionSubject <T ?> conditionSubject = it <T ?>();
64- final Subject <T > subject = conditionSubject.context.nest <T >(
65- () => [
66- unconstrainedSelector.toStringBreadcrumb (),
67- 'with prop "$propName "' ,
68- ],
69- (value) {
70- if (prop == null ) {
71- return Extracted .rejection (which: ['Has no prop "$propName "' ]);
72- }
73- if (value is ! T ) {
74- return Extracted .rejection (
75- which: [
76- 'Has no prop "$propName " of type "$T ", the type is "${prop .value .runtimeType }"' ,
77- ],
78- );
79- }
63+ void condition (Subject <T ?> subject) {
64+ subject.context.nest <T >(
65+ () => [
66+ unconstrainedSelector.toStringBreadcrumb (),
67+ 'with prop "$propName "' ,
68+ ],
69+ (value) {
70+ if (prop == null ) {
71+ return Extracted .rejection (which: ['Has no prop "$propName "' ]);
72+ }
73+ if (value is ! T ) {
74+ return Extracted .rejection (
75+ which: [
76+ 'Has no prop "$propName " of type "$T ", the type is "${prop .value .runtimeType }"' ,
77+ ],
78+ );
79+ }
80+
81+ return Extracted .value (actual as T );
82+ },
83+ );
84+ match (subject.hideNullability ());
85+ }
8086
81- return Extracted .value (actual as T );
82- },
83- );
84- match (subject);
85- final failure = softCheckHideNull (actual, conditionSubject);
87+ final failure = softCheckHideNull (actual, condition);
8688 if (failure != null ) {
8789 return false ;
8890 }
@@ -128,29 +130,31 @@ extension DiagnosticPropWidgetMatcher<W extends Widget> on WidgetMatcher<W> {
128130 selector.overrideQuantityConstraint (QuantityConstraint .unconstrained);
129131 final actual = prop? .value as T ? ?? prop? .getDefaultValue <T >();
130132
131- final ConditionSubject <T ?> conditionSubject = it <T ?>();
132- final Subject <T > subject = conditionSubject.context.nest <T >(
133- () => [
134- unconstrainedSelector.toStringBreadcrumb (),
135- 'with property $propName ' ,
136- ],
137- (value) {
138- if (prop == null ) {
139- return Extracted .rejection (which: ['Has no prop "$propName "' ]);
140- }
141- if (value is ! T ) {
142- return Extracted .rejection (
143- which: [
144- 'Has no prop "$propName " of type "$T ", the type is "${prop .value .runtimeType }"' ,
145- ],
146- );
147- }
148- return Extracted .value (value);
149- },
150- );
151- match (subject);
152- final failure = softCheckHideNull (actual, conditionSubject);
153- failure.throwPropertyCheckFailure (conditionSubject, element);
133+ void condition (Subject <T ?> subject) {
134+ subject.context.nest <T >(
135+ () => [
136+ unconstrainedSelector.toStringBreadcrumb (),
137+ 'with property $propName ' ,
138+ ],
139+ (value) {
140+ if (prop == null ) {
141+ return Extracted .rejection (which: ['Has no prop "$propName "' ]);
142+ }
143+ if (value is ! T ) {
144+ return Extracted .rejection (
145+ which: [
146+ 'Has no prop "$propName " of type "$T ", the type is "${prop .value .runtimeType }"' ,
147+ ],
148+ );
149+ }
150+ return Extracted .value (value);
151+ },
152+ );
153+ match (subject.hideNullability ());
154+ }
155+
156+ final failure = softCheckHideNull (actual, condition);
157+ failure.throwPropertyCheckFailure (condition, element);
154158 return this ;
155159 }
156160}
0 commit comments