writeFlutterApi method
void
writeFlutterApi(
- ObjcOptions generatorOptions,
- Root root,
- Indent indent,
- Api api, {
- required String dartPackageName,
override
Writes a single Flutter Api to indent
.
Implementation
@override
void writeFlutterApi(
ObjcOptions generatorOptions,
Root root,
Indent indent,
Api api, {
required String dartPackageName,
}) {
indent.newln();
final String apiName = _className(generatorOptions.prefix, api.name);
addDocumentationComments(
indent, api.documentationComments, _docCommentSpec);
indent.writeln('@interface $apiName : NSObject');
indent.writeln(
'- (instancetype)initWithBinaryMessenger:(id<FlutterBinaryMessenger>)binaryMessenger;');
indent.writeln(
'- (instancetype)initWithBinaryMessenger:(id<FlutterBinaryMessenger>)binaryMessenger messageChannelSuffix:(nullable NSString *)messageChannelSuffix;');
for (final Method func in api.methods) {
final _ObjcType returnType = _objcTypeForDartType(
generatorOptions.prefix, func.returnType,
// Nullability is required since the return must be nil if NSError is set.
forceNullability: true,
);
final String callbackType =
_callbackForType(func.returnType, returnType, generatorOptions);
addDocumentationComments(
indent, func.documentationComments, _docCommentSpec);
indent.writeln('${_makeObjcSignature(
func: func,
options: generatorOptions,
returnType: 'void',
lastArgName: 'completion',
lastArgType: callbackType,
)};');
}
indent.writeln('@end');
indent.newln();
}