Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution: How to implement Transparent FlutterViewController on macos #11

Open
Moosphan opened this issue Feb 24, 2022 · 1 comment
Open
Labels
question Further information is requested solutions UI

Comments

@Moosphan
Copy link
Collaborator

See: flutter/flutter#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 Moosphan added question Further information is requested solutions UI labels Feb 24, 2022
@Moosphan
Copy link
Collaborator Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested solutions UI
Projects
None yet
Development

No branches or pull requests

1 participant