abs method

List<num> abs()

Returns a new list consisting of the absolute value of the elements of this.

Implementation

List<num> abs() {
  if (this is List<int>) {
    return List<int>.generate(length, (i) => (this[i] as int).abs());
  } else if (this is List<double>) {
    return List<double>.generate(length, (i) => (this[i] as double).abs());
  } else {
    return List<num>.generate(length, (i) => this[i].abs());
  }
}