toIntJson static method

int? toIntJson(
  1. dynamic json
)

Converts JSON to an integer.

Implementation

static int? toIntJson(dynamic json) {
  if (json == null) return null;
  if (json is int) return json;
  if (json is double) return json.toInt();
  if (json is String) return int.tryParse(json);
  return null;
}