Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8981681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:23:49+00:00 2026-06-15T20:23:49+00:00

i was able to fire off an alert message from dart, but couldn’t figure

  • 0

i was able to fire off an alert message from dart, but couldn’t figure out how to call a function I wrote in another js file from dart. This would have been a great selling point if it was straight forward. I did see this post, which got me started, but i feel there must be a way, so please share the love if you figured it out.

Here’s what I’ve done:

  1. Add this to yaml file:

    dependencies:
    js:
    hosted: js

  2. Add import statement to top of dart file: import ‘package:js/js.dart’ as js;

  3. Add this bit of code to show alert message

    js.scoped(() {
    js.context.alert(“jump for joy!”);
    });

  4. Here’s the part which I think should work but doesn’t: given that I have a javascript function doSomething(), I should be able to call

    js.context.doSomething();

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T20:23:50+00:00Added an answer on June 15, 2026 at 8:23 pm

    First add the js package as dependency in your pubspec.yaml :

    dependencies:
      js: any
    

    Then you can use your own js function myFunc() like that :

    import 'package:js/js.dart' as js;
    
    main() {
      js.context.myFunc();
    }
    

    js.context is an alias to javascript window.

    See Using JavaScript from Dart: The js Library for more details.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to fire off a function every 0.5 seconds and be able to
A project I'm working on requires me to be able to fire off an
I was able to get the two events to fire off the one 'both'
Not able to download artifacts from central maven repository. <mirrors> <!-- mirror | Specifies
I am able to get the current date, but I don't know how to
I want to be able to find out when a page element is on
Have another issue here. Our app starts out with a tab activity. But, before
I realize this has been asked before, but I wasn't able to find a
I am able to fire an Event using an Event receiver which I created
I have an MVC 3 app that is using jQuery AJAX to fire off

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.