我必须进行一些api调用:我收到一个错误from django.http.request import QueryDict
d = QueryDict(mutable=True)
d.setlist('emails', ['abc@abc.com', 'def@abc.com'])
d['emails']
# 'def@abc.com'
d.getlist('emails')
# ['abc@abc.com', 'def@abc.com']
d.appendlist('emails', 'foo@bar.baz')
d
# <QueryDict: {'emails': ['abc@abc.com', 'def@abc.com', 'foo@bar.baz']}>
d.urlencode()
# 'emails=abc%40abc.com&emails=def%40abc.com&emails=foo%40bar.baz'
,因为我无法在PlatformException(Error performing get, Failed to get document because the client is offline., null)
中使用provider,所以正在didChangeDependencies
中调用该方法。我不确定该怎么做。调试器指向initState
。我想知道我是否正确使用async / await,因为我的怀疑是,在写入数据getLegislatures()
之后读取数据(getLegislatures)有问题吗?这是执行调用的方法:
setElcectorate()
为完整起见,Future<List<LegTile>> getPlaces(BuildContext context) async {
final database = Provider.of<Database>(context, listen: false);
await database.setElcectorate(suburb, postcode); //Call to server and write to firestore...all ok
final result = await database.getElectorates(); // a get from Firestore..returns the data ok.
final legislatures = await database.getLegislatures(result); //problem here!!
return legislatures;
}
方法
getLegislatures()