Я пытаюсь получить информацию о конкретном документе по его «идентификатору», чтобы показать информацию этого документа.
Код, который я использую для сервиса:
class SentenciasFireBase {
//This is a class where I have all the services of firebase
...
obtenerVacaciones(String empleado) async {
//empleado is the document id
return await Firestore.instance.document('Vacaciones/$empleado');
}
...
}
А код для отображения информации такой:
class TurnoActual_State extends State<TurnoActual>{
...
SentenciasFireBase objetoSentencias = new SentenciasFireBase();
//This object "metodos" is of a class that has several reusable methods:
Metodos metodos = new Metodos();
@override
void initState() {
objetoSentencias.obtenerVacaciones(_noEmpleado).then((resultados){
setState(() {
vacaciones = resultados;
});
});
}
...
@override
Widget build(BuildContext context){
...
RichText(
text: TextSpan(
//toDateTime is a method that converts a timestamp into a DateTime,
//and then converts the DateTime into a String with a specific date format.
//'Inicio' stores a timestamp (it is the date on which the holidays start):
text: metodos.toDateTime(vacaciones.documents[0].data['Inicio']),
style: TextStyle(
color: Colors.black,
fontSize: 30,
fontWeight: FontWeight.bold,
),
)
)
...
}
Это сообщение об ошибке:
трепетание: ══TION ИСКЛЮЧЕНИЕ ЗАПРЕЩЕНО БИБЛИОТЕКОЙ ВИДЖЕТОВ.
╞═════════════════════════════════════════════════ ══════════
flutter: было сгенерировано следующее NoSuchMethodError, создающее StreamBuilder (грязный, состояние:
флаттер: _StreamBuilderBaseState> # 45dbd):
флаттер: получатель «документы» был вызван на ноль
флаттер: приемник: ноль
флаттер: пробный вызов: документы
Примечание:
Я ошибся, поставив ссылку на документ, это был не «Турнос»:
return await Firestore.instance.document('Turnos/$empleado');
но "Vacaciones":
return await Firestore.instance.document('Vacaciones/$empleado');
(я обновил его в вопросе), но в любом случае это не "влияет" на сам по себе вопрос.