setObject<T> method

  1. @override
Future<void> setObject<T>(
  1. String key,
  2. T? value
)
override

Method to set custom object value to the storage, value can be null according to the support by underlying storage system.

Example code(SharedPreferences Implementation): /// ```dart Future

Implementation

@override
Future<void> setObject<T>(String key, T? value) async {
  if (T == int || value is int) {
    await _preferences?.setInt(key, value as int);
  } else if (T == double || value is double) {
    await _preferences?.setDouble(key, value as double);
  } else if (T == bool || value is bool) {
    await _preferences?.setBool(key, value as bool);
  } else if (T == String || value is String) {
    await _preferences?.setString(key, value as String);
  } else {
    throw Exception(
        "flutter_settings_screens doesn't handle values of type $T");
  }
}