date_range_common 0.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 60

DateRange Dart #

This is a very simple package that gives access to the DateRange class.

This package was created to allow sharing data between Flutter and AngularDart!

Because the Date Range Modal Picker package depends on this class and on the Flutter SDK, it would have been difficult to create a shared codebase across AngularDart and Flutter.

[0.0.1] #

  • First version of the package!

[0.0.2] #

  • Adding examples
  • The code is now formatted with DartFM

[0.0.3] #

  • Renaming lib/date_range.dart to lib/date_range_common.dart to match the package name

[0.1.0] #

  • Fixing issue with the get_duration method (start <-> end)
  • Adding documentation

example/main.dart

import 'package:date_range_common/date_range_common.dart';

void main() {
  /// Returns DateRange containing last week period
  DateRange.lastWeek();

  /// Returns DateRange containing last month period
  DateRange.lastMonth();

  /// Returns DateRange containing the past 7 days
  DateRange.pastSevenDays();

  /// Returns DateRange containing the past 28 days
  DateRange.pastTwentyHeightDays();

  /// This will work perfectly fine
  final DateRange customRange =
      DateRange(DateTime.now(), DateTime.now().add(Duration(days: 5)));

  /// And you can get the duration between both date with:
  customRange.getDuration();

  /// This will throw an error because the last date must be at least equal to the first date!
  DateRange(DateTime.now(), DateTime.now().subtract(Duration(days: 1)));
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  date_range_common: ^0.1.0

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:date_range_common/date_range_common.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
20
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
60
Learn more about scoring.

We analyzed this package on Mar 24, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0