random_date 0.0.5
random_date: ^0.0.5 copied to clipboard

Generate a random date given range. Options let you skip leap years and ignore endYear in that case end value is deduced based on current year plus 5 years.

example/random_date_example.dart

import 'package:random_date/random_date.dart';

void main() {
  var randomDateOptions = RandomDateOptions.withDefaultYearsToCurrent(10);
  // generates a random date for given range
  var randomDate = RandomDate.withStartYear(2000);
  print('randomDateWithStartYear[2000]: ${randomDate.random()}');
  randomDate = RandomDate.withRange(2000, 2010);
  print('randomDateWithRange[2000-2010]: ${randomDate.random()}');
  randomDateOptions.excludeLeapYear = true;
  randomDate = RandomDate.withRangeAndOptions(2000, 2010, randomDateOptions);
  print(
      'randomDateWithRangeAndSkipLeapYears[2000-2010]: ${randomDate.random()}');
  randomDate = RandomDate.withStartYearAndOptions(2000, randomDateOptions);
  print(
      'randomDateWithStartYearAndEndYearDefaultedTo[2000-2025]: ${randomDate.random()}');
}
2
likes
100
pub points
65%
popularity

Generate a random date given range. Options let you skip leap years and ignore endYear in that case end value is deduced based on current year plus 5 years.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

More

Packages that depend on random_date