createRoom method

Future<GameRoomModel?> createRoom(
  1. int userId,
  2. String roomName, {
  3. ApiError? error,
})

创建游戏房间

userId : 用户id,房间创始人

roomName : 房间名字

Implementation

Future<GameRoomModel?> createRoom(int userId, String roomName, {ApiError? error}) async {
  final result = await util.post('$userApiUrl/create-room',
      isTaokeApi: false, data: {'name': roomName, 'userId': userId}, error: error);

  return result.isNotEmpty ? GameRoomModel.fromJson(jsonDecode(result)) : null;
}