read method
Reads and returns the data from storage. value property will also be updated.
Implementation
Future<T?> read() async {
if (this.isDisposed) return null;
await this._writeCalls.completed();
// we cannot change the value of disposed ValueNotifier
if (this.isDisposed) return null;
T? t;
//print(T);
//print(T.toString()=='List<String>');
//print(T is List<String>);
switch (this._type) {
case ItemType.bool:
t = await storage.getBool(key) as T?;
break;
case ItemType.int:
t = await storage.getInt(key) as T?;
break;
case ItemType.double:
t = await storage.getDouble(key) as T?;
break;
case ItemType.string:
t = await storage.getString(key) as T?;
break;
case ItemType.stringList:
t = await storage.getStringList(key) as T?;
break;
case ItemType.dateTime:
t = await storage.getDateTime(key) as T?;
break;
default:
throw FallThroughError();
}
logInfo('PrefItem: read $key, result=$t');
this.value = t;
return t;
}