我在显示 Firebase 数据时遇到问题。这是我在 FutureBuilder 中使用的代码。
这是我得到的错误
"The following _CastError was thrown building FutureBuilder<QuerySnapshot<Object?>>(dirty, state: _FutureBuilderState<QuerySnapshot<Object?>>#c8a1c):
type '_JsonQuerySnapshot' is not a subtype of type 'Map<String, dynamic>' in type cast"
Run Code Online (Sandbox Code Playgroud)
代码
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:errandkaba_app/widgets/custom_action_bar.dart';
import 'package:flutter/material.dart';
class ServicePage extends StatefulWidget {
final String? serviceId;
const ServicePage({Key? key, this.serviceId}) : super(key: key);
@override
_ServicePageState createState() => _ServicePageState();
}
class _ServicePageState extends State<ServicePage> {
final CollectionReference _servicesRef =
FirebaseFirestore.instance.collection("cleaning");
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: [
FutureBuilder (
future: …Run Code Online (Sandbox Code Playgroud)