createInjectSelfOptional method

  1. @visibleForTesting
Method createInjectSelfOptional()

Returns the Object injectSelfOptional(...) method for the class.

Implementation

@visibleForTesting
Method createInjectSelfOptional() => Method((b) => b
  ..name = 'injectFromSelfOptional'
  ..returns = _$Object.rebuild((b) => b.isNullable = true)
  ..annotations.add(_$override)
  ..requiredParameters.add(Parameter((b) => b
    ..name = 'token'
    ..type = _$Object))
  ..optionalParameters.add(Parameter((b) => b
    ..name = 'orElse'
    ..type = _$Object.rebuild((b) => b.isNullable = true)
    ..defaultTo = _$throwIfNotFound.expression.code))
  ..body = Block((b) => b
    ..statements.addAll(_injectSelfBody)
    ..statements.addAll(_createMultiBody())
    ..statements.add(refer('orElse').returned.statement)));