Numeric range

Lightweight utility class providing interval-like operations as implemented e.g. also by math_expressions. This package offers a type-safe int-only version though, as well as exposing a dedicated API for intersecting ranges.

/// create an instance - for integer-only operations, import from [integer_range.dart]
const fourToFive = Range(4, 5);

/// in-range check
fourToFive.contains(4); // true
fourToFive.contains(7); // false

/// intersecting
fourToFive.intersection(Range(3.9, 5.1)); // still [4..5]
/// shorthand notation for intersection
fourToFive & NumRange(3.9, 4.9); // [4..4.9]

/// equality 
Range(4, 8).intersection(Range(3, 6)) == Range(4, 6); // true

Libraries

integer_range
numeric_range
For a type-safe pure "integer"-based implementation, import integer_range.dart instead