Handling RequestFailedException(800220) when sending file in flutter chat sdk of sendbird

33 Views Asked by At

I am using sendbird chat sdk to try sending a file, here is the code that I get from sample

GroupChannel? groupChannel;
final channelUrl = Get.parameters['channel_url']!;
@override
  void initState() {
    super.initState();
    GroupChannel.getChannel(channelUrl).then((channel) {
      groupChannel = channel;
    });
  }

voidSendFile() {
    try {
      FileMessageCreateParams? params;
      params = FileMessageCreateParams.withFile(
        File(filePath!),
        fileName: textEditingController.text,
      );

      if (params != null) {
        groupChannel!.sendFileMessage(
          params,
          handler: (message, e) async {
            print("Error here $e"); //error here
          },
          progressHandler: (sentBytes, totalBytes) {
            print("progress $sentBytes $totalBytes");
            setState(() {
              uploadProgressValue = (sentBytes / totalBytes);
            });
          },
        );
      }
    } catch (err) {
      print("this is error voidSendFile $err");
    }
  }

Each time I call voidSendFile() function, I always get this error :

RequestFailedException(800220): Null check operator used on a null value when sending file using flutter chat sdk

that message is printed from print("Error here $e"); is there a way to solve this case ? I have made sure that groupChannel and channelUrl is not null (I am debugging this using simulator, while using physical android device it is fine)

0

There are 0 best solutions below