Skip to content

Instantly share code, notes, and snippets.

@naimurhasan
Created June 24, 2021 06:51
Show Gist options
  • Save naimurhasan/0555f108846caccc10c6c0357c0d5f90 to your computer and use it in GitHub Desktop.
Save naimurhasan/0555f108846caccc10c6c0357c0d5f90 to your computer and use it in GitHub Desktop.
Dart is Expired
/**
import 'package:intl/intl.dart';
* MAKE A FUNCTION TO CHECK EXPIRE
* */
bool isExpired(date) {
DateTime parseDate = DateFormat("yyyy-MM-dd").parse(date);
var inputDate = DateTime.parse(parseDate.toString());
var todayDate = DateTime.now();
final difference = inputDate.difference(todayDate).inDays;
return difference < 0;
}
isSubscriptionValidToday() {
if (this._membershipEndDate != null) {
return !this.isExpired(this._membershipEndDate);
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment