New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dvote-js-runtime-flutter

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dvote-js-runtime-flutter

DVote Javascript runtime for Flutter apps

  • 1.1.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-80%
Maintainers
1
Weekly downloads
 
Created
Source

DVote JS runtime for Flutter

The purpose of this component is to overcome the current limitations of the ecosystem available to apps running on Flutter.

The component provides access to a full fledged JS runtime, that will only run explicitly bundled static HTML/JS code.

This is intended as a workaround until Dart has full support for cryptographic and blockchain libraries.

Usage

Check the exampe on example/*.

Within your Flutter code, invoke the available runtime functions as follows.

Add a listener

// listen for post messages coming from the JavaScript side
this.webViewController.addJavaScriptHandler(
    "JS_REQUEST_RESPONSE_CHANNEL", (arguments) => onMessageReceived(arguments));

Trigger an action

final requestId = 1234;
final jsExpression = "myJavascriptFunction('param1', { param2: true }, false)";

await this.webViewController.injectScriptCode('''
    call(() => $jsExpression)
    .then(result => replyMessage($requestId, result))
    .catch(error => replyError($requestId, error))
''');

Handle a response

  onMessageReceived(List<dynamic> arguments) async {
    print(arguments);

    // Expected:
    //  arguments[0] = { id: <int>, error: <bool> }
    //  arguments[1] = <data>
    
    // ...
  }

Customize

  • Add your new handler on index.ts
  • Declare the function within const handlers: HandlersMap = { ... }
  • Run npm run build
  • Use dist/runtime.html

Future work

  • Provide a dart example
  • Provide a dart package to import
  • Publish the repo as a package

FAQs

Package last updated on 16 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc