helpers_plethora_flutter

Last updated:

0 purchases

helpers_plethora_flutter Image
helpers_plethora_flutter Images
Add to Cart

Description:

helpers plethora flutter

An helpful variety of extensions and enumerations dependent on Flutter.
Usage #
DateTime extension methods #
You can determine if a date belongs to a date range:
final DateTime start = DateTime(2022, 7);
final DateTime end = DateTime(2022, 7, 31);
final DateTimeRange range = DateTimeRange(start: start, end: end);
DateTime(2022, 7, 15).belongsTo(range);
copied to clipboard
DateTimeRange extension methods #
You can determine if a date range belongs to another date range:
final DateTimeRange other =
DateTimeRange(
start: DateTime(2022),
end: DateTime(2022, 7, 31),
);
DateTimeRange(
start: DateTime(2021, 9),
end: DateTime(2022),
).belongsTo(other);
copied to clipboard
You can determine if a date range overlaps, in part or completely, with the other date range:
final DateTimeRange other =
DateTimeRange(
start: DateTime(2022),
end: DateTime(2022, 7, 31),
);
DateTimeRange(
start: DateTime(2021, 9),
end: DateTime(2022, 1, 2),
).overlapsWith(other);
copied to clipboard
List<DateTimeRange> extension methods #
You can get the sum of the duration of all intervals in a list after eliminating all duplicate intervals (which overlap some interval already present in the list).
final DateTimeRange range1 =
DateTimeRange(start: DateTime(2022), end: DateTime(2022, 7));
final DateTimeRange range2 = DateTimeRange(
start: DateTime(2022, 1, 25),
end: DateTime(2022, 4, 7),
);
final DateTimeRange range3 =
DateTimeRange(start: DateTime(2022, 4, 7), end: DateTime(2022, 7));
final DateTimeRange range4 = DateTimeRange(
start: DateTime(2022, 5, 2),
end: DateTime(2022, 6, 15),
);
final DateTimeRange range5 = DateTimeRange(
start: DateTime(2022, 7, 3),
end: DateTime(2022, 9, 30),
);
final DateTimeRange range6 =
DateTimeRange(start: DateTime(2022), end: DateTime(2022, 7));
final DateTimeRange range7 = range5;
<DateTimeRange>[range1, range2, range3, range4, range5].duration.inDays;
copied to clipboard
You can get the a list of date ranges that covers the entirety of the period of the sum of all date ranges in this list, but without repeating any overlap:
final DateTimeRange range1 =
DateTimeRange(start: DateTime(2022), end: DateTime(2022, 7));
final DateTimeRange range2 = DateTimeRange(
start: DateTime(2022, 1, 25),
end: DateTime(2022, 4, 7),
);
final DateTimeRange range3 =
DateTimeRange(start: DateTime(2022, 4, 7), end: DateTime(2022, 7));
final DateTimeRange range4 = DateTimeRange(
start: DateTime(2022, 5, 2),
end: DateTime(2022, 6, 15),
);
final DateTimeRange range5 = DateTimeRange(
start: DateTime(2022, 7, 3),
end: DateTime(2022, 9, 30),
);
<DateTimeRange>[range1, range2, range3, range4, range5].minimize();
copied to clipboard
TimeOfDay extension methods #
You can determine if a time is after another (this > other):
const TimeOfDay(hour: 7, minute: 35)
.isAfter(const TimeOfDay(hour: 7, minute: 57));
copied to clipboard
You can determine if a time is before another (this < other):
const TimeOfDay(hour: 12, minute: 20)
.isBefore(const TimeOfDay(hour: 7, minute: 10));
copied to clipboard
You can get the string representation of a time:
const TimeOfDay(hour: 7, minute: 15).toStringHm();
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.