首页 > 解决方案 > 可以mapEventToState同一个实例

问题描述

我们必须在 mapEventToState 中创建新的状态实例吗?像https://github.com/felangel/bloc/blob/master/examples/flutter_form_validation/lib/bloc/my_form_bloc.dart#L31我们有一个copyWith

如果我们只是这样做

state.email=event.email;
yield state;

怎么了?用户界面没有更新?

如果我们有嵌套对象怎么办?state.a.b.c,需要多少个copyWith?

我正在使用,swagger-codegen所以a并没有 copyWith 方法,为我所有生成的对象实现 copyWith 太麻烦了bc

如何轻松更改属性?

标签: flutterbloc

解决方案


推荐阅读