setData static method

dynamic setData(
  1. DataType dataType,
  2. String key,
  3. dynamic value
)

Implementation

static setData(DataType dataType, String key, var value) async {

  await _init();

   switch (dataType) {
     case DataType.string:
       await sharedPreferences!.setString(key, value);
       break;
     case DataType.bool:
       if ([null, ""].contains(value)) {
         await sharedPreferences!.setBool(key, false);
       } else {
         await sharedPreferences!.setBool(key, value);
       }
       break;
     case DataType.int:
       await sharedPreferences!.setInt(key, value);
       break;
     default:
       await sharedPreferences!.setString(key, value);
       break;
   }
 }