Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The example app does not persist data on reload #2792

Closed
jsloop42 opened this issue Dec 17, 2023 · 4 comments
Closed

The example app does not persist data on reload #2792

jsloop42 opened this issue Dec 17, 2023 · 4 comments

Comments

@jsloop42
Copy link

The example app is not persisting data on web on page reload.

The web app is compiled using:

➜  app git:(develop) flutter build web

Expected to find fonts for (MaterialIcons, packages/cupertino_icons/CupertinoIcons), but found (MaterialIcons). This usually means you are referring to font families in an IconData class but not including them in the assets section of your pubspec.yaml, are missing the package that would include them, or
are missing "uses-material-design: true".
Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 7848 bytes (99.5% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
Compiling lib/main.dart for the Web...                             42.0s

Then ran as:

http-server .
Starting up http-server, serving .

http-server version: 14.1.1
...
Available on:
  http://127.0.0.1:8080
  http://192.168.1.2:8080
  http://10.211.55.2:8080
  http://10.37.129.2:8080
Hit CTRL-C to stop the server

The app is then launched on Edge browser. Adding a todo shows in the list. But when I refresh the page only the two default entries are shown. The newly added todo is not shown. In the browser console I see two errors.

Failed to fetch a worker script.
Failed to load resource: the server responded with a status of 404 (Not Found)
@jsloop42
Copy link
Author

I tried the flutter_web_worker_example and is facing the same issue.

Screenshot 2023-12-17 at 12 03 49 PM

@simolus3
Copy link
Owner

You need to run dart run build_runner build before building the examples. This is because these examples don't use a prebuilt drift worker but instead compile them with build_runner, so if without running that command the worker will be missing and no persistence is possible.

I'll add that information to the readme - let me know if you run into other issues with the examples after the worker has been generated.

@juanccalzadilla
Copy link

I got the following error on console when i built flutter web app:

Captura de pantalla 2024-01-15 a las 12 24 13

What could be?

Thanks! @simolus3

@PrimeTimeTran
Copy link

Might I ask you guys how you got past the following error?

Using WasmStorageImplementation.sharedIndexedDb due to unsupported browser features: {MissingBrowserFeature.dedicatedWorkersInSharedWorkers, MissingBrowserFeature.sharedArrayBuffers}

I've tried doing the suggestions of this documentation on pub.dev

https://pub.dev/documentation/drift/latest/drift.wasm/WasmStorageImplementation.html

Running a server with appropriate headers:
dhttpd '--headers=Cross-Origin-Embedder-Policy=require-corp;Cross-Origin-Opener-Policy=same-origin'
Server started on port 8080

But that page isn't found when I navigate to http://localhost:8080/

A bit confused because I've run through the documentation several times and it still doesn't work. I am able to successfully run the example web app though found here.

Looking forward to your help =).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants