getMessages method

  1. @override
Future<List<InboxMessage>> getMessages({
  1. String? topic,
})
override

Implementation

@override
Future<List<InboxMessage>> getMessages({String? topic}) async {
  final result = await methodChannel.invokeMethod<List<dynamic>>(
    NativeMethods.getInboxMessages,
    topic != null ? {NativeMethodParams.topic: topic} : null,
  );

  if (result == null) {
    return [];
  }

  return result
      .map((item) => InboxMessage.fromMap(
          (item as Map<Object?, Object?>).cast<String, dynamic>()))
      .toList();
}