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
if we have a method that has parameters with labels, by default they would be optional, so if they are not specified when the method is called, they would be null.
To also have parameters with labels that are not optional there is the required keyword.
But since non nullability is a thing in dart, a labeled parameter needs to either be nullable without a required keyword or be non nullable and have the required keyword.
But if a parameter is non nullable it is theoretically implicitly required so having the required keyword seems to be very unnecessary In my opinion. And I think the language would be much cleaner without it.
Code example for required labeled parameters:
// Current requiredvoidfoo({requiredString bar});
// Proposed requiredvoidfoo({String bar});
// Optional stays the same:voidfoo({String? bar});
The text was updated successfully, but these errors were encountered:
if we have a method that has parameters with labels, by default they would be optional, so if they are not specified when the method is called, they would be null.
To also have parameters with labels that are not optional there is the
required
keyword.But since non nullability is a thing in dart, a labeled parameter needs to either be nullable without a required keyword or be non nullable and have the required keyword.
But if a parameter is non nullable it is theoretically implicitly required so having the
required
keyword seems to be very unnecessary In my opinion. And I think the language would be much cleaner without it.Code example for required labeled parameters:
The text was updated successfully, but these errors were encountered: