当前位置:网站首页>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
边栏推荐
- 解决异步接口慢导致的数据错乱问题
- 时空预测3-graph transformer
- Cadeus has never stopped innovating. Decentralized edge rendering technology makes the metauniverse no longer far away
- 哈希表(Hash Tabel)
- 1807. 替换字符串中的括号内容
- Exclusive interview of open source summer | new committer Xie Qijun of Apache iotdb community
- How was MP3 born?
- New intersectionobserver usage notes
- Interview question 01.08 Zero matrix
- 使用 BlocConsumer 同时构建响应式组件和监听状态
猜你喜欢

Bookmark

超详细教程,一文入门Istio架构原理及实战应用

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

i.MX6ULL驱动开发 | 24 - 基于platform平台驱动模型点亮LED

输入的查询SQL语句,是如何执行的?

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

Operation of adding material schedule in SolidWorks drawing

Keep on fighting! The city chain technology digital summit was grandly held in Chongqing

TCP protocol three times handshake process

Flutter TextField示例
随机推荐
保证接口数据安全的10种方案
Three or two things about the actual combat of OMS system
You don't have to run away to delete the library! Detailed MySQL data recovery
迷失在Mysql的锁世界
Flutter 返回按钮的监听
更强的 JsonPath 兼容性及性能测试之2022版(Snack3,Fastjson2,jayway.jsonpath)
WebGIS框架---kalrry
Machine learning notes mutual information
做BI开发,为什么一定要熟悉行业和企业业务?
Monitor the shuttle return button
Case sharing | integrated construction of data operation and maintenance in the financial industry
Shutter WebView example
ApacheCN 翻译、校对、笔记整理活动进度公告 2022.7
Interpreting the development of various intelligent organizations in maker Education
时空预测3-graph transformer
Analyzing the maker space contained in steam Education
How much is the minimum stock account opening commission? Is it safe to open an account online
How is the entered query SQL statement executed?
广电五舟与华为签署合作协议,共同推进昇腾AI产业持续发展
bizchart+slider实现分组柱状图