How to get the previous date ( dd/mm/yy) in flutter

Viewed 218

I would like to display the previous date How do I do that?

i used this methode for display the date of today, i also want to display the previous date.

  static final DateTime now = DateTime.now();
  static final DateFormat formatter = DateFormat('dd-MM-yyyy');
  final String formatted = formatter.format(now);
2 Answers
final now = DateTime.now();
final today = DateTime(now.year, now.month, now.day);
final yesterday = DateTime(now.year, now.month, now.day - 1);
final tomorrow = DateTime(now.year, now.month, now.day + 1);
Related