title: Unhandled Exception: Bad state: field does not exist within the DocumentSnapshotPlatform (While it does exits on firestore)
body: <p>I'm writing a code in which I'm trying to login admin. And for that I created an Admin on FireStore ,not with code, but with the options that firestore provide. It's like first I made an admin on firestore then I wrote a code in which I'm trying to login that perticular admin by providing the same admin's id and password inside the app. I suppose it is some kind of key issue but I don't know how to handle this error.</p>
  <p><strong>Below is the error when app is used on an Emulator</strong></p>
  <p><a href="https://i.stack.imgur.com/qlwdp.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qlwdp.jpg" alt="enter image description here" /></a>
  <strong>Below is the error when app is used on Real Android Mobile</strong></p>
  <p><a href="https://i.stack.imgur.com/NliTM.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NliTM.jpg" alt="enter image description here" /></a></p>
  <p><strong>And when Click on line #7 it takes me to the file where firestore code is written for admin login.</strong></p>
  <p><a href="https://i.stack.imgur.com/v1sgS.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v1sgS.jpg" alt="enter image description here" /></a></p>
  <p><strong>UPDATE:</strong></p>
  <p>And when I click the below line error(app running on actual phone) it takes me to a firestore snapshot file which I don't understand.
  <a href="https://i.stack.imgur.com/ATfZA.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ATfZA.jpg" alt="enter image description here" /></a></p>
  <p><strong>FirebaseFirestore console(Here the admin fields are created with the &quot;+&quot; options)</strong></p>
  <p><a href="https://i.stack.imgur.com/WGYUF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WGYUF.png" alt="enter image description here" /></a></p>
  <p><strong>Flutter Doctor</strong></p>
  <pre><code>Doctor summary (to see all details, run flutter doctor -v):
  [√] Flutter (Channel stable, 2.2.3, on Microsoft Windows [Version 10.0.19041.450], locale en-PK)
  [√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
  [√] Chrome - develop for the web
  [√] Android Studio
  [√] Connected device (2 available)
  
  • No issues found!
  </code></pre>
  <p><strong>AdminLogin.dart</strong></p>
  <pre><code>   import 'package:cloud_firestore/cloud_firestore.dart';
  import 'package:ecom_app/Authentication/AuthnticationScreen.dart';
  import 'package:ecom_app/DialogBox/errordialog.dart';
  import 'package:ecom_app/Widgets/CustomTextField.dart';
  import 'package:flutter/material.dart';
  import 'Uploaditems.dart';
  
  
  class Adminsignin extends StatelessWidget {
    const Adminsignin({Key? key}) : super(key: key);
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          flexibleSpace: Container(
            decoration: BoxDecoration(
                gradient: LinearGradient(
                  colors: [Colors.pink,Colors.lightGreenAccent],
                  begin: const FractionalOffset(0.0, 0.0),
                  end: const FractionalOffset(1.0, 0.0),
                  stops: [0.0,1.0],
                  tileMode: TileMode.clamp,
                )
            ),
          ),
          title: Text
            (
            'E-Shop',
            style: TextStyle(
                fontSize:55.0,color: Colors.white),
          ),
          centerTitle: true,
  
        ),
        body: AdminSignInPage(),
      );
    }
  }
  
  
  
  
  class AdminSignInPage extends StatefulWidget {
    const AdminSignInPage({Key? key}) : super(key: key);
  
    @override
    _AdminSignInPageState createState() =&gt; _AdminSignInPageState();
  }
  
  class _AdminSignInPageState extends State&lt;AdminSignInPage&gt; {
    final TextEditingController _adminController =TextEditingController();
    final TextEditingController _passwordController =TextEditingController();
    final GlobalKey&lt;FormState&gt; _formKey=GlobalKey&lt;FormState&gt;();
  
    @override
    Widget build(BuildContext context) {
      double _screenwidth=MediaQuery.of(context).size.width,_screenHeight=MediaQuery.of(context).size.height;
  
      return SingleChildScrollView(
        child: Container(
          decoration: BoxDecoration(
              gradient: LinearGradient(
                colors: [Colors.pink,Colors.lightGreenAccent],
                begin: const FractionalOffset(0.0, 0.0),
                end: const FractionalOffset(1.0, 0.0),
                stops: [0.0,1.0],
                tileMode: TileMode.clamp,
              )
          ),
          child: Column(
            mainAxisSize: MainAxisSize.max,
            children: [
              Container(
                alignment: Alignment.bottomCenter,
                child: Image.asset(
                  'images/welcome.png',
                  height: 240.0,
                  width: 240.0,
                ),
              ),
              Padding(
                padding:EdgeInsets.all(8.0),
                child: Text('Admin',
                  style: TextStyle(color: Colors.white38,fontSize: 28.0,fontWeight: FontWeight.bold),
                ),
  
              ),
  
              Form(
                  key: _formKey,
                  child: Column(
                    children: [
  
                      customtextfield(
                        controller: _adminController,
                        data: Icons.person,
                        hinttext: 'ID',
                        isObsecure:false,
                      ),
                      customtextfield(
                        controller: _passwordController,
                        data: Icons.lock,
                        hinttext: 'Password',
                        isObsecure:true,
                      ),
                      SizedBox(
                        height: 25.0,
                      ),
                      ElevatedButton(
                        onPressed: ()=&gt;
                        _adminController.text.isNotEmpty&amp;&amp;_passwordController.text.isNotEmpty
                            ? loginAdmin ()
                            :showDialog(
                            context: context,
                            builder: (c){
                              return ErrorDialog(message: 'Please Enter ID and Password');
                            }
                        ),
                        style: ElevatedButton.styleFrom(primary: Colors.pink,onPrimary: Colors.yellow),
                        child:Text(&quot;Login&quot;),
                      ),
                      SizedBox(
                        height: 50.0,
                      ),
                      Container(
                        height: 4.0,
                        width: _screenwidth*0.8,
                        color: Colors.pink,
                      ),
                      SizedBox(
                        height: 10.0,
                      ),
                      FlatButton.icon(
                        onPressed: (){
                          Navigator.push(context, MaterialPageRoute(builder: (context)=&gt;AuthenticScreen( )));
                        },
                        icon: Icon(Icons.admin_panel_settings,color: Colors.pink,),
                        label: Text('I am not an Admin',style: TextStyle(color: Colors.pink,fontWeight: FontWeight.bold),),
  
                      ),
                      SizedBox(
                        height: 50.0,
                      ),
  
                    ],
                  )
              ),
            ],
          ),
        ),
      );
    }
    loginAdmin (){
      FirebaseFirestore.instance.collection('admins').get().then((snapshot){
        snapshot.docs.forEach((result){
          if(result['id'] != _adminController.text.trim())
            {
              Scaffold.of(context).showSnackBar(SnackBar(content: Text('ID is not Correct')));
            }
          else if(result['password' != _passwordController.text.trim()])
            {
              Scaffold.of(context).showSnackBar(SnackBar(content: Text('Passwod is not Correct')));
            }
          else
            {
              Scaffold.of(context).showSnackBar(SnackBar(content: Text('Welcome Admin, ' +result['name'],)));
              setState(() {
                _adminController.text='';
                _passwordController.text='';
              });
              Route route=MaterialPageRoute(builder: (c)=&gt; UploadPage());
              Navigator.pushReplacement(context, route);
          }
        });
      });
  
    }
  }
  </code></pre>