Flukit-Group / flutter_mobile_controller

A PC client to control mobiles by adb tools in Flutter.
MIT License
7 stars 0 forks source link

Solution: How to implement Transparent FlutterViewController on macos #11

Open Moosphan opened 2 years ago

Moosphan commented 2 years ago

See: https://github.com/flutter/flutter/issues/59969

Example:

   // Transparent view
   self.isOpaque = false
   self.backgroundColor = .clear
   // Add the blur layer
    let blurView = NSVisualEffectView()
    let view = contentViewController?.view.superview;
    blurView.frame = CGRect(x: 0, y: 0, width: 2000, height: 2000)
    view?.addSubview(blurView, positioned: NSWindow.OrderingMode.below, relativeTo: nil)
Moosphan commented 2 years ago

If you modify your win32_windows.cpp by adding

#include <dwmapi.h>
#pragma comment(lib, "dwmapi.lib")
...
MARGINS margins = {-1};
DwmExtendFrameIntoClientArea(window, &margins)

after CreateWindow is called you'll be able to use transparency. Not sure how to do it in Dart yet, it's a good hack though.