How to use user-agent in webview-flutter Flutter?

Viewed 11625

I tried to use webview_flutter plugin in Flutter. But cannot find to set useragent in there. It's should be there right ? it's a basic function of webview. Is there any possibility way to achieve that ? Thank you in advance.

2 Answers
webview_flutter: ^0.3.13

introduced user agent, so now it could be used easily, like

WebView(
  userAgent: "random",
  initialUrl: "https://stackoverflow.com/questions/54102162/how-to-use-user-agent-in-webview-flutter-flutter",
)

Try to use the Flutter_webview_plugin here

you can add the below variables(including userAgent) as seen in their documentation:

Future<Null> launch(String url, {
   Map<String, String> headers: null,
   bool withJavascript: true,
   bool clearCache: false,
   bool clearCookies: false,
   bool hidden: false,
   bool enableAppScheme: true,
   Rect rect: null,
   **String userAgent: null,**
   bool withZoom: false,
   bool withLocalStorage: true,
   bool withLocalUrl: true,
   bool scrollBar: true,
   bool supportMultipleWindows: false,
   bool appCacheEnabled: false,
   bool allowFileURLs: false,
});
Related