当前位置:网站首页>Use blocconsumer to build responsive components and monitor status at the same time
Use blocconsumer to build responsive components and monitor status at the same time
2022-07-04 22:07:00 【InfoQ】
Preface
BlocListener
BlocBuilder
BlocBuilder
BlocListener
BlocBuilder
BlocListener
BlocConsumer
BlocConsumer Implementation mechanism
BlocConsumer
BlocBuilder
BlocListener
const BlocConsumer({
Key? key,
required this.builder,
required this.listener,
this.bloc,
this.buildWhen,
this.listenWhen,
}) : super(key: key);
builder
: Responsive component construction method , andBlocBuilder
In the same .
listener
: Status change processing listening callback function , andBlocListener
The definitions are the same .
bloc
: OptionalBloc
State object , If not specified , Automatically from the currentBuildContext
Find the corresponding type of status object in .
buildWhen
: Optional parameters , Status objects before and after receiving , You can return... According to the previous and subsequent status objectsbool
value , iftrue
Will refresh the component .
listenWhen
: Optional parameters , Status objects before and after receiving , You can return... According to the previous and subsequent status objectsbool
value , iftrue
Will calllistener
The callback method .
BlocConsumer
builder
@override
Widget build(BuildContext context) {
if (widget.bloc == null) context.select<B, int>(identityHashCode);
return BlocBuilder<B, S>(
bloc: _bloc,
builder: widget.builder,
buildWhen: (previous, current) {
if (widget.listenWhen?.call(previous, current) ?? true) {
widget.listener(context, current);
}
return widget.buildWhen?.call(previous, current) ?? true;
},
);
}
BlocBuilder
BlocBuilder
builderWhen
listenWhen
listener
BlocBuilder
BlocListener
BlocConsumer application

summary
BlocConsumer
BlocBuilder
BlocListener
BlocConsumer
BlocBuilder
BlocListener

边栏推荐
- Enlightenment of maker thinking in Higher Education
- 历史最全混合专家(MOE)模型相关精选论文、系统、应用整理分享
- ArcGIS 10.2.2 | solution to the failure of ArcGIS license server to start
- NAACL-22 | 在基于Prompt的文本生成任务上引入迁移学习的设置
- GTEST from ignorance to skillful use (1) GTEST installation
- Exclusive interview of open source summer | new committer Xie Qijun of Apache iotdb community
- B站大量虚拟主播被集体强制退款:收入蒸发,还倒欠B站;乔布斯被追授美国总统自由勋章;Grafana 9 发布|极客头条
- MongoDB聚合操作总结
- Go language loop statement (3 in Lesson 10)
- 【米哈游2023届秋招】开启【校招唯一专属内推码EYTUC】
猜你喜欢
bizchart+slider实现分组柱状图
el-tree结合el-table,树形添加修改操作
做BI开发,为什么一定要熟悉行业和企业业务?
广电五舟与华为签署合作协议,共同推进昇腾AI产业持续发展
TCP protocol three times handshake process
Shutter textfield example
TCP shakes hands three times and waves four times. Do you really understand?
[weekly translation go] how to code in go series articles are online!!
QT—双缓冲绘图
案例分享|金融业数据运营运维一体化建设
随机推荐
KDD2022 | 什么特征进行交互才是有效的?
Enlightenment of maker thinking in Higher Education
# 2156. 查找给定哈希值的子串-后序遍历
HDU - 2859 Phalanx(DP)
el-tree结合el-table,树形添加修改操作
保证接口数据安全的10种方案
gtest从一无所知到熟练使用(2)什么是测试夹具/装置(test fixture)
可视化任务编排&拖拉拽 | Scaleph 基于 Apache SeaTunnel的数据集成
Bizchart+slider to realize grouping histogram
置信区间的画法
283. Moving zero-c and language assisted array method
VIM from dislike to dependence (23) -- the last gossip
[optimtool.unconstrained] unconstrained optimization toolbox
网上开户哪家证券公司佣金最低,我要开户,网上开户安全吗
From repvgg to mobileone, including mobileone code
WebGIS框架---kalrry
Exclusive interview of open source summer | new committer Xie Qijun of Apache iotdb community
Which securities company has the lowest Commission for opening an account online? I want to open an account. Is it safe to open an account online
Interviewer: what is XSS attack?
服务线上治理