为什么可以在使用广播流的同时使用InheritedWidget | StreamBuilder和静态变量 [英] Why use InheritedWidget while we can use Broadcast Streams | StreamBuilder and Static Variables
问题描述
为什么可以在使用广播流的同时使用InheritedWidget | StreamBuilder和静态变量?
Why use InheritedWidget while we can use Broadcast Streams | StreamBuilder and Static Variables?
为什么我们可以拥有简单干净的体系结构,但为什么还要担心redux,范围模型等呢?
Why should we bother about redux, scoped model, etc. while we can have a simple and clean architecture?
推荐答案
流/接收器绝对是存储状态的绝佳选择.有一些现有的体系结构,例如BLoC经常使用它们.
Streams/Sink definitely are excellent to store a state. There are some existing architectures, such as BLoC which uses them a lot.
但是,Streams也不完全取代InheritedWidget
.
InheritedWidget
具有很酷的功能,可以覆盖屏幕的仅一部分内容.
一个很酷的应用是Theme
.
But, Streams don't entirely replace InheritedWidget
either.
InheritedWidget
comes with the cool ability to override it's content for only a part of the screen.
One cool application of this is Theme
.
通常来说,Streams
很酷,可以存储业务逻辑.但是当您需要存储UI逻辑时,InheritedWidgets
占据上风.
Generally speaking, Streams
are cool to store business logic. But when you need to store UI logic, InheritedWidgets
takes the upper hand.
这篇关于为什么可以在使用广播流的同时使用InheritedWidget | StreamBuilder和静态变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!