flutter - 如果 Condition 没有在内部调用
问题描述
以下代码中的我的 if 条件不起作用....
我认为我的 if 条件是错误的,但是代码应该调用 else 条件,但它没有这样做。
class polyline {
List<LatLng> _listltlg=[];
start_record() {
BackgroundLocation.startLocationService();
BackgroundLocation.getLocationUpdates((location) {
if(_listltlg.isEmpty){
print('2nd if statement');
_listltlg.add(LatLng(location.latitude, location.longitude));
}
else{
print('Else case');
}
});
}
解决方案
没错,第一次调用回调时,列表“_listltlg”为空。
推荐阅读
- reactjs - 在自定义钩子中设置多个状态
- git - Git 在几次拉取后应用一些修改
- kubernetes - kubectl - 如何在 Kubernetes 中检索默认标签的值?
- electron - 如何在 Electron 应用程序中禁用网络?
- firebase - Flutter Firestore 地理查询距我的位置一定距离
- angular - Angular:用于注入依赖的自定义装饰器(@Inject 包装器)
- python - 获取字典的某些部分
- excel - Excel,使用从 Web 获取数据,我的 URL 参数之一被忽略
- flutter - Flutter 或 Dart 分析器包没有正确响应
- python - 在 Python 中安装模块