1

GZipCodec().decode does not work in flutter for the target web. Is there a workaround? The following snippet works for the target 'android' and it works for the target 'windows'.

        List<int> gzipped = providerFDC.fdcdata_gzipped.codeUnits;
        final ungzipped0 = GZipCodec().decode(gzipped);
        String ungzipped = String.fromCharCodes(ungzipped0);
        List<dynamic> food = jsonDecode(ungzipped);
        foodList = food.map((e) => FoodItem.fromJson(e)).toList();

I am working on an app that uses Food Data Central database. A preliminary version can be already used at http://buf1612huds2.w73.eu/foodd456/

K.Karamazen
  • 176
  • 1
  • 8

1 Answers1

1

The GZipCodec object is imported from the dart.io library, this library is not supported for Flutter Web.

A solution would be to use the univerisal_io package, as also answered in the question: import 'dart:io'; not support on the web application. Howver this library only allows you to compile for web while still using the dart.io references. But does not allow web clients to use the GZip decoding on web itself.