getInt method

int? getInt(
  1. String key, [
  2. int? defaultVal
])

Returns a session value as int by key. Returns defaultVal if the conversion fails.

Implementation

int? getInt(String key, [int? defaultVal]) {
  final String? val = _data[key];

  if (val == null) {
    return defaultVal;
  }

  return int.tryParse(val) ?? defaultVal;
}