当前位置:网站首页>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
BlocListenerBlocBuilderBlocBuilderBlocListenerBlocBuilderBlocListenerBlocConsumerBlocConsumer Implementation mechanism
BlocConsumerBlocBuilderBlocListenerconst BlocConsumer({
Key? key,
required this.builder,
required this.listener,
this.bloc,
this.buildWhen,
this.listenWhen,
}) : super(key: key);
builder: Responsive component construction method , andBlocBuilderIn the same .
listener: Status change processing listening callback function , andBlocListenerThe definitions are the same .
bloc: OptionalBlocState object , If not specified , Automatically from the currentBuildContextFind 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 objectsboolvalue , iftrueWill refresh the component .
listenWhen: Optional parameters , Status objects before and after receiving , You can return... According to the previous and subsequent status objectsboolvalue , iftrueWill calllistenerThe callback method .
BlocConsumerbuilder@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;
},
);
}
BlocBuilderBlocBuilderbuilderWhenlistenWhenlistenerBlocBuilderBlocListenerBlocConsumer application

summary
BlocConsumerBlocBuilderBlocListenerBlocConsumerBlocBuilderBlocListener
边栏推荐
- gtest从一无所知到熟练使用(3)什么是test suite和test case
- el-tree结合el-table,树形添加修改操作
- Enlightenment of maker thinking in Higher Education
- Representation of confidence interval
- 电话加密,中间4为****代替
- Bookmark
- # 2156. 查找给定哈希值的子串-后序遍历
- ArcGIS 10.2.2 | solution to the failure of ArcGIS license server to start
- QT - double buffer plot
- 1807. 替换字符串中的括号内容
猜你喜欢

ArcGIS 10.2.2 | solution to the failure of ArcGIS license server to start

Bizchart+slider to realize grouping histogram

How was MP3 born?

从RepVgg到MobileOne,含mobileone的代码
![[leetcode] 17. Letter combination of telephone number](/img/be/7f456c092f7cda5ebabc2f1cce292e.png)
[leetcode] 17. Letter combination of telephone number

From repvgg to mobileone, including mobileone code

PMO:比较25种分子优化方法的样本效率

close系统调用分析-性能优化

i. Mx6ull driver development | 24 - platform based driver model lights LED

智洋创新与华为签署合作协议,共同推进昇腾AI产业持续发展
随机推荐
GTEST from ignorance to proficiency (4) how to write unit tests with GTEST
i.MX6ULL驱动开发 | 24 - 基于platform平台驱动模型点亮LED
Interview question 01.01 Determine whether the character is unique
Relational database
Keep on fighting! The city chain technology digital summit was grandly held in Chongqing
How was MP3 born?
[advanced C language] array & pointer & array written test questions
Spatiotemporal prediction 3-graph transformer
Which securities company is better to open an account? Is online account opening safe
WebGIS framework -- kalrry
股票开户流程是什么?使用同花顺手机炒股软件安全吗?
Delphi soap WebService server-side multiple soapdatamodules implement the same interface method, interface inheritance
How to remove the black dot in front of the title in word document
Shutter textfield example
Learning breakout 3 - about energy
湘江鲲鹏加入昇腾万里伙伴计划,与华为续写合作新篇章
WebGIS框架---kalrry
Redis 排查大 key 的3种方法,优化必备
一文掌握数仓中auto analyze的使用
输入的查询SQL语句,是如何执行的?