我想在 Firebase 中更改一个布尔值,但它说该文档不存在

I would like to change a boolean value in Firebase, but it says that the document doesn't exist

当我单击 TextButton 时,我希望 Firestore 上的 requestDelivered 值更改为 true。 代码如下:

import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';

class Delivered extends StatefulWidget {
  final String pedidoId;
  final bool delivered;
  Delivered(this.pedidoId, this.delivered, {Key key}) : super(key: key);

  @override
  State<Delivered> createState() => _DeliveredState(delivered: this.delivered);
}

class _DeliveredState extends State<Delivered> {
  bool delivered = false;
  _DeliveredState({this.delivered});

  Future<void> _updateDelivered(pedidoId) async {
    await FirebaseFirestore.instance
        .collection("pedidos")
        .doc(pedidoId)
        .update({
      'requestDelivered': true,
    });
  }

  @override
  Widget build(BuildContext context) {
    return Container(
        margin: const EdgeInsets.all(5),
        child: Padding(
            padding: const EdgeInsets.all(
              10,
            ),
            child: Card(
                child: TextButton(
              style: TextButton.styleFrom(
                primary: Colors.green[900],
              ),
              child: const Text(
                'Confirmar entrega!',
                style: TextStyle(fontSize: 18),
              ),
              onPressed: () {
                setState(() {
                  delivered = !delivered;
                });
                _updateDelivered(widget.pedidoId);
              },
            ))));
  }
}

一张图片: [1]: https://i.stack.imgur.com/HXWT6.pn

错误是:

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: [cloud_firestore/not-found] Some requested document was not found

代码看起来正确,我认为是参数问题。 检查升级时 firebase 数据库中“pedoidid”的值是否正确。 您可以截取 firebase 屏幕的屏幕截图吗?