当前位置:网站首页>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
边栏推荐
- 赋能数字经济 福昕软件出席金砖国家可持续发展高层论坛
- 更强的 JsonPath 兼容性及性能测试之2022版(Snack3,Fastjson2,jayway.jsonpath)
- CloudCompare&Open3D DBSCAN聚类(非插件式)
- PostgreSQL基本结构——表
- Spatiotemporal prediction 3-graph transformer
- GTEST from ignorance to proficiency (3) what are test suite and test case
- File read write
- Cadeus has never stopped innovating. Decentralized edge rendering technology makes the metauniverse no longer far away
- Case sharing | integrated construction of data operation and maintenance in the financial industry
- 1807. Replace the parentheses in the string
猜你喜欢
How was MP3 born?
【LeetCode】17、电话号码的字母组合
ArcGIS 10.2.2 | solution to the failure of ArcGIS license server to start
DevEco Device Tool 3.0 Release带来5大能力升级,让智能设备开发更高效
并发网络模块化 读书笔记转
From repvgg to mobileone, including mobileone code
Case sharing | integrated construction of data operation and maintenance in the financial industry
Analyzing the maker space contained in steam Education
Machine learning notes mutual information
智洋创新与华为签署合作协议,共同推进昇腾AI产业持续发展
随机推荐
Interview question 01.01 Determine whether the character is unique
湘江鲲鹏加入昇腾万里伙伴计划,与华为续写合作新篇章
KDD2022 | 什么特征进行交互才是有效的?
MySQL存储数据加密
能源势动:电力行业的碳中和该如何实现?
Kubedm initialization error: [error cri]: container runtime is not running
What is the stock account opening process? Is it safe to use flush mobile stock trading software?
TCP协议三次握手过程
MongoDB聚合操作总结
并列图的画法,多排多列
QT - plot other problems
Telephone encryption, middle 4 is replaced by * * * *
Interpreting the development of various intelligent organizations in maker Education
Nat. Commun.| 机器学习对可突变的治疗性抗体的亲和力和特异性进行共同优化
El tree combined with El table, tree adding and modifying operations
File read write
CloudCompare&Open3D DBSCAN聚类(非插件式)
Spatiotemporal prediction 3-graph transformer
[weekly translation go] how to code in go series articles are online!!
哈希表(Hash Tabel)