toUnixEpoch method

int? toUnixEpoch(
  1. String? value
)

Implementation

int? toUnixEpoch(String? value) {
  if (value == null) return null;
  value = value.trim();
  if (value.isEmpty) return null;

  if (RegExp(r'^\d+$').hasMatch(value)) return int.parse(value);

  return DateTime.parse(value).millisecondsSinceEpoch;
}