如果流媒体在扑朔迷离的情况下,正确的方法是什么?

发布于 2025-02-12 12:49:43 字数 705 浏览 1 评论 0原文

让我们说我需要在页面上通过“类别流”访问。现在,该页面被模块化了:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文