rodydavis / http_get_cache

HTTP compliant cache for Dart and Flutter. This package is a wrapper around the http package that provides a simple way to cache responses using the 'Cache-Control', 'eTag' and 'Last-Modified' headers.
Apache License 2.0
20 stars 0 forks source link

Having difficulty getting it working on flutter web #3

Open jimmyff opened 2 months ago

jimmyff commented 2 months ago

Hey! Thanks for this great package, look forward to you publishing it on pub.dev.

I'm just having a little difficulty getting it working on flutter web, I get a really useful error:

await initFlutterHttpGetCache();

results in:

Error
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 296:3  throw_
errors.dart:296
packages/flutter/src/services/platform_channel.dart 332:7                    _invokeMethod
platform_channel.dart:332
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50           <fn>
async_patch.dart:45
dart-sdk/lib/async/zone.dart 1661:54                                         runUnary
zone.dart:1661
dart-sdk/lib/async/future_impl.dart 163:18                                   handleValue
future_impl.dart:163
dart-sdk/lib/async/future_impl.dart 861:44                                   handleValueCallback
future_impl.dart:861
dart-sdk/lib/async/future_impl.dart 890:13                                   _propagateToListeners
future_impl.dart:890
dart-sdk/lib/async/future_impl.dart 666:5                                    [_completeWithValue]
future_impl.dart:666
dart-sdk/lib/async/future_impl.dart 736:7                                    callback
future_impl.dart:736
dart-sdk/lib/async/schedule_microtask.dart 40:11                             _microtaskLoop
schedule_microtask.dart:40
dart-sdk/lib/async/schedule_microtask.dart 49:5                              _startMicrotaskLoop
schedule_microtask.dart:49
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 181:7           <fn>

Just wondering if I've missed something obvious? I've got the drift_worker.js and sqlite wasm files in place.

Thanks!

rodydavis commented 2 months ago

I’ll see if I can reproduce the error! What is weird is you shouldn’t need the sqlite database for web as it completely relies on the Fetch API via the fetch_client package.

rodydavis commented 2 months ago

Actually in fact I need to update the example, you need to check for web and only call the method on native platforms.