Renders a Flutter app to the dock icon of an app.
The interesting bits are the following lines:
|
private func handleMessage(call: FlutterMethodCall, result: FlutterResult) { |
|
if call.method != "sync" { |
|
fatalError("fatalError") |
|
} |
|
let uintInt8List = call.arguments as! FlutterStandardTypedData |
|
let byte = [UInt8](uintInt8List.data) |
|
let imageView = NSImageView() |
|
imageView.image = NSImage(data: Data(byte)) |
|
NSApp.dockTile.contentView = imageView |
|
NSApp.dockTile.display() |
|
} |
|
Future<void> _syncToDockIcon() async { |
|
final renderObject = _screenshareKey.currentContext!.findRenderObject() |
|
as RenderRepaintBoundary; |
|
|
|
final image = await renderObject.toImage(pixelRatio: 0.3); |
|
final bytedata = await image.toByteData(format: ImageByteFormat.png); |
|
final bytelist = bytedata!.buffer.asUint8List(); |
|
await _channel.invokeMethod('sync', bytelist); |
|
} |