toIso8601String method

String toIso8601String()

Returns an ISO-8601 full-precision extended format representation. The format is yyyy-MM-ddTHH:mm:ss.mmmuuunnnZ nanoseconds and microseconds are omitted if null

Implementation

String toIso8601String() {
  // Use DateTime without the sub second part
  var text = Timestamp(seconds, 0).toDateTime(isUtc: true).toIso8601String();
  // Then add the nano part to it
  var nanosStart = text.lastIndexOf('.') + 1;
  return '${text.substring(0, nanosStart)}${_formatNanos(nanoseconds)}Z';
}