ceil function
Returns the smallest integer greater than or equal to value.
- Accepts
int,double, orString. - Strings are parsed via parseDouble before applying
.ceil(). - Returns
nullifvalueisnull. - Throws Exception if
valueis not a supported type.
Example:
ceil(3.2); // -> 4
ceil("7.9"); // -> 8
Implementation
int? ceil(dynamic value) {
if (value == null) return null;
if (value is int) return value;
if (value is double) return value.ceil();
if (value is String) return parseDouble(value)?.ceil();
throw Exception("Invalid value '$value' for 'ceil' function.");
}