1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] How to load an HTML page with relative CSS paths in Flutter Windows app using...

Discussão em 'Mobile' iniciado por Stack, Novembro 8, 2024 às 06:22.

  1. Stack

    Stack Membro Participativo

    I am trying to load an HTML page in my Flutter Windows app using the inAppWebView package (latest version), and the HTML page contains relative paths to external CSS files.

    The HTML page is located at the following path:

    C:\Users\akshay.verma\Documents\MyFiles\cover.html

    The HTML file content looks like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html>
    <!-- PDFTron PDFNet Generated! Version: 9.4.0-fd07a7defc -->
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta charset="UTF-8" />
    <title>Page 1 of 802</title>
    <link type="text/css" rel="stylesheet" href="css/Styles.css" />
    <meta content="width=1127.52, height=1378.08" name="viewport" />
    <link rel="stylesheet" type="text/css" href="css/page0001.css" />
    </head>
    <body style="margin:0;background-color:#808080;width:1127.52px;height:1378.08px;">
    <!-- Content -->
    </body>
    </html>



    The CSS files are also placed at the same location as HTML file.

    C:\Users\akshay.verma\Documents\MyFiles\css\Styles.css

    The problem is inappwebview is not loading the CSS file.

    Using the below code to load the HTML content. This one is not loading the CSS file

    InAppWebView(
    initialData: InAppWebViewInitialData(
    data: htmlContent,
    baseUrl: WebUri("C:\\Users\\akshay.verma\\Documents\\MyFiles\\"),
    ),


    Code which is working fine. This is loading the CSS also.

    InAppWebView(
    initialUrlRequest: URLRequest(url:WebUri("C:\\Users\\akshay.verma\\Documents\\MyFiles\\cover.html")
    ),


    I need to use the initialData property to set the modified HTML Content. Kindly help here.

    Continue reading...

Compartilhe esta Página