getDateFromDay static method

String? getDateFromDay({
  1. required int dayOfMonth,
  2. String format = Format.fyyyyMMdd,
})

get date from day

Implementation

static String? getDateFromDay({
  required int dayOfMonth,
  String format = Format.fyyyyMMdd,
}) {
  final now = DateTime.now();

  // The DateTime constructor handles year/month/day
  // Note: If you pass a day invalid for the month (e.g., Feb 30),
  // Dart wraps it into the next month automatically.
  DateTime date = DateTime(now.year, now.month, dayOfMonth);
  return DateFormat(format).format(date);
}