parse static method

IntRange? parse(
  1. String? input, {
  2. bool? startInclusive,
  3. bool? endInclusive,
})

Parses a string representation of an integer range.

The input string should be in one of the following formats:

  • [int,int] (inclusive start and end)
  • [int,int) (inclusive start, exclusive end)
  • (int,int] (exclusive start, inclusive end)
  • (int,int) (exclusive start and end)
  • (-infinity,infinity) (open range)
  • (-infinity,int] or (-infinity,int) (open start, inclusive/exclusive end)
  • [int,infinity) or (int,infinity) (inclusive/exclusive start, open end)

Returns a IntRange instance if the input is valid, otherwise returns null.

Implementation

static IntRange? parse(String? input, {bool? startInclusive, bool? endInclusive}) {
  final range = DiscreteRange._parse<num, int>(input,
      regexInfInf: regexInfInf,
      regexInfVal: regexInfVal,
      regexValInf: regexValInf,
      regexValVal: regexValVal,
      parser: (val) => int.parse(val),
      ctor: () => IntRange._(),
      startInclusive: startInclusive,
      endInclusive: endInclusive) as IntRange?;
  return range ;
}