format method

String format({
  1. String? format,
  2. Locale? locale,
  3. BuildContext? context,
})

Implementation

String format({String? format, Locale? locale, BuildContext? context}) {
  try {
    locale ??=
        FlutterViewUtils.get(context: context).platformDispatcher.locale;
    return Intl.DateFormat(
            format ?? getFormattedDateTimeFormat(), locale.toString())
        .format(getDateAsDateTimeLocal()!);
  } catch (e) {
    print(e);
    try {
      return Intl.DateFormat(format ?? getFormattedDateTimeFormat())
          .format(getDateAsDateTimeLocal()!);
    } catch (e) {
      print(e);
      return Intl.DateFormat().format(getDateAsDateTimeLocal()!);
    }
  }
}