optPositiveInt method

int? optPositiveInt(
  1. String name, {
  2. int fallback = -1,
  3. bool remove = false,
})

Returns the value mapped by name if it exists and is a positive integer or can be coerced to a positive integer, or fallback otherwise. If remove is true, then the mapping will be removed from the Map.

Implementation

int? optPositiveInt(String name, {int fallback = -1, bool remove = false}) {
  int i = optInt(name, fallback: fallback);
  int? value = (i >= 0) ? i : null;
  if (remove) {
    this?.remove(name);
  }
  return value;
}