exec method

Future<DateTime> exec(
  1. {required XFile photo}
)

写真の撮影日時を取得する。

指定された写真のExif情報から撮影日時を取得します。 Exif情報がない場合や無効な場合は現在の日時を返します。

Parameters:

  • photo : 撮影日時を取得する写真

Return: Future<DateTime> が返されます。このFutureは、操作が完了すると完了します。

使用するサービス:

Implementation

Future<DateTime> exec({
  required XFile photo,
}) async {
  try {
    final dateTime = await _getShootingDateService.exec(
      photo: photo,
    );

    if (dateTime == null) {
      return DateTime.now();
    }

    if (dateTime.isBefore(DateTimeConst.firstDate)) {
      return DateTime.now();
    }

    return dateTime;
  } catch (_) {
    return DateTime.now();
  }
}