ChangeNotifier で更新される値の検証
ChangeNotifier を使用した場合に、値の更新を待って検証したいとき
class ProfileViewModel extends ChangeNotifier {
ProfileViewModel(this._updateProfileBodyUseCase);
final UpdateProfileBodyUseCase _updateProfileBodyUseCase;
String _body = '';
String get body => _body;
void onBodyEdited(String body) {
_updateProfileBodyUseCase.execute(body: body).then((value) {
_body = value;
notifyListeners();
});
}
}
class UpdateProfileBodyUseCase {
Future<String> execute({required String body}) { ... }
}
Recipe
Result
最終更新