Flutter ------- WebView加載網頁

在Flutter 加載網頁?也是有WebView的哦,和Android同樣web


1.添加依賴app

dependencies:
flutter_webview_plugin: ^0.2.1+2less

2.導入庫ide

import 'import 'package:flutter_webview_plugin/flutter_webview_plugin.dart'; //導入前須要配置ui

效果圖:url


代碼:spa

import 'package:flutter/material.dart';
import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';

class WebMain extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    List<Widget> titleContent = [];
    titleContent.add(new Text(
      "關於咱們",
      style: new TextStyle(color: Colors.white),
    ));
    titleContent.add(new Container(width: 50.0));
    // WebviewScaffold是插件提供的組件,用於在頁面上顯示一個WebView並加載URL
    return new WebviewScaffold(
      url:"https://blog.csdn.net/dickyqie",
      // 登陸的URL
      appBar: new AppBar(
        title: new Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: titleContent,
        ),
        iconTheme: new IconThemeData(color: Colors.white),
      ),
      withZoom: true,
      // 容許網頁縮放
      withLocalStorage: true,
      // 容許LocalStorage
      withJavascript: true, // 容許執行js代碼
    );
  }
}

 


WebView庫 詳細的說明文檔.net

https://pub.dev/packages/flutter_webview_plugin插件

相關文章
相關標籤/搜索