toJson method
Implementation
@override
Map<String, dynamic>? toJson(CupertinoThemeData? object) {
if (object == null) return null;
var runtimeTypeStr = object.runtimeType.toString();
// In Flutter < 1.24, the type is: CupertinoThemeData or _NoDefaultCupertinoThemeData
// In Flutter >= 1.24, the type is: NoDefaultCupertinoThemeData
assert(runtimeTypeStr == 'CupertinoThemeData' ||
runtimeTypeStr == 'NoDefaultCupertinoThemeData' ||
runtimeTypeStr == '_NoDefaultCupertinoThemeData');
if (runtimeTypeStr == 'CupertinoThemeData' ||
runtimeTypeStr == 'NoDefaultCupertinoThemeData' ||
runtimeTypeStr == '_NoDefaultCupertinoThemeData') {
return <String, dynamic>{
'barBackgroundColor':
const NullableColorConverter().toJson(object.barBackgroundColor),
'brightness':
const NullableBrightnessConverter().toJson(object.brightness),
'primaryColor':
const NullableColorConverter().toJson(object.primaryColor),
'primaryContrastingColor': const NullableColorConverter()
.toJson(object.primaryContrastingColor),
'scaffoldBackgroundColor': const NullableColorConverter()
.toJson(object.scaffoldBackgroundColor),
'textTheme': const NullableCupertinoTextThemeDataConverter()
.toJson(object.textTheme),
};
} else {
throw Exception(
'Unknown type passed in to [const NullableCupertinoThemeDataConverter().toJson]: [$runtimeTypeStr]',
);
}
}