put static method

Future<bool> put(
  1. dynamic key,
  2. dynamic value
)

Implementation

static Future<bool> put(key, value) async {
  if (value is String) {
    return (await _sp).setString(key, value);
  } else if (value is int) {
    return (await _sp).setInt(key, value);
  } else if (value is double) {
    return (await _sp).setDouble(key, value);
  } else if (value is bool) {
    return (await _sp).setBool(key, value);
  } else if (value is List<String>) {
    return (await _sp).setStringList(key, value);
  } else {
    try {
      var encode = json.encode(value);
      return (await _sp).setString(key, encode);
    } catch (e) {
      print(e);
      return false;
    }
  }
}