savedMessages static method
Returns the saved messages. @returns A future that completes with the list of saved messages.
Implementation
static Future<List<MBMessage>?> savedMessages() async {
String path = await _messagesPath();
File f = File(path);
bool fileExists = await f.exists();
if (!fileExists) {
return [];
}
String contents = await f.readAsString();
if (contents.isEmpty) {
return [];
}
List<dynamic> list = json.decode(contents);
List<MBMessage> messages = [];
for (dynamic messageDict in list) {
if (messageDict is Map<String, dynamic>) {
messages
.add(MBMessageSavingUtility.messageFromJsonDictionary(messageDict));
}
}
return messages;
}