我遇到了一个问题,我的流生成器只触发一次。我正在尝试根据用户选择的主题将我的bottomNavigationBar配置为不同的颜色。为此,我有一个页面,用户可以在其中决定是使用浅色主题还是深色主题。这在共享首选项时保存到设备中,然后使用异步,我会将当前值流式传输到我的bottomNavigationBar中。当我使用流生成器创建两个if语句时出现问题。声明如果从流返回的值为0,我将显示一个“浅色模式”底部导航栏。否则,如果它是1,我将展示一个黑暗的主题。第一次运行程序时一切正常。但是,在导航到设置页面并更改用户首选项后,流构建器将不会再次加载。这是我的代码的一些快照我已经尝试删除关
所以我正在做一个项目,我希望有一个包含多个数据流的ListView。我正在寻找的是这样的东西,但它都需要在一个ListView中滚动。我收到的数据流来自firebase,变量myData是firebase集合的一个实例。我能够构建单个流的列表,所以我知道实例是正确的,我不想共享它,因为数据库规则目前处于测试模式。此代码允许我从单个流构建单个ListView并按预期工作。Container(child:StreamBuilder(stream:myData,builder:(BuildContextcontext,AsyncSnapshotsnapshot){if(snapshot.ha
我正在尝试计算未读消息的数量。在第一个streambuilder中,我需要获取所有与第一个查询匹配的文档ID。然后,在该文档ID中,我可以访问该文档中的子集合并执行另一个查询。然后我需要访问该查询的结果。然而,在下面的尝试中,控制台输出“pastfirststream”但不进入第二个streambuilder。returnStreamBuilder(stream:Firestore.instance.collection('conversations').where('user_id',isEqualTo:Provider.of(context).id).snapshots(),bui
是否可以在一个Widget中有多个StreamBuilder?我有关注小部件:classBuilderLoadingextendsStatelessWidget{@overrideWidgetbuild(BuildContextcontext){TenderApiProviderapiProv=Provider.of(context);//apiProv.getToken();returnStreamBuilder(stream:apiProv.streamApiKeyController.stream,//herebuilder:(BuildContextcontext,AsyncS
我有StreamBuilder。我正在尝试用它做进度指示器。喜欢:LoadingtokenDONELoadingregionsDONELoadingindustryDONE在最后一项(“LoadingindustryDONE”)之后和切换到HomePage之前,我想添加一点延迟。但我不明白该怎么做。我尝试使用Future.delayed和Timer,但它们并没有切换到HomePage。没有延迟/定时器切换工作,但我需要延迟。这是我的代码:import'dart:async';import'package:flutter/material.dart';import'package:flu
我想在加载网络图像时获取它的进度,但我发现StreamBuilder的结果不正确,但我可以使用listen.这是我的运行代码:classHomePageextendsStatefulWidget{@override_HomePageStatecreateState()=>_HomePageState();}class_HomePageStateextendsState{Uriurl=Uri.parse('https://s2.ax1x.com/2019/05/22/V9fCKH.jpg');ImageChunkEventloadingProgress;http.Requestget_r
也许我的结构有误,如有任何建议,我们将不胜感激。这是我的类(class):classMainClass{finalStringtitle;MainClass({this.title});}classSubClass1extendsMainClass{finalStringsubClass1Info;SubClass1({this.subClass1Info});}classSubClass2extendsMainClass{finalStringsubClass2Info;SubClass2({this.subClass2Info});}classSubClass3extendsMai
在一个StreamBuilder中使用2个不同的流是否可行,或者我应该如何解决这个问题?我尝试对它们都使用同一个流,但是主题数据的BehaviorSubject是ThemeData模型,而对于languageStream是String并且它无法正常工作。child:StreamBuilder(stream:translationsBloc.languageOutStream,//stream:themeBloc.outFirestore,这些是我想使用的流Bloc看起来像这样:final_themeSubject=BehaviorSubject();StreamgetoutTheme=
我目前正在开发我的应用程序的聊天功能。我在StreamBuilder中设置了一个AnimatedList,以便使消息反向显示。这是我的代码children:[newFlexible(child:newStreamBuilder(stream:chatRoomRef.document(widget.chatRoomID).collection('messages').orderBy('time').snapshots(),builder:(BuildContextcontext,AsyncSnapshotsnapshot){returnnewAnimatedList(reverse:tr
以下代码按预期构建和运行——当用户键入内容时,会显示一条错误消息,直到该字符串通过电子邮件验证格式。WidgetemailField(){returnStreamBuilder(stream:bloc.emailStream,builder:(BuildContextcontext,snapshot){returnTextField(keyboardType:TextInputType.emailAddress,decoration:InputDecoration(hintText:'you@example.com',labelText:'E-mailaddress',errorTex