当前位置:网站首页>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
边栏推荐
- 【Acwing】第58场周赛 题解
- 从RepVgg到MobileOne,含mobileone的代码
- 并发优化总结
- 开户哪家券商比较好?网上开户安全吗
- Delphi soap WebService server-side multiple soapdatamodules implement the same interface method, interface inheritance
- 网上开户哪家证券公司佣金最低,我要开户,网上开户安全吗
- Redis03 - network configuration and heartbeat mechanism of redis
- 机器学习笔记 - 互信息Mutual Information
- 保证接口数据安全的10种方案
- Sorting and sharing of selected papers, systems and applications related to the most comprehensive mixed expert (MOE) model in history
猜你喜欢

NAACL-22 | 在基于Prompt的文本生成任务上引入迁移学习的设置

Why do you have to be familiar with industry and enterprise business when doing Bi development?

复数在数论、几何中的用途 - 曹则贤
![[advanced C language] array & pointer & array written test questions](/img/3f/83801afba153cfc0dd73aa8187ef20.png)
[advanced C language] array & pointer & array written test questions

How is the entered query SQL statement executed?

VS2019 C# release下断点调试
![[optimtool.unconstrained] unconstrained optimization toolbox](/img/ef/65379499df205c068ee9bc9df797ac.png)
[optimtool.unconstrained] unconstrained optimization toolbox

【LeetCode】17、电话号码的字母组合

从RepVgg到MobileOne,含mobileone的代码

el-tree结合el-table,树形添加修改操作
随机推荐
Why should garment enterprises talk about informatization?
HDU - 1078 fatmouse and cheese (memory search DP)
# 2156. Find the substring of the given hash value - post order traversal
湘江鲲鹏加入昇腾万里伙伴计划,与华为续写合作新篇章
Bookmark
Enlightenment of maker thinking in Higher Education
What is business intelligence (BI), just look at this article is enough
Flutter TextField示例
GTEST from ignorance to proficiency (3) what are test suite and test case
HUAWEI nova 10系列发布 华为应用市场筑牢应用安全防火墙
解决异步接口慢导致的数据错乱问题
Go language loop statement (3 in Lesson 10)
Machine learning notes mutual information
如何借助自动化工具落地DevOps
PostgreSQL基本结构——表
Learning breakout 3 - about energy
并发优化总结
广电五舟与华为签署合作协议,共同推进昇腾AI产业持续发展
New intersectionobserver usage notes
迷失在Mysql的锁世界