Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

Page updated Apr 29, 2024

Listen to auth events

AWS Cognito Auth Plugin sends important events through Amplify Hub.

Amplify Flutter v0 is now in Maintenance Mode until July 19th, 2024. This means that we will continue to include updates to ensure compatibility with backend services and security. No new features will be introduced in v0.

Please use the latest version (v1) of Amplify Flutter to get started.

If you are currently using v0, follow these instructions to upgrade to v1.

1// Do not forget to import the following for StreamSubscription
2import 'dart:async';
3
4StreamSubscription<HubEvent> hubSubscription = Amplify.Hub.listen([HubChannel.Auth], (hubEvent) {
5 switch(hubEvent.eventName) {
6 case 'SIGNED_IN':
7 print('USER IS SIGNED IN');
8 break;
9 case 'SIGNED_OUT':
10 print('USER IS SIGNED OUT');
11 break;
12 case 'SESSION_EXPIRED':
13 print('SESSION HAS EXPIRED');
14 break;
15 case 'USER_DELETED':
16 print('USER HAS BEEN DELETED');
17 break;
18 }
19});