Get the user information
To get the user information just call to getUserData
method.
final userData = await FacebookAuth.instance.getUserData();
// or FacebookAuth.i.getUserData()
Only call
getUserData
method if you have an user Logged
Expected response Map<String,dynamic>
:
{
"email" = "dsmr.apps@gmail.com",
"id" = 3003332493073668,
"name" = "Darwin Morocho",
"picture" = {
"data" = {
"height" = 50,
"is_silhouette" = 0,
"url" = "https://platform-lookaside.fbsbx.com/platform/profilepic/?asid=3003332493073668",
"width" = 50,
},
}
}
by default the
getUserData
method requests thename, email and picture profile
. If you want to get to other user info you need to use thefields
param.
For example if you want to get the user birthday, friends, gender and link you need first make a login request with these permissions.
final result = await FacebookAuth.i.login(
permissions: ['email', 'public_profile', 'user_birthday', 'user_friends', 'user_gender', 'user_link'],
);
if (result.status == LoginStatus.success) {
final userData = await FacebookAuth.i.getUserData(
fields: "name,email,picture.width(200),birthday,friends,gender,link",
);
}