withFilter method

ProgramOptions withFilter(
  1. MessageFilter filter
)

Creates options with the given message filter.

Example:

final options = ProgramOptions().withFilter((model, msg) {
  if (msg is KeyMsg && msg.key.type == KeyType.ctrlC) {
    if (model is MyModel && model.hasUnsavedChanges) {
      return const ConfirmQuitMsg();
    }
  }
  return msg;
});

Implementation

ProgramOptions withFilter(MessageFilter filter) => copyWith(filter: filter);