signInWithLinkedIn method
Future<Map<String, dynamic> ?>
signInWithLinkedIn(
- BuildContext context, {
- Color? progressBarColors,
- bool? isDisplayProgressBar,
- required String redirectUrl,
- required String clientId,
- required String clientSecret,
- required PreferredSizeWidget? appBar,
- bool? destroySession,
Implementation
Future<Map<String, dynamic>?> signInWithLinkedIn(BuildContext context,
{Color? progressBarColors, bool? isDisplayProgressBar,
required String redirectUrl,
required String clientId,
required String clientSecret,
required PreferredSizeWidget? appBar,
bool? destroySession,
}) async {
ProgressDialog.show(context,progressBarColors??Colors.black,isDisplayProgressBar??false);
// Trigger the sign-in flow
try {
ProgressDialog.hide();
return Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => LinkedInUserWidget(
appBar: appBar,
destroySession: destroySession ?? true,
// redirectUrl: FirebaseKey.redirectUrl,
redirectUrl: redirectUrl,
clientId: clientId,
clientSecret: clientSecret,
projection: [
ProjectionParameters.id,
ProjectionParameters.localizedFirstName,
ProjectionParameters.localizedLastName,
ProjectionParameters.firstName,
ProjectionParameters.lastName,
ProjectionParameters.profilePicture,
],
onError: (UserFailedAction e) {
showToastMessage(e.toString());
print('Error: ${e.toString()}');
print('Error: ${e.stackTrace.toString()}');
},
onGetUserProfile: (UserSucceededAction linkedInUser) {
print(
'Access token ${linkedInUser.user.token.accessToken}');
print('User id: ${linkedInUser.user.userId}');
// print('User firstName: ${linkedInUser?.user?.firstName?.localized?.label}');
// String name=
/* loginAPI(context,linkedInUser?.user?.email?.elements[0]
?.handleDeep?.emailAddress,"",LoginType.linkedin.name,linkedInUser.user.userId,
linkedInUser?.user?.firstName?.localized?.label);*/
Map<String,dynamic> user=new Map();
user["id"]=linkedInUser?.user.userId;
user["firstName"]=linkedInUser?.user?.firstName?.localized?.label;
user["lastName"]=linkedInUser?.user?.lastName?.localized?.label;
user["email"]=linkedInUser?.user?.email?.elements?[0]?.handleDeep?.emailAddress;
user["profileImageUrl"]=linkedInUser?.user?.profilePicture?.displayImageContent
?.elements?[0]?.identifiers?[0]?.identifier;
/*setState(() {
logoutUser = false;
});*/
Navigator.pop(context,user);
},
),
fullscreenDialog: true,
),
);
} catch (e) {
ProgressDialog.hide();
print(e.toString());
return null;
}
return null;
}