intervals 0.2.0-beta.2

  • Installing
  • Versions
  • 49


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


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));


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


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

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or flutter packages 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';
Version Uploaded Documentation Archive
0.2.0-beta.2 Feb 6, 2018 Go to the documentation of intervals 0.2.0-beta.2 Download intervals 0.2.0-beta.2 archive
0.2.0-beta.1 Feb 5, 2018 Go to the documentation of intervals 0.2.0-beta.1 Download intervals 0.2.0-beta.1 archive


We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3


Describes how popular the package is relative to other packages. [more]
0 / 100
Code health derived from static analysis. [more]
99 / 100
Reflects how tidy and up-to-date the package is. [more]
98 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:intervals/intervals.dart.


  • Package is pre-release.

    Pre-release versions should be used with caution, their API may change in breaking ways.

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 6 hints.

    Run dartfmt to format lib/intervals.dart.

    Run dartfmt to format lib/src/interval.dart.

    Similar analysis of the following files failed:

    • lib/src/interval_set.dart (hint)
    • lib/src/materialized_interval_set.dart (hint)
    • lib/src/set_operations.dart (hint)
    • lib/src/util.dart (hint)
  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use intervals.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <2.0.0
collection ^1.14.0 1.14.10
Dev dependencies
test ^0.12.30