getProfileImageUrl method

Future<String?> getProfileImageUrl({
  1. required int width,
  2. int? height,
})

Get user profile image url.

If not logged in or error during request than return null.

width of picture is required, but height is optional, and by default is equals to width.

Implementation

Future<String?> getProfileImageUrl({required int width, int? height}) async {
  if (await isLoggedIn == false) {
    if (debug) _log('Not logged in. Profile image url is null');
    return null;
  }

  try {
    final url = await _channel.invokeMethod<String>(
      _methodGetProfileImageUrl,
      {
        _widthArg: width,
        _heightArg: height ?? width,
      },
    );

    if (debug) _log('Profile image url: $url');

    return url;
  } on PlatformException catch (e) {
    if (debug) _log('Get profile image url error: $e');
  }

  return null;
}