getTimeDifferenceMs method
Calculates the time difference in milliseconds between the current DateTime and another DateTime.
Args: compareTo (DateTime?): The DateTime to compare to. alwaysPositive (bool): If true, the result will always be a positive value. Defaults to true.
Returns:
int?: The time difference in milliseconds, or null if compareTo
is null.
Implementation
int? getTimeDifferenceMs(DateTime? compareTo, {bool alwaysPositive = true}) {
if (compareTo == null) {
return null;
}
final int inMilliseconds = difference(compareTo).inMilliseconds;
return alwaysPositive ? inMilliseconds.abs() : inMilliseconds;
}