createArgFromData function

Expression createArgFromData(
  1. ServerParam param
)

Implementation

Expression createArgFromData(ServerParam param) {
  var dataVar = refer('context').property('data').property('get').call([]);

  if (!param.isNullable) {
    dataVar = dataVar.ifNullThen(
      createMissingArgumentException(
        key: param.name,
        location: '@${AnnotationType.data.name}',
      ).thrown.parenthesized,
    );
  }

  return dataVar;
}