@@ -346,9 +346,10 @@ class Translator {
346
346
}
347
347
}
348
348
349
- code.TypeDef _typedef (String name, String type) => code.TypeDef ((b) => b
350
- ..name = name
351
- ..definition = _typeReference (type));
349
+ code.TypeDef _typedef (String name, String type, bool nullable) =>
350
+ code.TypeDef ((b) => b
351
+ ..name = name
352
+ ..definition = _typeReference (type, isNullable: nullable));
352
353
353
354
code.Method _topLevelGetter (String dartName, String getterName) =>
354
355
code.Method ((b) => b
@@ -674,17 +675,19 @@ class Translator {
674
675
..comments.addAll (licenseHeader)
675
676
..body.addAll ([
676
677
for (final typedef in library.typedefs)
677
- _typedef (typedef .name.toDart, _typeRaw (typedef .idlType)),
678
+ _typedef (typedef .name.toDart, _typeRaw (typedef .idlType),
679
+ typedef .idlType.nullable.toDart),
678
680
// TODO(joshualitt): We should lower callbacks and callback interfaces to
679
681
// a Dart function that takes a typed Dart function, and returns an
680
682
// JSFunction.
681
683
for (final callback in library.callbacks)
682
- _typedef (callback.name.toDart, 'JSFunction' ),
684
+ _typedef (callback.name.toDart, 'JSFunction' , false ),
683
685
for (final callbackInterface in library.callbackInterfaces)
684
- _typedef (callbackInterface.name.toDart, 'JSFunction' ),
686
+ _typedef (callbackInterface.name.toDart, 'JSFunction' , false ),
685
687
// TODO(joshualitt): Enums in the WebIDL are just strings, but we could
686
688
// make them easier to work with on the Dart side.
687
- for (final enum_ in library.enums) _typedef (enum_.name.toDart, 'String' ),
689
+ for (final enum_ in library.enums)
690
+ _typedef (enum_.name.toDart, 'String' , false ),
688
691
for (final interfacelike in library.interfacelikes)
689
692
..._interfacelike (interfacelike),
690
693
]));
0 commit comments