toJson method
Implementation
Map<String, dynamic> toJson() {
// Android setters accept signed 32-bit integers. Validate in release too.
for (final entry in <String, int?>{
'maxLogSizeM': maxLogSizeM,
'singleLogSizeM': singleLogSizeM,
'logExpireTimeS': logExpireTimeS,
}.entries) {
final value = entry.value;
if (value != null && (value <= 0 || value > 2147483647)) {
throw ArgumentError.value(value, entry.key, 'Must be a positive int32');
}
}
if ((singleLogSizeM ?? 2) > (maxLogSizeM ?? 100)) {
throw ArgumentError('singleLogSizeM must not exceed maxLogSizeM');
}
for (final entry in <String, String?>{
'logPath': logPath,
'deviceID': deviceID,
}.entries) {
if (entry.value != null && entry.value!.trim().isEmpty) {
throw ArgumentError.value(entry.value, entry.key, 'Must not be blank');
}
}
return {
'enable': enable,
if (logLevel != null) 'logLevel': logLevel!.name,
if (logPath != null) 'logPath': logPath,
if (maxLogSizeM != null) 'maxLogSizeM': maxLogSizeM,
if (singleLogSizeM != null) 'singleLogSizeM': singleLogSizeM,
if (logExpireTimeS != null) 'logExpireTimeS': logExpireTimeS,
if (deviceID != null) 'deviceID': deviceID,
};
}