import 'package:flutter/services.dart'; import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; class UserManager { MethodChannel _channel; late OnUserListener listener; UserManager(this._channel); /// User profile change listener Future setUserListener(OnUserListener listener) { this.listener = listener; return _channel.invokeMethod('setUserListener', _buildParam({})); } /// Get user information /// [userIDList] List of user IDs Future> getUsersInfo({ required List userIDList, String? operationID, }) => _channel .invokeMethod( 'getUsersInfo', _buildParam({ 'userIDList': userIDList, 'operationID': Utils.checkOperationID(operationID), })) .then((value) => Utils.toList(value, (v) => UserInfo.fromJson(v))); /// Get information of the currently logged-in user Future getSelfUserInfo({ String? operationID, }) => _channel .invokeMethod( 'getSelfUserInfo', _buildParam({ 'operationID': Utils.checkOperationID(operationID), })) .then((value) => Utils.toObj(value, (map) => UserInfo.fromJson(map))); /// Modify the profile of the currently logged-in user /// [nickname] Nickname /// [faceURL] Profile picture /// [appManagerLevel] /// [ex] Additional fields Future setSelfInfo({ String? nickname, String? faceURL, int? appManagerLevel, String? ex, String? operationID, }) => _channel.invokeMethod( 'setSelfInfo', _buildParam({ // 'userID': userID, 'nickname': nickname, 'faceURL': faceURL, 'appManagerLevel': appManagerLevel, 'ex': ex, 'operationID': Utils.checkOperationID(operationID), })); Future> subscribeUsersStatus( List userIDs, { String? operationID, }) { return _channel .invokeMethod( 'subscribeUsersStatus', _buildParam({ 'userIDs': userIDs, 'operationID': Utils.checkOperationID(operationID), })) .then((value) => Utils.toList(value, (map) => UserStatusInfo.fromJson(map))); } Future unsubscribeUsersStatus( List userIDs, { String? operationID, }) { return _channel.invokeMethod( 'unsubscribeUsersStatus', _buildParam({ 'userIDs': userIDs, 'operationID': Utils.checkOperationID(operationID), })); } Future> getSubscribeUsersStatus({ String? operationID, }) { return _channel .invokeMethod( 'getSubscribeUsersStatus', _buildParam({ 'operationID': Utils.checkOperationID(operationID), })) .then((value) => Utils.toList(value, (map) => UserStatusInfo.fromJson(map))); } Future> getUserStatus( List userIDs, { String? operationID, }) { return _channel .invokeMethod( 'getUserStatus', _buildParam({ 'userIDs': userIDs, 'operationID': Utils.checkOperationID(operationID), })) .then((value) => Utils.toList(value, (map) => UserStatusInfo.fromJson(map))); } Future> getUsersInfoStranger( List userIDs, { String? groupID, String? operationID, }) { return _channel .invokeMethod( 'getUsersInfoStranger', _buildParam({ 'userIDs': userIDs, 'groupID': groupID, 'operationID': Utils.checkOperationID(operationID), })) .then((value) => Utils.toList(value, (map) => UserInfo.fromJson(map))); } static Map _buildParam(Map param) { param["ManagerName"] = "userManager"; return param; } }