map<T> method

T map<T>({
  1. required T local(
    1. SourceType
    ),
  2. required T remote(
    1. SourceType
    ),
})

Accepts a handler for each SourceType variant and runs the appropriate handler for which flavor this instance is.

Implementation

T map<T>({
  required T Function(SourceType) local,
  required T Function(SourceType) remote,
}) {
  return switch (this) {
    SourceType.local => local(this),
    SourceType.remote => remote(this),
  };
}