我有一个使用Cloud Firestore的Flutter项目。在我的一个小部件中,我有一个理想的从数据库读取快照的StreamBuilder。从理论上讲,我用于从远程服务器读取数据的API应该足够抽象,以便用不同的实现替换Firestore。
class Database {
Stream<QuerySnapshot> get snapshots => Firestore.instance.collection('entires').snapshots();
Stream<List<String>> get entries
目前我正在同时使用firestore和实时数据库。我在代码中以最简单有效的方式从firestore中设置和检索数据,对于实时数据库,我设置了数据,但我不能像使用firestore那样检索它。总结:我想在实时数据库代码中使用firestore代码做同样的事情。 下面是我的代码: //Get data from Firestore
Stream <DocumentSnapshot> getData() async*{
final user = FirebaseAuth.instance.currentUser;
yield* FirebaseFirestore.
我正面临着Streambuilder的问题。我的应用程序的工作流程就像是有一个项目列表,当我按下add to favorites时,它会将项目添加到firestore。然后,我使用stream从firestore获取数据,并使用stream builder将其显示在另一个屏幕上。问题是,当我热重载应用程序时,流生成器是空的,数据显示得很完美。this is the part where I am calling stream method this is streambuilder,谢谢。
我已经编写了一些简化的代码,我希望firestore数据的条件能够更新父小部件。
我得到的错误是:在构建过程中调用了setState()或markNeedsBuild()。
如何从StreamBuilder内部更新myVar的状态?更新myVar后,将不会访问StreamBuilder,而只会访问等待的文本...应显示。
编辑:我将myVar更新为Firestore的文档ID。为了清楚起见,我希望能够从StreamBuilder内部更新StreamBuilder的文档。换句话说,正如问题所说,从子StreamBuilder更新有状态小部件。
class MyWidget extends Sta
我想使用streambuilder显示用户的firestore信息,但是不能。以下是我的代码,但是当我构建这个页面时,我在调试控制台上看到一个红屏和一个错误消息Value not in range: 12 The relevant error-causing widget was StreamBuilder<Userbio>。我不知道哪里出了问题。有人能帮帮我吗? @override
Widget build(BuildContext context) {
final clientbios = Provider.of<List<Clientbio>>(c
在我的应用程序中,我需要在继续之前获取当前用户的配置文件数据。我试图通过在代码中使用StreamBuilder来实现这一点。
我的问题是: StreamBuilder总是返回else语句。好像他无法从FireStore-Collection‘User’加载任何数据。
return StreamBuilder<QuerySnapshot>(
stream: Firestore.instance.collection('Users').snapshots(), // It seems like he cannot load any data from t
我正在尝试使用Flutter和Firestore构建一个应用程序。当使用StreamBuilder从Firestore加载集合以在ListView中显示它时,我得到以下错误 The following assertion was thrown building StreamBuilder(dirty, state:
I/flutter (26287): _StreamBuilderBaseState>#d5638):
I/flutter (26287): type '_InternalLinkedHashMap' is not a subtype of type