getUserProfile method

  1. @override
Future<UserProfile?> getUserProfile()
override

Implementation

@override
Future<UserProfile?> getUserProfile() async {
  var result = await methodChannel.invokeMethod('getUserProfile');
  if (result != null) {
    if (result['isSuccess']) {
      if (Platform.isAndroid) {
        var decodedUserProfile = jsonDecode(result['userProfile']);
        return UserProfile.fromMap(decodedUserProfile);
      } else {
        return UserProfile.fromMap(
            Map<String, dynamic>.from(result['userProfile']));
      }
    } else {
      throw PlatformException(code: 'ERROR', message: result['message']);
    }
  } else {
    throw Exception('getUserProfile() failed');
  }
}