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

only Shows blank extension with error #1

Open
gauravmehta13 opened this issue Oct 7, 2020 · 9 comments
Open

only Shows blank extension with error #1

gauravmehta13 opened this issue Oct 7, 2020 · 9 comments

Comments

@gauravmehta13
Copy link

image

@samhardeman
Copy link

samhardeman commented Nov 17, 2020

There are two problems. The first problem is that the code presented should be in flutter_app.html, not in index.html. The second problem is that Chrome doesn't allow inline code so you have to put the code within the script tags in a separate js file and then link the new file in the script tag.
So in flutter.html:

<html>
  <body>
    <script src="newFile.js"></script>
    <script src="main.dart.js" type="application/javascript"></script>
  </body>
</html>

And in newFile.js:

if ("serviceWorker" in navigator) {
  window.addEventListener("load", function () {
    navigator.serviceWorker.register("flutter_service_worker.js");
  });
}

I hope this solves your problem.

@shaw8wit
Copy link

shaw8wit commented Mar 1, 2021

@Locuroid this is the error now. Any suggestions on how to resolve this?
Screenshot from 2021-03-01 17-53-23

Also in this statement:

There are two problems. The first problem is that the code presented should be in flutter_app.html, not in index.html. The second problem is that Chrome doesn't allow inline code so you have to put the code within the script tags in a separate js file and then link the new file in the script tag.
So in flutter.html:

what did you mean by: "The first problem is that the code presented should be in flutter_app.html, not in index.html"

@samhardeman
Copy link

After some digging, I found my old code from when I tried to do this, and resurrected it. As expected, It did not work and I found I had the same error message as you. I guess I probably was frustrated and quit making the extension. My suggestion would be to find a more recent tutorial that is better maintained. I found a tutorial on the developer.chrome.com site here. I haven't tried it to see if it actually works, but it might yield better results.
As for the "The first problem is that the code presented should be in flutter_app.html, not in index.html", I don't really know what I meant there. I probably saw the "Context: index.html" in your original screenshot and thought the code had been mixed up.
I'm sorry I wasn't able to fix your problem, I hope this was even a bit helpful. Have a nice day/night.

@shaw8wit
Copy link

shaw8wit commented Mar 2, 2021

Thank you for the honest response.
I'll check out the link provided by you.
Have a nice day.

@abhaybabbar
Copy link

@shaw8wit did you get any solution?

@shaw8wit
Copy link

@abhaybabbar nope couldn't resolve the error

@LefebvreIlyas
Copy link

LefebvreIlyas commented Aug 22, 2021

Hello @gauravmehta13, @Locuroid, @shaw8wit, @abhaybabbar,

Watch this YoutTube video of @Destiny-Ed.

Here are the steps I followed:

  • Rename browser_action to action
  • Change manifest_version from 2 to 3
  • Delete content_security_policy

And the Flutter application was displayed correctly which was not the case before.

Only the error Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'. is left.

Have a nice day

@LefebvreIlyas
Copy link

I also removed the use of the auxliary file flutter_app.htm to do as in the video.

@Likenttt
Copy link

Likenttt commented Aug 6, 2022

Try this command

flutter build web --web-renderer html --csp

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

6 participants