Я выполняю следующий процесс:
- , чтобы получить данные из облачного пожарного хранилища
- , чтобы использовать адрес данных в геолокации для поиска широты и долготы
для создания новой коллекции облачного пожарного хранилища с предыдущими данными, а также широтой и долготой.
К сожалению, в облачном пожарном хранилище не создано ни одной коллекции, и я получаю сообщение об ошибке, которое пока не удалось устранить.
Функция, созданная для использования геокодирования
upload() async{
List<Map<dynamic,dynamic>> listaFornecedorNovo = [];
Firestore db = Firestore.instance;
Map<dynamic,dynamic> fornecedorNovo = Map();
QuerySnapshot querySnapshot = await db.collection("baseDados").getDocuments();
for( DocumentSnapshot item in querySnapshot.documents){
var dados = item.data;
fornecedorNovo["nome"]= dados["nome"];
fornecedorNovo["localizacao"]= dados["localizacao"];
fornecedorNovo["email"]= dados["email"];
fornecedorNovo["telefone"]= dados["nome"];
fornecedorNovo["site"]= dados["site"];
//localizacao = address
List<Placemark> listaLatLong = await Geolocator().placemarkFromAddress(dados["localizacao"]);
Placemark local = listaLatLong[0];
fornecedorNovo["latitude"] = local.position.latitude;
fornecedorNovo["longitude"] = local.position.longitude;
listaFornecedorNovo.add(fornecedorNovo);
}
for( Map map in listaFornecedorNovo) {
db.collection("dadosComLatLong").add(map);
} }
Ошибка
E/flutter ( 7538): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(ERROR_GEOCODING_ADDRESS, grpc failed, null)
E/flutter ( 7538): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
E/flutter ( 7538): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321:33)
E/flutter ( 7538): <asynchronous suspension>
E/flutter ( 7538): #2 Geolocator.placemarkFromAddress (package:geolocator/geolocator.dart:239:30)
E/flutter ( 7538): #3 _EntradaState._encontraFornecedores (package:solisbr/Telas/Entrada.dart:512:57)
E/flutter ( 7538): <asynchronous suspension>
E/flutter ( 7538): #4 _EntradaState._posicaoUsuario (package:solisbr/Telas/Entrada.dart:160:5)
E/flutter ( 7538): #5 _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:73:64)
E/flutter ( 7538): #6 _rootRunUnary (dart:async/zone.dart:1134:38)
E/flutter ( 7538): #7 _CustomZone.runUnary (dart:async/zone.dart:1031:19)
E/flutter ( 7538): #8 _FutureListener.handleValue (dart:async/future_impl.dart:139:18)
E/flutter ( 7538): #9 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680:45)
E/flutter ( 7538): #10 Future._propagateToListeners (dart:async/future_impl.dart:709:32)
E/flutter ( 7538): #11 Future._completeWithValue (dart:async/future_impl.dart:524:5)
E/flutter ( 7538): #12 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:32:15)
E/flutter ( 7538): #13 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:290:13)
E/flutter ( 7538): #14 Geolocator.getCurrentPosition (package:geolocator/geolocator.dart)
E/flutter ( 7538): #15 _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:73:64)
E/flutter ( 7538): #16 _rootRunUnary (dart:async/zone.dart:1134:38)
E/flutter ( 7538): #17 _CustomZone.runUnary (dart:async/zone.dart:1031:19)
E/flutter ( 7538): #18 _FutureListener.handleValue (dart:async/future_impl.dart:139:18)
E/flutter ( 7538): #19 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680:45)
E/flutter ( 7538): #20 Future._propagateToListeners (dart:async/future_impl.dart:709:32)
E/flutter ( 7538): #21 Future._completeWithValue (dart:async/future_impl.dart:524:5)
E/flutter ( 7538): #22 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:32:15)
E/flutter ( 7538): #23 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:290:13)
E/flutter ( 7538): #24 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart)
E/flutter ( 7538): #25 _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:73:64)
E/flutter ( 7538): #26 _rootRunUnary (dart:async/zone.dart:1134:38)
E/flutter ( 7538): #27 _CustomZone.runUnary (dart:async/zone.dart:1031:19)
E/flutter ( 7538): #28 _FutureListener.handleValue (dart:async/future_impl.dart:139:18)
E/flutter ( 7538): #29 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680:45)
E/flutter ( 7538): #30 Future._propagateToListeners (dart:async/future_impl.dart:709:32)
E/flutter ( 7538): #31 Future._completeWithValue (dart:async/future_impl.dart:524:5)
E/flutter ( 7538): #32 Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:554:7)
E/flutter ( 7538): #33 _rootRun (dart:async/zone.dart:1126:13)
E/flutter ( 7538): #34 _CustomZone.run (dart:async/zone.dart:1023:19)
E/flutter ( 7538): #35 _CustomZone.runGuarded (dart:async/zone.dart:925:7)
E/flutter ( 7538): #36 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:965:23)
E/flutter ( 7538): #37 _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
E/flutter ( 7538): #38 _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5)