Browse Source

Added handling for more null values

master
Kenneth Bruen 3 years ago
parent
commit
113808091e
Signed by: kbruen
GPG Key ID: C1980A470C3EE5B1
  1. 12
      bin/tdlib_gen.dart

12
bin/tdlib_gen.dart

@ -1,4 +1,5 @@
import 'dart:io';
import 'dart:typed_data';
import 'tl_scheme.dart';
@ -188,7 +189,14 @@ String findFromJsonHandling(
objectPrefix: objectPrefix,
varNameInsteadOfKeyName: 'e',
);
return '($varAccess as List<dynamic>).map((e) => ($innerHandler)).toList(growable: false)';
final innerType = findDartType(
tmp2,
scheme,
abstractPrefix: abstractPrefix,
functionPrefix: functionPrefix,
objectPrefix: objectPrefix,
);
return '$varAccess == null ? <$innerType>[] : ($varAccess as List<dynamic>).map((e) => ($innerHandler)).toList(growable: false)';
}
final predefined = {
@ -213,7 +221,7 @@ String findFromJsonHandling(
return "int.parse($varAccess ?? '0')";
}
else if (type == 'bytes') {
return 'base64.decode($varAccess)';
return '$varAccess == null ? Uint8List(0) : base64.decode($varAccess)';
}
else {
return 'b.TdBase.fromJson($varAccess) as ${findDartType(type, scheme, abstractPrefix: abstractPrefix, functionPrefix: functionPrefix, objectPrefix: objectPrefix)}';

Loading…
Cancel
Save