asString method
Returns the stored data as a formatted string.
This method helps in debugging by providing a structured view of the stored key-value pairs.
Implementation
@override
Future<String> asString() async {
final StringBuffer stringBuffer = StringBuffer();
stringBuffer.write(
'\n----------------------------------------------------------------------------------------',
);
stringBuffer.write('\n$logPrefix data:');
stringBuffer.write(
'\n----------------------------------------------------------------------------------------',
);
// Retrieve all stored key-value pairs and format them.
(await getAll()).forEach(
(key, value) => stringBuffer.write('\n\n$key: $value'),
);
stringBuffer.write(
'\n----------------------------------------------------------------------------------------',
);
return stringBuffer.toString();
}