【发布时间】:2021-07-10 16:00:08
【问题描述】:
class Stations extends ChangeNotifier {
StationListState state = StationListState(loading: false, stations: []);
Future<void> getMachedStations() async {
state = state.copyWith(loading: true);
notifyListeners();
List<Map<String, dynamic>> aroundStations =
await FindNearStation().getLocation();
print(aroundStations.length);
var subwaysRef = FirebaseFirestore.instance.collection('subways');
var stations = aroundStations.map((searchedElement) async {
String subwayStationName = yuk(searchedElement['subwayStationName']);
try {
print(' ::::: ${searchedElement['line']}');
var lineRef = await subwaysRef
.doc(searchedElement['line'])
.collection(subwayStationName)
.get();
return SubwayStation.fromDoc(lineRef.docs[0]);
} catch (e) {
state = state.copyWith(loading: false);
}
});
state = state.copyWith(loading: false, stations: stations); // <-- Error (stations : stations)
}
}
我尝试获取返回的列表,但出现错误:
参数类型“Iterable
我该如何解决?
【问题讨论】:
标签: flutter