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 DateTime.now())) {
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));
IntervalSet
classisBefore
and isAfter
method on Intersect
intersect
and enclose
method on Intersect
and intersectAll
constructor Add this to your package's pubspec.yaml file:
dependencies:
intervals: ^0.2.0-beta.2
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.
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 |
|
|
0.2.0-beta.1 | Feb 5, 2018 |
|
|
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
5
|
Health:
Code health derived from static analysis.
[more]
|
--
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
--
|
Overall:
Weighted score of the above.
[more]
|
3
|
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.
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 https://www.dartlang.org/dart-2#migration.
Make sure dartdoc
successfully runs on your package's source files. (-10 points)
Dependencies were not resolved.
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=1.20.1 <2.0.0 |