read method

  1. @override
DateTime? read(
  1. dynamic data
)
override

read

A callback function that is used to read and convert the stored data back into the expected type when the CachedWatcher is initialized. This function handles various primitive types and collections containing primitives, ensuring that the data retrieved from the local cache is correctly transformed back into its original state or the state type T. The read callback is crucial for the accurate restoration of the cached state, facilitating a seamless user experience across app sessions.

the read function returns data only when the write function gets called before and returned a value.

NOTE: make sure that the dynamic data that you are getting from the read function is properly converted into the type that you wrote before using the write function.

Implementation

@override
DateTime? read(dynamic data) => tryToDateTime(data);