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.writeln(
'$_docCommentPrefix The codec used by ${_className(generatorOptions.prefix, api.name)}.');
indent.writeln(
'NSObject<FlutterMessageCodec> *${_getCodecGetterName(generatorOptions.prefix, api.name)}(void);');
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;');
for (final Method func in api.methods) {
final _ObjcPtr returnType =
_objcTypeForDartType(generatorOptions.prefix, func.returnType);
final String callbackType = _callbackForType(func.returnType, returnType);
addDocumentationComments(
indent, func.documentationComments, _docCommentSpec);
indent.writeln('${_makeObjcSignature(
func: func,
options: generatorOptions,
returnType: 'void',
lastArgName: 'completion',
lastArgType: callbackType,
isEnum: (TypeDeclaration t) => isEnum(root, t),
)};');
}
indent.writeln('@end');
indent.newln();
}