firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.73k stars 3.98k forks source link

cloud_firestore(windows): empty document crash #13150

Open HeroRickyGAMES opened 3 months ago

HeroRickyGAMES commented 3 months ago

Is there an existing issue for this?

Which plugins are affected?

Database

Which platforms are affected?

Windows

Description

Hello, how are you, yesterday I had a meeting with my boss and my program simply closed abruptly, after a search I detected that the .doc(idCondominio) o idCondominio was empty because it had not yet been collected and set. In the debug version you don't hear any errors. When I got home I tested the production version to see if everything was ok and it could be something on the guy's PC there, so I opened it and came across this, no logs, no error stack, nothing. It was basically blindly that I found this possible flaw. The right thing to do was to display something in the console... The document cannot be empty, as is normally the case in Android and Web versions.

Reproducing the issue

After a search I detected that the .doc(idCondominio) o idCondominio was empty because it had not yet been collected and set. In the debug version you don't hear any errors. When I got home I tested the production version to see if everything was ok and it could be something on the guy's PC there, so I opened it and came across this, no logs, no error stack, nothing. It was basically blindly that I found this possible flaw. The right thing to do was to display something in the console... The document cannot be empty, as is normally the case in Android and Web versions.

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

//Desenvolvido por HeroRickyGames

//Change the testclass("") to another value to solve the problem.
main(){
  runApp(
    MaterialApp(
      home: testclass(""),
    )
  );
}

class testclass extends StatefulWidget {

  String checkedDoc = "";
  testclass(this.checkedDoc, {super.key});

  @override
  State<testclass> createState() => _testclassState();
}

class _testclassState extends State<testclass> {

  initCode() async {
    //The line issue
    var getUserPermissions = await FirebaseFirestore.instance
        .collection("QualquerColecao")
        .doc(widget.checkedDoc).get();

    print(getUserPermissions["sameValue"]);
  }

  @override
  Widget build(BuildContext context) {
    return const Placeholder();
  }
}

The app is closing in the RELEASE VERSION! In the DEBUG version it works normally and in ANDROID this problem does not happen!

In fact, the expected behavior was to have a document, BUT IN THE RELEASE VERSION it does not put an alert, much less in DEBUG. There should be an alert saying that document x is empty.

And no, it's not an error in my code, but rather in the library.

Firebase Core version

3.2.0

Flutter Version

3.22.1

Relevant Log Output

No logs

Flutter dependencies

Expand Flutter dependencies cloud_firestore
```yaml Replace this line with the contents of your `flutter pub deps -- --style=compact`. ```

Additional context and comments

No response

zTomz commented 1 month ago

Having the same problem, please fix this