isPeriodStarted method

Future<bool> isPeriodStarted()

check if period started

Implementation

Future<bool> isPeriodStarted() async {
  bool periodStart = false;
  if (_lastPeriodDate.isNotEmpty) {
    DateTime lastPeriodDate = DateTime.parse(getPreviousPeriodDay());
    DateTime expEndPeriodDate =
        lastPeriodDate.add(Duration(days: getPeriodDuration()));
    DateTime today = DateTime.now();

    if (today.isAfter(lastPeriodDate) && today.isBefore(expEndPeriodDate)) {
      periodStart = true;
    } else if (today.isAtSameMomentAs(lastPeriodDate) ||
        today.isAtSameMomentAs(expEndPeriodDate)) {
      periodStart = true;
    }
  }
  return periodStart;
}