remainder function Null safety

int remainder(
  1. int input,
  2. int? source
)

Returns the remainder of the modulo operation input % source, and adjust it for negative values.

Implementation

int remainder(int input, int? source) {
  if (source == 0) return 0;
  final int result = input % source!;
  return result < 0 ? source + result : result;
}