Created
October 16, 2021 17:07
-
-
Save vaygeth89/6f5d044a5b895410720a70cb1f42d98d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:tutorial_flutter_minimalist_authentication/cubit/user_authentication_cubit.dart'; | |
import 'package:tutorial_flutter_minimalist_authentication/pages/sign_in_page.dart'; | |
import 'package:tutorial_flutter_minimalist_authentication/widgets/protected_widget.dart'; | |
import 'package:flutter_bloc/flutter_bloc.dart'; | |
class UserProfilePage extends StatelessWidget { | |
const UserProfilePage({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
final userAuthCubit = context.watch<UserAuthenticationCubit>(); | |
return ProtectedWidget( | |
onAuthenticated: (context, authData) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("Profile Page"), | |
actions: [ | |
IconButton( | |
onPressed: () { | |
userAuthCubit.logoutUser(); | |
}, | |
icon: Icon(Icons.logout)) | |
], | |
), | |
body: Center( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
crossAxisAlignment: CrossAxisAlignment.center, | |
children: [ | |
Text("User Id:" + authData.id), | |
SizedBox( | |
height: 10, | |
), | |
Text("Auth Token:" + authData.accessToken), | |
], | |
), | |
), | |
); | |
}, | |
onUnauthenticatedChild: const SignInPage()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment