You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CoreChecks.has() usage could perhaps be improved #2616
Actually, scratch this - however i didn't realise immediately from the docs that the idiomatic way to write reusable checks was to make extensions e.g.
extensionUriChecksonSubject<Uri> {
Subject<String?> param(String name) =>has((u) => u.queryParameters[name], 'param ${name}');
Subject<String> get host =>has((u) => u.host, 'host');
Subject<String> get path =>has((u) => u.path, 'path');
Subject<String> get scheme =>has((u) => u.scheme, 'scheme');
Subject<String> get value =>has((u) => u.toString(), 'toString value');
}
the docs only mention extensions as ways to create composite or custom checks, maybe this would be a useful addition? thx!
Side-though: Could we swap the parameter order of has so the closure is last?
Generally when a function takes a closure as positional argument, it's the last parameter. That allows big closures, like:
Yes, I am definitely open to changing this. The deciding factor when I first wrote it is that the current order makes autocomplete a bit more useful. I found it handy that I could start typing without even considering what members the object has and once I typed the . it would populate autocomplete with a list of members. This use case is narrow and I hope most uses of has are generated at some point.
Activity
time4tea commentedon Mar 25, 2026
or another example:
time4tea commentedon Apr 6, 2026
Actually, scratch this - however i didn't realise immediately from the docs that the idiomatic way to write reusable checks was to make extensions e.g.
the docs only mention extensions as ways to create composite or custom checks, maybe this would be a useful addition? thx!
jonasfj commentedon Apr 17, 2026
I really think that
package:checksis awesome, but I'll grant that perhaps a few more illustrative examples could be useful.Especially, in the API references where sometimes you forget how to use something.
Proposed: #2631
natebosch commentedon Apr 17, 2026
In addition to improving the docs it would help if I release the codegen I had started looking at around this API.
#2632
lrhn commentedon Jul 22, 2026
Side-though: Could we swap the parameter order of
hasso the closure is last?Generally when a function takes a closure as positional argument, it's the last parameter.
That allows big closures, like:
without the name getting lost.
natebosch commentedon Jul 22, 2026
Yes, I am definitely open to changing this. The deciding factor when I first wrote it is that the current order makes autocomplete a bit more useful. I found it handy that I could start typing without even considering what members the object has and once I typed the
.it would populate autocomplete with a list of members. This use case is narrow and I hope most uses ofhasare generated at some point.Enable incremental migration for argument swap (#2806)
Swap the arguments to `has` (#2758)