getUserProfile method

  1. @override
Future<void> getUserProfile(
  1. String jid,
  2. dynamic callback(
    1. FlyResponse response
    )?, [
  3. bool fromserver = false,
  4. bool saveasfriend = false,
])
override

This method is used to get the user profile.

Implementation

@override
Future<void> getUserProfile(
    String jid, Function(FlyResponse response)? callback,
    [bool fromserver = false, bool saveasfriend = false]) async {
  String? profileResponse;
  try {
    profileResponse = await mirrorFlyMethodChannel.invokeMethod(
        'getUserProfile',
        {"jid": jid, "server": fromserver, "saveasfriend": saveasfriend});
    var res = convertProfileJsonFromString(profileResponse);
    callback?.call(FlyResponse(true, res, "user profile fetched"));
  } on PlatformException catch (e) {
    LogMessage.d("Platform Exception =", " $e");
    callback?.call(FlyResponse(false, FlyConstants.empty, FlyConstants.empty,
        FlyException(e.code, e.message, e.details)));
  } on Exception catch (e) {
    LogMessage.d("Exception ", " $e");
    callback?.call(FlyResponse(false, FlyConstants.empty, FlyConstants.empty,
        FlyException(FlyErrorCode.unHandle, FlyErrorMessage.unHandle, e)));
  }
}