formateDate method

String formateDate({
  1. bool name = true,
  2. bool withYear = true,
  3. bool withDate = true,
})

Implementation

String formateDate({
  bool name = true,
  bool withYear = true,
  bool withDate = true,
}) {
  try {
    if (name) {
      return _nameDateFormate
          .format(dateTime)
          .substring(withDate ? 0 : 3, withYear ? null : 6);
    }
    return value.substring(withYear ? 0 : 5, withDate ? 10 : 7);
  } catch (_) {
    return "".padLeft((withYear ? 5 : 0) + 2 + (withDate ? 3 : 0));
  }
}