Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autofill password and email #488

Open
venky9885 opened this issue Aug 14, 2020 · 12 comments
Open

Autofill password and email #488

venky9885 opened this issue Aug 14, 2020 · 12 comments

Comments

@venky9885
Copy link

Environment

Flutter version:
Plugin version:
Android version:
iOS version:
Xcode version:
Device information:

Description

What you'd like to happen:

Alternatives you've considered:
Autofill email and password
Images:

@tneotia
Copy link
Contributor

tneotia commented Sep 7, 2020

Just use JS to do this, many examples on the web.

@rikousik
Copy link

rikousik commented Dec 4, 2020

@tneotia can you share any link ?

@ycv005
Copy link
Contributor

ycv005 commented Dec 19, 2020

That would very hard to detect field and fill them. You need to check each and every url.

@tneotia
Copy link
Contributor

tneotia commented Dec 19, 2020

That is correct, my solution was intended for accessing a single website through webview, like if you wanted to make a PWA app and save the user's login, autofilling it in the background on app start.

I use this method, autofilling my website's login or autofilling Google login (depending which way the user has created their account)

@aaron-chu
Copy link

aaron-chu commented Apr 13, 2021

In issue #598, the author said the Android autofill is solved in 5.0.5+3 with useHybridComposition: true. However, it still doesn't work even though I use the version 5.3.2 with useHybridComposition: true.

The following is an example to load github page, it should be able to auto fill the username and password when you are in the sign in page.

class InAppWebViewExampleScreen extends StatefulWidget {
  @override
  _InAppWebViewExampleScreenState createState() =>
      _InAppWebViewExampleScreenState();
}

class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
  final GlobalKey webViewKey = GlobalKey();

  InAppWebViewController? webViewController;
  InAppWebViewGroupOptions options = InAppWebViewGroupOptions(
      crossPlatform: InAppWebViewOptions(
        useShouldOverrideUrlLoading: true,
        mediaPlaybackRequiresUserGesture: false,
      ),
      android: AndroidInAppWebViewOptions(
        useHybridComposition: true,
      ),
      ios: IOSInAppWebViewOptions(
        allowsInlineMediaPlayback: true,
      ));

  late PullToRefreshController pullToRefreshController;
  late ContextMenu contextMenu;
  String url = "";
  double progress = 0;
  final urlController = TextEditingController();

  @override
  void initState() {
    super.initState();

    pullToRefreshController = PullToRefreshController(
      options: PullToRefreshOptions(
        color: Colors.blue,
      ),
      onRefresh: () async {
        if (Platform.isAndroid) {
          webViewController?.reload();
        } else if (Platform.isIOS) {
          webViewController?.loadUrl(
              urlRequest: URLRequest(url: await webViewController?.getUrl()));
        }
      },
    );
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(title: Text("InAppWebView")),
        body: SafeArea(
            child: Column(children: <Widget>[
          Expanded(
            child: Stack(
              children: [
                InAppWebView(
                  key: webViewKey,
                  // contextMenu: contextMenu,
                  initialUrlRequest:
                      URLRequest(url: Uri.parse('https://github.com/')),
                  // initialFile: "assets/index.html",
                  initialUserScripts: UnmodifiableListView<UserScript>([]),
                  initialOptions: options,
                  pullToRefreshController: pullToRefreshController,
                  onWebViewCreated: (controller) {
                    webViewController = controller;
                  },
                  onLoadStart: (controller, url) {
                    setState(() {
                      this.url = url.toString();
                      urlController.text = this.url;
                    });
                  },
                  androidOnPermissionRequest:
                      (controller, origin, resources) async {
                    return PermissionRequestResponse(
                        resources: resources,
                        action: PermissionRequestResponseAction.GRANT);
                  },
                  shouldOverrideUrlLoading:
                      (controller, navigationAction) async {
                    return NavigationActionPolicy.ALLOW;
                  },
                  onLoadStop: (controller, url) async {
                    pullToRefreshController.endRefreshing();
                    setState(() {
                      this.url = url.toString();
                      urlController.text = this.url;
                    });
                  },
                  onLoadError: (controller, url, code, message) {
                    pullToRefreshController.endRefreshing();
                  },
                  onProgressChanged: (controller, progress) {
                    if (progress == 100) {
                      pullToRefreshController.endRefreshing();
                    }
                    setState(() {
                      this.progress = progress / 100;
                      urlController.text = this.url;
                    });
                  },
                  onUpdateVisitedHistory: (controller, url, androidIsReload) {
                    setState(() {
                      this.url = url.toString();
                      urlController.text = this.url;
                    });
                  },
                  onConsoleMessage: (controller, consoleMessage) {
                    print(consoleMessage);
                  },
                ),
                progress < 1.0
                    ? LinearProgressIndicator(value: progress)
                    : Container(),
              ],
            ),
          ),
          ButtonBar(
            alignment: MainAxisAlignment.center,
            children: <Widget>[
              ElevatedButton(
                child: Icon(Icons.arrow_back),
                onPressed: () {
                  webViewController?.goBack();
                },
              ),
              ElevatedButton(
                child: Icon(Icons.arrow_forward),
                onPressed: () {
                  webViewController?.goForward();
                },
              ),
              ElevatedButton(
                child: Icon(Icons.refresh),
                onPressed: () {
                  webViewController?.reload();
                },
              ),
            ],
          ),
        ])));
  }
}

@xiejinpeng007
Copy link

I have the same problem

@TobiasHeidingsfeld
Copy link

Any update on this? Looking for the same feature for Android and iOS

@andychucs
Copy link

any solution? Android can auto suggest autofill by website. but ios cannot. looks like only safari can autofill?

@xiejinpeng007
Copy link

xiejinpeng007 commented Oct 9, 2023

I think this is a bug from flutter sdk in Android , and has been fixed in latest version. check this flutter/flutter#92165

@FaFre
Copy link

FaFre commented Jun 21, 2024

Did anyone manage to get the autofill work on Android (inappwebview 6.x)?

@andychucs
Copy link

andychucs commented Sep 14, 2024

any solution? Android can auto suggest autofill by website. but ios cannot. looks like only safari can autofill?

I noted that Brave browser is able to autofill, so it is possible on iOS. Maybe we should try to find how they do this. https://github.com/brave/brave-core
I am not sure where they implement autofill.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants