如果流媒体在扑朔迷离的情况下,正确的方法是什么?
让我们说我需要在页面上通过“类别流”访问。现在,该页面被模块化了:
Widget/Page A:
build() {
subWidgetA,
subWidgetB,
subWidgetC,
subWidgetD,
}
现在,我需要在Subwidget A和SubwidgetD中的类别流D。我是否应该将StreamBuilder声明为我的构建中的第一个孩子()或声明各自的子Widgets内部的StreamBuilder。
方法1:
build() {
StreamBuilder() {
subWidgetA (data from asyncsnapshot),
subWidgetB,
subWidgetC,
subWidgetD (data from asyncsnapshot),
}
}
方法2:
build() {
subWidgetA,
subWidgetB,
subWidgetC,
subWidgetD,
}
subWidgetA() {
StreamBuilder categories () {
}
}
subWidgetD() {
StreamBuilder categories () {
}
}
哪种方法更好,为什么?提前致谢!
Let us say that I need access to by "categories stream" on a page. Now the page is modularised such that :
Widget/Page A:
build() {
subWidgetA,
subWidgetB,
subWidgetC,
subWidgetD,
}
Now, I need my categories streams inside subWidget A and subWidget D. Should I just declare the streambuilder as the first child inside my build() or declare that streambuilder inside the respective subwidgets.
Approach 1:
build() {
StreamBuilder() {
subWidgetA (data from asyncsnapshot),
subWidgetB,
subWidgetC,
subWidgetD (data from asyncsnapshot),
}
}
Approach 2:
build() {
subWidgetA,
subWidgetB,
subWidgetC,
subWidgetD,
}
subWidgetA() {
StreamBuilder categories () {
}
}
subWidgetD() {
StreamBuilder categories () {
}
}
Which approach is better and why ?? Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论