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
This is to support a common use case: devs often want to pass either Uri orString to such methods. In the end, all String values are "upgraded"
to Uri before use. To support the desired flexibility, the user risks
runtime errors if something other than String or Uri are provided.
Flutter avoids this issue, by being explicit about types everywhere.
// FluttervoidgiveMeABorder(BorderRadiusGeometry value) {}
voiddoWork() {
giveMeABorder(constBorderRadius.all(
Radius.circular(18),
));
// User would like to write this, but...giveMeABorder(18); // static error
}
Every place in
pkg:http
with aurl
parameter types it asdynamic
.This is to support a common use case: devs often want to pass either
Uri
or
String
to such methods. In the end, allString
values are "upgraded"to
Uri
before use. To support the desired flexibility, the user risksruntime errors if something other than
String
orUri
are provided.Flutter avoids this issue, by being explicit about types everywhere.
The existing request(s) for union types – https://github.com/dart-lang/sdk/issues/4938 and #83 – could be an option here, but it would require updating all parameters and setters to specify the supported types.
It'd be nice to be able to define explicit conversions so one could easily pass
String
to properties/params requiringUri
, etc.The text was updated successfully, but these errors were encountered: