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

1K
Visualizações
Flutter webview_flutter_plus webview error Uncaught ReferenceError: function is not defined

I am using webview_flutter_plus with flutter and using local files from assets folder. Page is loading fine but sometimes (every now and then), I keep getting below error in console even though I have setUserData() function setup in js file. Surprisingly sometimes it works and prints through js file.

I/chromium( 7190): [INFO:CONSOLE(1)] "Uncaught ReferenceError: setUserData is not defined", source: http://localhost:42369/assets/html/home.html (1)

Function in js file:

function setUserData(json) {
    console.log(json);
}

First I load data from SQFLite and display on webpage. After that if device is online, app downloads data from online server and updates SQFLite. Below is the dart file:

late WebViewPlusController _webViewPlusController;
Timer? timer;
bool _webViewInitialized = false;

void _checkIfWebViewInitialized(){
    timer = Timer.periodic(const Duration(seconds: 1), (Timer t) {
        if(_webViewInitialized){
            timer?.cancel();
            _getSqliteDetails();
        }
    });
}

Future<void> _getSqliteDetails() async {
    final userDetails = Map.of(await UserProfileCrud.getUserDetailsByDisplayId(1917));
    if(userDetails.isNotEmpty) {
        userDetails['status'] = 'Success';
        final encodedUserData = convert.jsonEncode(userDetails);

        _webViewPlusController.webViewController.runJavascript("setUserData('$encodedUserData')");
    }
    // Check Online Server Data
}

@override
Widget build(BuildContext context) {
    return Scaffold(
        body: WebViewPlus(
            javascriptMode: JavascriptMode.unrestricted,
            initialUrl: 'assets/html/home.html',
            onWebViewCreated: (controller){
                _webViewPlusController = controller;
                //CookieManager().clearCookies();
                setState((){
                    _webViewInitialized = true;
                });
            },
        ),
    );
}

Is there any other way to it that I am unaware of? Kindly help as new to flutter.

Thanks in advance.

about 4 years ago · Juan Pablo Isaza
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