2

I am getting a user's fb profile picture using http.get, but the picture is very small and blurry, how can i get a better picture? Currently this is my code to get the image and store it:

final token = result.accessToken.token;
                          final graphResponse = await http.get('https://graph.facebook.com/v3.3/me?fields=name,picture,friends,email&access_token=${token}');
                          final profile = JSON.jsonDecode(graphResponse.body);
                          print(profile);
                          setState(() {
                            userProfile = profile;
                            _isLoggedIn = true;
                          });

Then later when i set the data in my db:

'photoUrl':userProfile["picture"]["data"]["url"],

The picture is extremely small and blurry since i'm getting a width and height of 50 inside the url idk how to change that though?

Potato
  • 509
  • 1
  • 6
  • 17
  • Have you checked the quality of the picture before adding to db? Try to check quality of pic before u add it to db, and then check its quality when u add it then retrieve it from db. Perhaps when you add it there's some option to set its size or so. – Abbas.M Jul 06 '19 at 21:50
  • Well the thing is when i get the image from facebook its a url with a width and height of 50, like thats included in the link and if i try to manually edit those numbers in the link i wont get the image anymore its a wrong link. So the quality of the image as soon as i get it from the api to when i store it and show it is always bad since its dimensions are small so idk how to request it with different dimensions. Im not aware if i can resize it when adding to firebase but i think if i do that itll just make it blurry since the original image from api was small – Potato Jul 06 '19 at 21:55

1 Answers1

9

See below for sample URL that specifies dimensions.

final graphResponse = await http.get(
    'https://graph.facebook.com/v2.12/me?fields=name,picture.width(800).height(800),first_name,last_name,email&access_token=${fbToken}');

This is really an FB Graph API question and it was answered here previously: Getting full-size profile picture

socasanta
  • 1,532
  • 9
  • 15