Autofill password field not triggering on (Android devices) for Flutter

mtambucho
mtambucho
Community Member

Password field in Flutter, working fine with Iphones but for Android the password field is never autofilling.


1Password Version: Not Provided
Extension Version: Not Provided
OS Version: Not Provided

«1

Comments

  • Hey @mtambucho. Are you noticing this issue in any Flutter app in particular, or have you had this issue across multiple Flutter apps? If it's any app in particular, can you let me know which, so we can test it out on our end?

  • mtambucho
    mtambucho
    Community Member
    edited March 2022

    Hi peri, I'm trying to develop an application and fill the username and pass with 1password, I tried with many Flutter versions but still not working, I don't know if exists a Flutter App working good with 1pass.
    With the same code, for iphones works ok, but the issue is only with Android.

  • Hello @mtambucho thanks for the information. I can see that Peri filed an issue with our development team so we can investigate further: ref: android-1524

  • mtambucho
    mtambucho
    Community Member

    Thanks! hope it can be solved soon

  • Thanks for reporting this, @mtambucho!

  • @mtambucho Thanks for letting us know that 1Password is not filling into the password field in your Flutter app on Android.

    After trying out a few different Flutter apps, I can confirm that the input type for the field is not shared with 1Password. This is an additional requirement that 1Password has for password fields where the input type must also be of a password type. Since we cannot verify the input type, 1Password will not recognize the field for filling the user’s password.

    We are excited to see Autofill support making its way into Flutter and we hope that we'll continue to see support for other Autofill features including sharing the input type in the near future.

    I hope this helps! Let us know if you have any questions.

  • sjoulbak
    sjoulbak
    Community Member

    Hi @saad

    Thank you for sharing this information. I'm currently experiencing the same issue on iOS. Can you perhaps share a bit more information with what you mean with "the input type must also be of a password type". Can you perhaps point where we can find this in the iOS/Android documentation? (note: I'm not referring to Flutter, since it probably does not exist there yet)

  • Hi @sjoulbak! I think you are experiencing a different problem because Autofill works different on iOS.

    On Android, 1Password is responsible for iterating through a filtered view hierarchy to identify fields for filling. This is where 1Password will look at the view's input type when it’s looking for a password field.

    On iOS, Apple does that work for us and only tells 1Password when it needs the username and password value for a given URL.

  • mtambucho
    mtambucho
    Community Member

    @saad there is going to be a workaround from 1password team for this or you need for wait to Flutter for do this?

  • @mtambucho this feature needs to be supported in Flutter to match the native Android app experience.

  • AugustoResende
    AugustoResende
    Community Member

    Issue created at Flutter's GitHub
    https://github.com/flutter/flutter/issues/105241

  • Hi @AugustoResende, thanks for filing and sharing the link with us!

  • ricardoboss
    ricardoboss
    Community Member

    Over on the flutter issue, they are saying you need to find another way to find the auto-fillable input fields... Can one of you decide who has to implement it? Can we as the users do anything to help implement it on either side?

  • Hi @ricardoboss! Could you share the app that you're having issues with? I'll do another round of testing and add my notes to the Github issue to help.

  • ricardoboss
    ricardoboss
    Community Member

    Hi @saad!

    This is a minimal example showing what I expect 1password to be able to fill: https://github.com/ricardoboss/flutter_password_autofill

    When tapping on the username field, it should suggest logins I have used within the app or suggest to create a new login.
    When a login is selected, it should fill username and password field.
    When the submit button is pressed (aka the AutofillGroup is disposed and the appropriate onDisposeAction is executed by it), 1password should prompt the user if they want to save the entered details in case they are different than what was filled in automatically.

    Hope this helps.

  • On behalf of @saad, thanks for providing that example @ricardoboss! I'm sure this will be really useful in figuring out what's not quite working. 🙏🏻

  • rekire
    rekire
    Community Member
    edited October 2022

    What's the current status here? I'm right now working on a login in a Flutter app where I would like to add also support for 2FA.

    Is there maybe a way like provided by Google with Smartlock for Passwords to query explicitly 1password for logins?

  • Thanks for following up with us. I've reached out to the team regarding your questions and will update when we have any information to share.

  • peri
    edited December 2022

    @ricardoboss @rekire @mtambucho @AugustoResende

    I did some research on this and found a way for Flutter developers to get Autofill working with 1Password, but it will require a bit of work. Flutter provides a way to host native Android views, which would allow you to apply an InputType to your text fields as well as Autofill hints.

    For example:
    textView.inputType = android.text.InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS
    and
    textView.inputType = android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD

    This will need to be done in the Android platform side of the code, but you can create a class which you can then input into your Dart code.

    I spent some time working on a dummy app, so I have a working example if anyone needs.

  • rekire
    rekire
    Community Member

    Please share anything which might help

  • tjarvstrand
    tjarvstrand
    Community Member

    @peri Great effort and interesting solution!

    Unfortunately it doesn't solve the issue in the grand scheme of things as Flutter's native platform views come with a lot of caveats and tradeoffs and are still experimental on several platforms. Not to mention that you would have to write your own implementations of all widgets that use TextField under the hood (eg. TextFormField).

    So, while I applaud this, I just wanted to make it clear to the 1Password folks that this is sadly not a suitable workaround for most developers.

  • nealsanche
    nealsanche
    Community Member
    edited January 2023

    The inputType for Flutter fields always returns 0, it seems. I've run an autofill sample from this codebase (after migrating it to the latest Room which causes compile errors), https://github.com/android/input-samples/tree/main/AutofillFramework and this code can detect password fields and offer to fill them based on the 'hint' field alone. Would it be possible to have a user setting in 1Password that relaxes the inputType = password stipulation and allows autofill on fields with a hint of 'password'? Just curious if that'd be acceptable or not?

    This is what the code sees when a password field is focused in a Flutter app I'm working on. In the sample code it iterates through the view nodes that flutter is producing, and it is able to properly get the autofill hints, however asking what the inputType of the node is always returns 0. The AutoFillType is TEXT which seems fine. Here's a little output from the run:

    D/BasicService: inputType = 0
    D/BasicService: autofillType = 1
    D/BasicService: autoFillHints = [password]
    V/BasicService: Setting hint 'password' on 1073741824:543304862@2145823823
    D/BasicService: autofillable fields:{password=1073741824:543304862@2145823823}

    So, I guess my question stands, can 1Password just use the autoFillType and autoFillHints to allow flutter apps to be autofilled, like Google's sample app does?

  • peri
    edited January 2023

    @tjarvstrand Thanks for the kudos!

    This is by no means a be-all and end-all solution. It was just what I came up with as a possibility while we see if there's other ways around this. Using the demo app @ricardoboss made as an example, there is only one Autofill group with two fillable fields, which is something that can be done with my suggestion. There's also a plugin I found which does the same thing I suggested (only better since i'm not a Flutter developer 😁).

    I hear you and I'm looking into ways to improve filling in Flutter apps on our end. I hope to have something to report soon!

  • ricardoboss
    ricardoboss
    Community Member

    @peri Thank you for working on this!

    I looked at the repository of yours but I'm having trouble finding the relevant parts of code. Is there a way to add your solution to an existing Flutter app? Can you highlight any code related to the problem?

    Thanks!

  • Hey @ricardoboss!. I've basically just adapted what's in this Flutter guide:

    Hosting native Android views in your Flutter app with Platform Views

    The difference is that I created the text fields in the Kotlin code rather than Dart. The relevant part is that I created a NativeView.kt class where I initialize the text field:

    internal class NativeView(context: Context, id: Int, creationParams: Map<String?, Any?>?) :
        PlatformView {
        private val textView: EditText
    
        override fun getView(): View {
            return textView
        }
    
        override fun dispose() {}
    
        init {
            textView = android.widget.EditText(context)
            textView.setHint("username")
            textView.setAutofillHints(android.view.View.AUTOFILL_HINT_EMAIL_ADDRESS)
            textView.setBackgroundColor(Color.rgb(230, 230, 250))
            textView.setGravity(android.view.Gravity.CENTER)
    
        }
    

    Then I refer to the view in the Dart code, rather than using the TextField widget.

    That said, hopefully we can get something better than this workaround out as a solution. I'll keep you all posted here!

  • ytomassen
    ytomassen
    Community Member

    @peri thank you for working on this.

    I am also having trouble with 1Password autofill for our Flutter app on Android.
    I spent a lot of time debugging this issue but could not find a workaround.

    I created an Android app with a TextField which had the inputType="textPassword", and 1Password did trigger in that case.
    This confirms the suspicion that the problem has something to do with Flutter incorrectly reporting the inputType to the AutoFill service.

    However other Password managers who also work with the Autofill framework - like Bitwarden - seem to be working fine without this additional requirement for inputType. Maybe 1Password could look into doing something similar to the Bitwarden Android app.

    Thanks!

  • Indeed @ytomassen. The Flutter TextField doesn't have an inputType, which is why it's not working there. I'm currently looking into ways to improve the experience for Flutter developers without needed development on the Flutter end, and I'll keep you posted when I have something to report!

  • @ytomassen @tjarvstrand @nealsanche @ricardoboss @rekire @mtambucho @AugustoResende

    I made a change in our latest beta that should allow filling in Flutter apps. Give it a try!

  • nealsanche
    nealsanche
    Community Member

    I have given it a try and it works! Thanks very much.