Bad state: field does not exist within the DocumentSnapshotPlatform. Giving this error but don't know where the error is

Aliah Gapor

Hi this is my code but it gives me this error: Bad state: field does not exist within the DocumentSnapshotPlatform. im not sure where is the error.

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

class OrderSuccessful extends StatefulWidget {
  @override
  _OrderSuccessfulState createState() => _OrderSuccessfulState();
}

  class _OrderSuccessfulState extends State<OrderSuccessful>{
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("Order Successful")),
      resizeToAvoidBottomInset: true,

      body: StreamBuilder(
        stream: FirebaseFirestore.instance.collection('personalinfo').snapshots(),
        builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot){
        if (!snapshot.hasData){
          return Text("no value");
        }
        return ListView(
          children: snapshot.data!.docs.map((document){
            return Text(document['personalinfo']);
          }).toList(),
        );
        },
        ),
    );
  }
}
Moaz El-sawaf

You are trying to access a field named personalinfo from the documents inside the collection in the named personalinfo but unfortunlly this field doesn't exist.

So make sure that all the documents inside the personalinfo collection contains a key named personalinfo or just add a condition to check its existence before using it such as: document.contains('personalinfo').

The line you are using to access the field is:

return Text(document['personalinfo']);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Error: Bad state : field does not exist within the DocumentSnapshotPlatform

Bad state: field does not exist within the DocumentSnapshotPlatform error

Bad state: field does not exist within the DocumentSnapshotPlatform flutter error even though field exists

Flutter: Unhandled Exception: Bad state: field does not exist within the DocumentSnapshotPlatform

Problem with stream and firebase Bad state: field does not exist within the DocumentSnapshotPlatform

StateError (Bad state: field does not exist within the DocumentSnapshotPlatform) on flutter

flutter Bad state: field does not exist within the DocumentSnapshotPlatform

Flutter: Bad state: field does not exist within the DocumentSnapshotPlatform in streambuilder

Flutter - "Bad state: field does not exist within the DocumentSnapShotPlatform"

StateError (Bad state: field does not exist within the DocumentSnapshotPlatform). How can I get a doc from firestore?

How to fix Bad state: field does not exist within the DocumentSnapshotPlatform Firebase Flutter FutureBuilder

Bad state: cannot get a field on a DocumentSnapshotPlatform which does not exist

I tried to display 'DateTime' on flutter UI get from firestore but show " Bad state: field does not exist within the DocumentSnapshotPlatform "

Bad state: cannot get a field on a DocumentSnapshotPlatform which does not exist, Firebase Flutter

How can I resolve " Bad state: cannot get a field on a DocumentSnapshotPlatform which does not exist"

Exception: Bad state: cannot get a field on a DocumentSnapshotPlatform which does not exist provider

field dos not exist within the DocumentSnapshotPlatform

query error, but I don't know where is it

My QuickSort code sometimes run but sometimes it does not and I don't know where error got happened

There's an error in my syntax, I don't know where

Postgres giving relation does not exist error for alias

Postgres - Why is it giving the error 'Schema does not exist'

ReactJS is giving bad set state error in useMemo function

Android sqlite query giving an error that column doesn't exist when it surely does

php error - don't know how to fix it

SMTP Error, I don't know why

Getting an "ArgumentOutOfRangeException" error but don't know how?

I get the error "internal server pine compilation error" but i don't know where to look for an error in my code

Android Studio, mismatch support library versions error, but don't know where it is being specified at