magicLength method

int magicLength({
  1. int defaultValue = 0,
})

Returns the length of the value if it is iterable or a map.

  • defaultValue: The value to return if the length cannot be determined or the value is null.

Implementation

int magicLength({int defaultValue = 0}) {
  if (this is Iterable) return (this as Iterable).length;
  if (this is Map) return (this as Map).length;
  return defaultValue;
}