How to login with cognito in flutter web?

2,363

Try using this package: https://pub.dev/packages/amazon_cognito_identity_dart_2

I've been using it for a while, and it works fine on Android and Web; I think I even got it working on iOS.

What Amplify team did with official Flutter package was use a wrapper around existing Android and iOS implementation (by using platform channel). I guess this is a reason it will take them a while to sort out web.

The above package is based on amplify-js, and re-written in dart, so it will compile on any platform.

In my project workspace I created two separate projects: one with amplify to create back-end objects, and one flutter project. So, like in your case, my flutter project connects to an existing AWS backed.

Share:
2,363
Prashant Kumar Singh
Author by

Prashant Kumar Singh

Updated on December 19, 2022

Comments

  • Prashant Kumar Singh
    Prashant Kumar Singh over 1 year

    I built a flutter web application and have previously whole backend setup on AWS. So I want to use my existing userpools from cognito in my app. But just got know that AWS amplify for flutter in only supported in android and ios,not for web. Can you suggest me any solution for this?

  • Prashant Kumar Singh
    Prashant Kumar Singh about 3 years
    But the problem is that this package takes very much time in authentication(around 8 seconds), that is obviously not a good user experience.
  • Andrija
    Andrija about 3 years
    You are right; I never realized that. I'm using a SharedPreferences to store user session, so you only need to login once in a while. Anyway - there is an open issue for this page: github.com/furaiev/amazon-cognito-identity-dart-2/issues/123
  • Gary Zhang
    Gary Zhang over 2 years
    @Andrija I tried to follow Case 19 of this package, but WebView is not supported yet for Flutter web to bring up my federated login page. How did you get past this? Thanks.
  • Andrija
    Andrija over 2 years
    I didn't use the federated login, just the basic Cognito process. I just rendered Flutter page with two text boxes and a button, and used this package as described in the examples.
  • Jared Hasson
    Jared Hasson about 2 years
    @PrashantKumarSingh Version 2.0.0 of the amazon_cognito_identity_dart_2 package has improved the authentication time by a considerable amount.
  • LearnFlutter
    LearnFlutter almost 2 years
    Hey im having a problem with google sign in using the package you recommended. Here is the code pastebin.com/M6JgcTV9 but basically when im pressing the button it is not showing anything and im trying to do google sign in using the package
  • LearnFlutter
    LearnFlutter almost 2 years
    is there any video or article that uses amazon_cognito_identity_dart_2 package and does google sign in using web view
  • Andrija
    Andrija almost 2 years
    Will use case 19 on this page fix your problem: pub.dev/packages/amazon_cognito_identity_dart_2
  • NiiTii
    NiiTii almost 2 years
    has anyone solved the problem with federated login with this package? I'm referring to "Use Case 19"