title: Flutter WebView with Basic Authentication
body: <p>I am loading a web page and I want to login with Basic Authentication, I have experience with Swift and able to do Basic Auth like below but I couldn't implement Basic Auth for Flutter version of my app.</p>
  
  <p>---- Swift Code ---</p>
  
  <pre><code>func configureView() {
          let username = "user"
          let password = "pass"
          let userPasswordString = "\(user):\(pass)"
          let userPasswordData = userPasswordString.data(using: String.Encoding.utf8)
          let base64EncodedCredential = userPasswordData!.base64EncodedString(options:[])
          let authString = "Basic \(base64EncodedCredential)"
          let url = URL(string: "http://myurl")
          var request = URLRequest(url: url!)
          request.setValue(authString, forHTTPHeaderField: "Authorization")
          webView.scalesPageToFit = true
          webView.loadRequest(request)
      }
  </code></pre>
  
  <p>--- Flutter WebView ---> load webview with URL</p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'dart:convert';
  import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';
  
  class AddShipment extends StatefulWidget {
  
    final String url;
  
    AddShipment(this.url);
  
    @override 
    State&lt;StatefulWidget&gt; createState() {
      return new _AddShipment();
    }
  }
  
  class _AddShipment extends State&lt;AddShipment&gt; {
    final flutterWebviewPlugin = new FlutterWebviewPlugin();
  
    @override
    void initState() {
      super.initState();
  
      flutterWebviewPlugin.close();
    }
  
    @override
    void dispose() {
  
      flutterWebviewPlugin.dispose();
  
      super.dispose();
    }
  
  
    @override
    Widget build(BuildContext context) {
      return new WebviewScaffold(
        appBar: new AppBar(
            title: new Text("WebView"),
            centerTitle: true,
            backgroundColor: Colors.blue[900],
            elevation: 0.0,
        ),
        url: widget.url,
        withJavascript: true,
      );
    }
  }
  </code></pre>
  
  <p>What is the correct way to create an urlRequest? I tried:</p>
  
  <pre><code>static Future&lt;Response&gt; getURL(
        final String username, final String password) {
      final String url = 'http://myurl';
      final String auth =
          'Basic ' + base64Encode(utf8.encode('$username:$password'));
      return http.get(url, headers: {'Authorization': auth});
  }
  </code></pre>