bool supports(obj)

Source

bool supports(dynamic obj) {
  return obj is DateTime || obj is num;
}