loadMessages static method

Future<List<String>> loadMessages()

Loads the list of saved chat messages from SharedPreferences.

Returns a list of messages, ordered from newest to oldest.

Implementation

static Future<List<String>> loadMessages() async {
  final prefs = await SharedPreferences.getInstance();

  // Retrieve existing messages
  List<String> messages = prefs.getStringList(_chatMessagesKey) ?? [];

  return messages;
}