Skip to content

Commit a4a8315

Browse files
committed
no function needed
1 parent 13959c0 commit a4a8315

File tree

3 files changed

+105
-134
lines changed

3 files changed

+105
-134
lines changed

packages/pigeon/lib/swift_generator.dart

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -638,24 +638,11 @@ import FlutterMacOS
638638
});
639639
}
640640

641-
void _writeValueOrNil(Indent indent) {
642-
indent.format('''
643-
644-
private func valueOrNil(value : Any?) -> Any? {
645-
if value is NSNull {
646-
return nil
647-
} else {
648-
return value
649-
}
650-
}''');
651-
}
652-
653641
@override
654642
void writeGeneralUtilities(
655643
SwiftOptions generatorOptions, Root root, Indent indent) {
656644
_writeWrapResult(indent);
657645
_writeWrapError(indent);
658-
_writeValueOrNil(indent);
659646
}
660647
}
661648

@@ -692,7 +679,7 @@ String _castForceUnwrap(String value, TypeDeclaration type, Root root) {
692679
// Special-cased to avoid warnings about using 'as' with Any.
693680
return value;
694681
} else if (type.isNullable) {
695-
return 'valueOrNil(value: $value) as! ${_swiftTypeForDartType(type)}$castUnwrap';
682+
return '($value is NSNull) ? (nil as Any?) as! ${_swiftTypeForDartType(type)}$castUnwrap : $value as! ${_swiftTypeForDartType(type)}$castUnwrap';
696683
} else {
697684
return '$value as! ${_swiftTypeForDartType(type)}$castUnwrap';
698685
}

0 commit comments

Comments
 (0)