validate method
Validates the double value and returns it if not null.
If the value is null
, returns the specified value
(default is 0.0
).
Example:
double? value1;
double? value2 = 3.14;
print(value1.validate()); // Output: 0.0
print(value1.validate(value: 1.5)); // Output: 1.5
print(value2.validate()); // Output: 3.14
Implementation
double validate({double value = 0.0}) => this ?? value;