Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

341
Vistas
How can I use main.dart variable in my JS file?

I'm trying to create a calling app using flutter and I've created the backend using a node.js. This is how my main.dart file in flutter looks like:

import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:io';
import 'package:flutter/services.dart';
import 'package:flutter_dialpad/flutter_dialpad.dart';

import 'dart:js';
import 'package:js/js.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        backgroundColor: Colors.black,
        body: SafeArea(
            child:
            DialPad(
                enableDtmf: true,
                outputMask: "(000) 000-0000",
                backspaceButtonIconColor: Colors.red,
                makeCall: (number){
                  print(number);
                }
            )
        ),
      ),
    );
  }
}

I want to use this "number" variable in my app.js file which looks like this:

const accountSid = '***';
const authToken = '***';
const client = require('twilio')(accountSid, authToken);

client.calls.create({
          url: 'http://demo.twilio.com/docs/voice.xml',
         to: '+10000000',
         from: '+1000000',
       }, function(err, call){
           if (err) {
               console.log(err);
           } else {
            console.log(call.sid);
           }
       })

I want to be able to use the "number" variable from my main.dart file in the "to" field in my app.js file. Please help me out...

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

What you need is a way to pass data between applications, and the easiest way for that would be through a REST API You can use the HTTP module in NodeJS or a third-party package like Express and set up a POST Route to your NodeJS Server, where the number is sent as data. Once the data is received on your server, you can call your Twilio function, and send a response back. On Flutter, you can use the http package to make the API call.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda