getServerTime method
Implementation
@override
Future<DateTime> getServerTime() async {
if (config.serverTimeRpcName == null) {
// Fallback to client time (non-ideal); recommended to configure RPC.
return DateTime.now().toUtc();
}
final res = await config.client.rpc(config.serverTimeRpcName!);
// Supabase returns ISO8601 string or timestamp depending on RPC
if (res is String) return DateTime.parse(res).toUtc();
if (res is Map && res['server_time'] is String) {
return DateTime.parse(res['server_time'] as String).toUtc();
}
// Try to coerce to ISO string
return DateTime.parse(res.toString()).toUtc();
}