receiveFromFrontend method

  1. @override
void receiveFromFrontend(
  1. int? id,
  2. String method,
  3. Map<String, dynamic>? params
)

Implementation

@override
void receiveFromFrontend(int? id, String method, Map<String, dynamic>? params) {
  switch (method) {
    case 'setCacheDisabled':
      bool cacheDisabled = params?['cacheDisabled'];
      if (cacheDisabled) {
        HttpCacheController.mode = HttpCacheMode.NO_CACHE;
      } else {
        HttpCacheController.mode = _httpCacheOriginalMode;
      }
      sendToFrontend(id, null);
      break;
    case 'getResponseBody':
      String requestId = params!['requestId'];
      Uint8List? buffer = _responseBuffers[requestId];
      sendToFrontend(
          id,
          JSONEncodableMap({
            if (buffer != null) 'body': utf8.decode(buffer),
            // True, if content was sent as base64.
            'base64Encoded': false,
          }));
      break;

    case 'setAttachDebugStack':
      sendToFrontend(id, JSONEncodableMap({}));
      break;

    case 'clearAcceptedEncodingsOverride':
      sendToFrontend(id, JSONEncodableMap({}));
      break;
  }
}