我正在监听字符串更改的值,以便将其保存到本地数据库。它会多次触发保存数据。对于同一个值。是否有任何方法可以在更改时循环一次...
locationListener() async {
emit(LoadingListentLocState());
String? latLong;
final loc = FirebaseDatabase.instance.ref().child('h/location');
emit(LoadingListentLocState());
loc.onValue.listen((DatabaseEvent event) {
latLong = event.snapshot.value.toString();
CacheHelper.saveData(key: "latLong", value: latLong);
locationsState = true;
locationUpdated = true;
getMapStatus = true;
mapsStateMsg = MapStatesMsg(MapStates.LASTUPDATED);
loadingWebViewMap(latLong);
savingLocationToDB(latLong);
emit(UpdatedListentLocState());
});
}
1条答案
按热度按时间iqjalb3h1#
您可能会寻找“独特":
Distinct Description