我正在尝试在Dart中编写一个小命令行库来使用Facebook API.我有一个类'fbuser',它获取auth-token和user-id作为属性,并且有一个方法'groupIds',它应该返回一个List,其中包含来自用户的所有组ID.
当我调用该方法时,它返回null,尽管在http响应之后调用了两个可能的返回.我做错了什么?
这是我的代码:
import 'dart:convert'; //used to convert json
import 'package:http/http.dart' as http; //for the http requests
//config
final fbBaseUri = "https://graph.facebook.com/v2.1";
final fbAppID = "XXX";
final fbAppSecret = "XXY";
class fbuser {
int fbid;
String accessToken;
fbuser(this.fbid, this.accessToken); //constructor for the object
groupIds(){ //method to get a list of group IDs
var url = "$fbBaseUri/me/groups?access_token=$accessToken"; //URL for the API request
http.get(url).then((response) {
//once the response is here either process it or return an error
print ('response received');
if …Run Code Online (Sandbox Code Playgroud)