我在我的 nodejs 服务器上使用 pako 包,并将压缩的二进制字符串从服务器发送到我的颤振客户端。我无法在颤振客户端上解压缩/膨胀它。我尝试了库的组合
我的服务器 NodeJS 代码:
var pako = require('pako');
let buffer = pako.deflate(JSON.stringify(userModels), { to: 'string' });
//Server code for sending to client
我的颤振代码:
import 'dart:io';
import 'dart:convert';
List<int> gzipBytes = serverResponse.data.codeUnits;
List<int> stringBytes = gzip.decode(gzipBytes);
var data = utf8.decode(stringBytes);
我收到以下异常..
在 1,725 毫秒内重新启动应用程序。E/flutter (25340): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] 未处理异常:InternalError: 'Filter error, bad data' E/flutter (25340): #0
_FilterImpl.processed (dart: io-patch/filter_patch.dart:11:32) E/flutter (25340): #1 _FilterSink.addSlice (dart:io/data_transformer.dart:610:29) E/flutter (25340): #2
_FilterSink.add ( dart:io/data_transformer.dart:596:5) E/flutter (25340): #3 ZLibDecoder.convert (dart:io/data_transformer.dart:465:9) E/flutter (25340): #4
Codec.decode ( dart:convert/codec.dart:26:34)