when<T> method

T when<T>({
  1. required T sameTab(
    1. WebAuthenticationSameTab sameTab
    ),
  2. required T popup(
    1. WebAuthenticationPopup popup
    ),
})

Implementation

T when<T>({
  required T Function(WebAuthenticationSameTab sameTab) sameTab,
  required T Function(WebAuthenticationPopup popup) popup,
}) {
  if (this is WebAuthenticationSameTab) {
    return sameTab(this as WebAuthenticationSameTab);
  } else if (this is WebAuthenticationPopup) {
    return popup(this as WebAuthenticationPopup);
  } else {
    throw StateError(
      'Instance of WebAuthenticationMode is not a known subtype',
    );
  }
}