Flutter

MvpView and BuildContext

Choose direct or context binding and use Flutter presentation dependencies without retaining stale context.

v0.1.0-dev.1Intermediate

MvpView and BuildContext

MvpView resolves ModelBinding in a deterministic order:

  1. use the explicit model argument when supplied;
  2. otherwise watch the nearest exact MvpModelProvider<Model>.

Direct binding

dart
MvpView<ProfileModel, ProfileViewState, ProfileEffect, ProfilePresenter>(
  model: profileBinding,
  createPresenter: ProfilePresenter.new,
  onEffect: handleProfileEffect,
  builder: buildProfile,
)

This form keeps a local dependency visible at the feature call site.

Context binding

dart
MvpModelProvider<ProfileModel>.value(
  binding: profileBinding,
  child: const ProfileScreen(),
)

The descendant omits model. Use context.readMvpModel<ProfileModel>() for a one-off read and context.watchMvpModel<ProfileModel>() when a widget must react to replacement of the binding itself.

Why Presenter receives BuildContext

Flutter localization, themes, accessibility, layout, and inherited presentation settings are context-based. FlutterPresenter.buildViewState(context) may read them synchronously while adapting Model. The runtime never stores context.

Tree-dependent one-time work belongs in onEffect, which receives the currently active context. Presenter methods should accept explicit parameters rather than retaining an old context for later navigation.

ARKTELOS

Purpose-built engineering systems for software that has to hold.