const_date_time_range 1.0.0 copy "const_date_time_range: ^1.0.0" to clipboard
const_date_time_range: ^1.0.0 copied to clipboard

A drop-in replacement for Dart's DateTimRange class with const constructors.

const_date_time_range #

Build Status Code Coverage Funding Status

A drop-in replacement for Dart's DateTimeRange class with const constructors. Builds on top of the const_date_time package.

Getting started #

Install the package:

flutter pub add const_date_time_range

Usage #

You can use a ConstDateTimeRange anywhere a DateTimeRange is expected. All major DateTimeRange constructors have a const version.

import 'package:const_date_time/const_date_time.dart';
import 'package:const_date_time_range/const_date_time_range.dart';

// const constructors
const start = ConstDateTime(2024);
const end = ConstDateTime(2025);
const constDateTimeRange = ConstDateTimeRange(start: start, end: end);

You can access the underlying DateTimeRange object directly:

const cdtr = ConstDateTimeRange(start: ConstDateTime(2024), end: ConstDateTime(2025))
final DateTimeRange dtr = cdtr.dateTimeRange;
// other getters are available as well:
final ConstDateTime dtrStart = cdtr.start;
final ConstDateTime dtrEnd = cdtr.end;
final Duration dtrDur = cdtr.duration;

You can convert a DateTimeRange to a ConstDateTimeRange.

final dtr = DateTimeRange(start: DateTime(2024), end: DateTime(2025));
final ConstDateTimeRange cdtr = dtr.toConstDateTimeRange();

Please consider sponsoring my work to ensure this library receives the attention it deserves.

License #

const_date_time_range is released under the MIT License.

1
likes
160
points
19
downloads

Publisher

verified publisherwesty92.com

Weekly Downloads

A drop-in replacement for Dart's DateTimRange class with const constructors.

Repository (GitHub)
View/report issues

Topics

#date #time #date-time #const #util

Documentation

API reference

Funding

Consider supporting this project:

github.com

License

MIT (license)

Dependencies

const_date_time, flutter

More

Packages that depend on const_date_time_range