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

345
Visualizações
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 Respostas
Responde à pergunta

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 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