Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

286
Visualizações
Call javascript from dart native/flutter

I've seen that calling js is definitely possible from dart web using the dart js package, however haven't found a way to do this from dart native. For some more context - I have an npm package written in javascript and I would like to invoke this from a flutter mobile app. Calling the javascript directly or somehow wrapping it in dart or some other way are all fine for me, however rewriting it in dart is not possible as said npm package depends on a very specific cryptography javascript package to which no equivalent exists in dart, and recreating said cryptography package would bear a huge workload and significant security risks. Thank you in advance!

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Embed a WebView in your app and use it to run JavaScript:

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';

main() {
  runApp(_Test());
}

class _Test extends StatelessWidget {
  final completer = Completer<WebViewController>();

  @override
  Widget build(BuildContext context) {
    var js = '1+1';
    return MaterialApp(
      home: Scaffold(
        body: Stack(
          children: [
            WebView(
              javascriptMode: JavascriptMode.unrestricted,
              onWebViewCreated: (controller) {
                if (!completer.isCompleted) completer.complete(controller);
              },
            ),
            Center(
              child: FutureBuilder(
                future: completer.future.then((controller) {
                  return controller.runJavascriptReturningResult(js);
                }),
                builder: (context, snapshot) {
                  if (snapshot.hasError) throw snapshot.error!;
                  if (!snapshot.hasData) return Container();
                  return Text('$js=${snapshot.data}', style: Theme.of(context).textTheme.headline2);
                },
              ),
            ),
          ],
        ),
      ),
    );
  }
}
about 4 years ago · Juan Pablo Isaza Relatório

0

If all you need is the Circom library, someone has already implemented it in Dart. You can check out the Hermez SDK package and see how they did it. Specifically, in this file.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda