intervals 0.2.0-beta.2

  • Readme
  • Changelog
  • Installing
  • 0

intervals #

Build Status

Provides the Interval and IntervalSet class, a (resp. piecewise) contiguous set of values.

If an Interval contains two values, it also contains all values between them. It may have an upper and lower bound, and those bounds may be open or closed.

An IntervalSet represents the union of zero or more non connected intervals.

Note: this package is a fork and extension of the interval package created by Sean Eagan

Usage #

import 'package:intervals/intervals.dart';

void isActive(DateTime date1, DateTime date2) {
    // Date intervals
    var activeDates = new Interval<DateTime>.closed(date1, date2);
    if(activeDates.contains(new {
      print('Item is active!');

// View selection model
var slider = new Slider(interval: new Interval.closed(0, 100));

// Validation
class Rating {
  final int value;

  Rating(this.value) {
    if(!new Interval.closed(1, 5).contains(value)) {
      throw new ArgumentError('ratings must be between 1 and 5');

// IntervalSet
var a = new Interval.closed(0,1)
    .union(new Interval.closed(2,5))
    .diff(new Interval.closed(3,4));

0.2.0 #

  • new IntervalSet class
  • added isBefore and isAfter method on Intersect
  • strong mode compliant
  • added intersect and enclose method on Intersect and intersectAll constructor

0.1.0 #

  • fork of interval package by Sean Eagan

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  intervals: ^0.2.0-beta.2

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:intervals/intervals.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <2.0.0