toJson method
Convert the current object to JSON.
Returns a Map with key-value pairs representing the object's data. Each key corresponds to a property of the object.
Each value is the value of that property. The values may be basic types (e.g. String, int, bool, etc.),
Types that can be directly converted to JSON (e.g. List, Map), or objects that implement the toJson method.
The Map can be converted directly to a JSON string.
Implementation
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['type'] = _fromEnumType(this.type!);
// Windows 原生层期望 int 类型,macOS 期望 String 类型
if (Platform.isWindows) {
data['sourceId'] = this.sourceId != null ? int.tryParse(this.sourceId!) : null;
} else {
data['sourceId'] = this.sourceId;
}
data['sourceName'] = this.sourceName;
data['thumbBGRA'] = this.thumbBGRA?.toJson();
data['iconBGRA'] = this.iconBGRA?.toJson();
data['isMinimizeWindow'] = this.isMinimizeWindow;
data['isMainScreen'] = this.isMainScreen;
data['x'] = this.x;
data['y'] = this.y;
data['width'] = this.width;
data['height'] = this.height;
return data;
}