requestResource method

Future<OWRequestResponse> requestResource(
  1. ResourceRequestType arg_type,
  2. OWRequestDetails arg_details
)

Implementation

Future<OWRequestResponse> requestResource(
    ResourceRequestType arg_type, OWRequestDetails arg_details) async {
  final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
      'dev.flutter.pigeon.ResourceMethodApi.requestResource', codec,
      binaryMessenger: _binaryMessenger);
  final List<Object?>? replyList = await channel
      .send(<Object?>[arg_type.index, arg_details]) as List<Object?>?;
  if (replyList == null) {
    throw PlatformException(
      code: 'channel-error',
      message: 'Unable to establish connection on channel.',
    );
  } else if (replyList.length > 1) {
    throw PlatformException(
      code: replyList[0]! as String,
      message: replyList[1] as String?,
      details: replyList[2],
    );
  } else if (replyList[0] == null) {
    throw PlatformException(
      code: 'null-error',
      message: 'Host platform returned null value for non-null return value.',
    );
  } else {
    return (replyList[0] as OWRequestResponse?)!;
  }
}