【发布时间】:2020-04-28 14:57:06
【问题描述】:
一个类的输入部分和另一类的输出部分出错
- 这将是引用的主类
abstract class HttpFunction<Input, Output>
{
Output apply(Input paramInput);
}
- 这将是调用前一个的类
class ComposerFunction with HttpFunction<Input, Request>
{
RequestComposer<Input> inputConverter;
ComposerFunction(RequestComposer inputConverter);
ComposerFunction_(RequestComposer<Input> inputConverter)
{
this.inputConverter = inputConverter;
}
Request apply(Input input)
{
return this.inputConverter.compose(input);
}
}
class InterpreterFunction with HttpFunction<Response, Output>
{
ResponseInterpreter<Output> responseInterpreter;
InterpreterFunction(ResponseInterpreter outputConverter);
InterpreterFunction_(ResponseInterpreter<Output> responseInterpreter)
{
this.responseInterpreter = responseInterpreter;
}
Output apply(Response response)
{
return this.responseInterpreter.interpret(response);
}
}
- 这些是错误
The name 'Input' isn't a type so it can't be used as a type argument.
Try correcting the name to an existing type, or defining a type named 'Input'.dart(non_type_as_type_argument)
和
The name 'Output' isn't a type so it can't be used as a type argument.
Try correcting the name to an existing type, or defining a type named 'Output'.dart(non_type_as_type_argument)
更新
class ComposerFunction<Input> implements HttpFunction<Input, Request>
{
...
}
class InterpreterFunction<Output> implements HttpFunction<Response, Output>
{
...
}
感谢您的回答:)
【问题讨论】: