getCreatedAtTime method

DateTime getCreatedAtTime()

Retrieves the createdAt timestamp as a DateTime object.

  • If the data object or its createdAt field is null, the current time is returned.
  • Otherwise, parses the createdAt field into a DateTime.

Implementation

DateTime getCreatedAtTime() {
  if (data != null) {
    if (data?.createdAt != null) {
      return DateTime.parse(data!.createdAt!);
    } else {
      return DateTime.now();
    }
  } else {
    return DateTime.now();
  }
}