getMyConversations method

Future<List<Conversation>> getMyConversations()

Implementation

Future<List<Conversation>> getMyConversations() async {
  try {
    final result = await TwilioConversations()
        .conversationsClientApi
        .getMyConversations();

    final conversationsMapList = result
        .whereType<
            ConversationData>() // converts list contents type to non-nullable
        .map((ConversationData c) =>
            Map<String, dynamic>.from(c.encode() as Map))
        .toList();

    for (var element in conversationsMapList) {
      updateConversationFromMap(element);
    }

    return conversations.values.toList();
  } on PlatformException catch (err) {
    throw TwilioConversations.convertException(err);
  }
}