xrange 0.0.8
This is a fork of Interval library
XRange lib #
Provides the Range
class, a contiguous set of values, and the NumRange
class, that along with functionality of
Range
class can also generate values of arithmetic progression in a specific diapason.
If a range 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.
Also the library contains integers
generator function, that is based on NumRange
class. It produces integer values
from a specific closed diapason.
Usage #
Range #
import 'package:xrange/range.dart';
void main() {
final date1 = DateTime(2015);
final date2 = DateTime(2021);
final dates = Range<DateTime>.closed(date1, date2);
if (dates.contains(DateTime.now())) {
print('Hi, contemporary!');
} else {
print('Apparently, you are from the future!');
}
}
NumRange #
import 'package:xrange/num_range.dart';
void main() {
final range = NumRange.closed(-10, 10);
for (final value in range.values(step: 2)) {
print(value); // it yields numbers from -10 to 10 with step equals 2
}
}
Pay attention to values
method - it is a generator function, so use all the benefits of this.
integers #
import 'package:xrange/integers.dart';
void main() {
for (final value in integers(-10, 10)) {
print(value); // it yields numbers from -10 to 10 with step equals 2
}
}
The integers
function returns a lazy iterable, thus it consumes little memory, since the whole collection is not
being generated when integers
is called.
Changelog #
0.0.8 #
integers
:lowerClosed
andupperClosed
arguments added
0.0.7 #
ZRange
renamed toNumRange
integers
function added
0.0.6 #
ZRange
: firstValue, lastValue, length calculation fixed
0.0.5 #
README
updated: badges added, text corrected
0.0.4 #
ZRange
: length calculation fixed
0.0.3 #
ZRange
class introduced
0.0.2 #
pubspec.yaml
:author
section corrected
0.0.1 #
Interval
renamed toRange
- Analysis options added
import 'package:xrange/src/range/range.dart';
import 'package:xrange/src/num_range/num_range.dart';
void range() {
final date1 = DateTime(2015);
final date2 = DateTime(2021);
final dates = Range<DateTime>.closed(date1, date2);
if (dates.contains(DateTime.now())) {
print('Hi, contemporary!');
} else {
print('Apparently, you are from the future!');
}
}
void zrange() {
final range = NumRange.closed(-10, 10);
for (final value in range.values(step: 2)) {
print(value); // it yields numbers from -10 to 10 with step equals 2
}
}
void main() {
range();
zrange();
}
Use this package as a library
1. Depend on it
Add this to your package's pubspec.yaml file:
dependencies:
xrange: ^0.0.8
2. Install it
You can install packages from the command line:
with pub:
$ pub get
with Flutter:
$ flutter pub get
Alternatively, your editor might support pub get
or flutter pub get
.
Check the docs for your editor to learn more.
3. Import it
Now in your Dart code, you can use:
import 'package:xrange/xrange.dart';
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
35
|
Health:
Code health derived from static analysis.
[more]
|
100
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
87
|
Overall:
Weighted score of the above.
[more]
|
65
|
We analyzed this package on Dec 12, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
- Dart: 2.6.1
- pana: 0.13.1+4
Health suggestions
Format lib/src/generators/integers.dart
.
Run dartfmt
to format lib/src/generators/integers.dart
.
Format lib/src/injector.dart
.
Run dartfmt
to format lib/src/injector.dart
.
Format lib/src/num_range/num_range.dart
.
Run dartfmt
to format lib/src/num_range/num_range.dart
.
Format lib/src/num_range/num_range_factory_impl.dart
.
Run dartfmt
to format lib/src/num_range/num_range_factory_impl.dart
.
Format lib/src/range/range.dart
.
Run dartfmt
to format lib/src/range/range.dart
.
Maintenance suggestions
Package is pre-v0.1 release. (-10 points)
While nothing is inherently wrong with versions of 0.0.*
, it might mean that the author is still experimenting with the general direction of the API.
The package description is too short. (-3 points)
Add more detail to the description
field of pubspec.yaml
. Use 60 to 180 characters to describe the package, what it does, and its target use case.
Dependencies
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=2.2.0 <3.0.0 | ||
injector | ^1.0.8 | 1.0.8 | |
Transitive dependencies | |||
meta | 1.1.8 | ||
Dev dependencies | |||
build_runner | ^1.1.2 | ||
build_test | ^0.10.2 | ||
grinder | ^0.8.3 | ||
ml_tech | ^0.0.8 | ||
mockito | ^4.1.1 | ||
test | ^1.2.0 |