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

277
Visualizações
I cant use java script on flutter

My JavaScript code is not working. I want to make a WebView application via flutter. but I want to remove some sections or customize some properties using JavaScript on flutter. I also removed header and footer but I cant customize container padding of the website using JavaScript. Its not working.

Here is the code:

import 'package:flutter/material.dart';
import 'package:flutter_application_1/progress1.dart';
import 'package:webview_flutter/webview_flutter.dart';

void main() {
  runApp(MaterialApp(
    title: "Webview App",
    home: Scaffold(
      appBar: AppBar(
        title: Text("University Of Global Village"),
        centerTitle: true,
      ),
      body: MyApp(),
    ),
  ));
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      child: WebViewState(),
    );
  }
}

class WebViewState extends StatefulWidget {
  const WebViewState({Key? key}) : super(key: key);

  @override
  State<WebViewState> createState() => _WebViewStateState();
}

class _WebViewStateState extends State<WebViewState> {
  int position = 1;
  @override
  WebViewController? controller;

  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        child: IndexedStack(
          index: position,
          children: [
            WebView(
              initialUrl: "https://ugv.edu.bd/notice",
              javascriptMode: JavascriptMode.unrestricted,
              onPageStarted: (Value) {
                setState(() {
                  position = 1;
                });
              },
              onPageFinished: (value) {
                setState(() {
                  position = 0;

                  controller?.evaluateJavascript(
                      "document.getElementsByClassName('header')[0].style.display ='none'");

                  controller?.evaluateJavascript(
                      "document.getElementsByClassName('inner-header')[0].style.display ='none'");

                  controller?.evaluateJavascript(
                      "document.getElementsByClassName('footer')[0].style.display ='none'");

                  controller?.evaluateJavascript(
                      "document.getElementsByClassName('container')[0].style.padding-top ='20px !important'");

                  
                });
              },
              onWebViewCreated: (controller) {
                this.controller = controller;
              },
            ),
            Container(
              child: Center(
                child: CircularProgressIndicator(),
              ),
            )
          ],
        ),
      ),
    );
  }
}

Website: https://ugv.edu.bd/notice

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

0

"padding-top" is not correct.

Your code;

"document.getElementsByClassName('container')[0].style.padding-top ='20px !important'");

You must change like this;

"document.getElementsByClassName('container')[0].style.paddingTop ='20px !important'");

You can more information about padding-top on w3

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