【发布时间】:2021-11-08 09:02:15
【问题描述】:
我写了一个谷歌云function,它返回一个数字。我想在我的颤振应用程序上读到这个数字,但我做不到。貌似flutter http依赖只能读取JSON格式。
我已尝试在云函数中格式化响应输出,但我不断收到错误消息,提示未找到烧瓶。我正在使用 Python 3.9,根据this 链接,默认情况下应该有烧瓶。我也尝试将输出格式化为字典,然后使用json.dumps(x),但这也不起作用。
这个函数应该是检索数据:
Future<http.Response> dataHTTP() async {
return http.get(
Uri.parse(
('https://us-east4-persuasive-yeti-325421.cloudfunctions.net/open_seats?college' +
college.text.toUpperCase() +
'&dept=' +
department.text.toUpperCase() +
'&course=' +
course.text.toUpperCase() +
'§ion=' +
section.text.toUpperCase()),
),
);
}
我想将输出打印到终端以检查一切是否正常。但是下面的代码 sn-p 返回以下内容:Instance of 'Future<Response>'
TextButton(
onPressed: () async {
print(dataHTTP().toString());
},
child: Text('Enter'),
)
如何返回数据本身而不是对象实例?在云函数中格式化输出,还是在客户端处理更容易?
【问题讨论】:
标签: json flutter http flutter-web