WebController constructor

WebController()

Implementation

WebController() {
  if (isAndroid() || isIOS()) {
    _controller = WebViewController()
      ..setJavaScriptMode(JavaScriptMode.unrestricted)
      ..setBackgroundColor(const Color(0xfff2f2f2))
      ..setNavigationDelegate(NavigationDelegate(onPageStarted: (url) async {
        if (onPageStarted != null) {
          var title = await _controller?.getTitle();
          onPageStarted?.call(url, title);
        }
      }, onPageFinished: (url) async {
        if (onPageFinished != null) {
          var title = await _controller?.getTitle();
          onPageFinished?.call(url, title);
        }
      }));
  }
}