HookContext class abstract

A reference to core mason APIs to be used within hooks.

Each hook is defined as a run method which accepts a HookContext instance.

HookContext exposes APIs to:

  • read/write template vars
  • access a Logger instance
// pre_gen.dart
import 'package:mason/mason.dart';

void run(HookContext context) {
  // Read/Write vars
  context.vars = {...context.vars, 'custom_var': 'foo'};

  // Use the logger
  context.logger.info('hello from pre_gen.dart');
}

Constructors

HookContext()

Properties

hashCode int
The hash code for this object.
no setterinherited
logger Logger
Getter that returns a Logger instance.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
vars Map<String, dynamic>
Getter that returns the current map of variables.
getter/setter pair

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited