Skip to content

feat: Flutter engine integration#427

Open
LuckZAE wants to merge 7 commits into
Snapmaker:feature_flutter_enginefrom
LuckZAE:develop
Open

feat: Flutter engine integration#427
LuckZAE wants to merge 7 commits into
Snapmaker:feature_flutter_enginefrom
LuckZAE:develop

Conversation

@LuckZAE
Copy link
Copy Markdown

@LuckZAE LuckZAE commented Jun 3, 2026

Summary

Add FlutterChannel communication layer to establish structured message passing between the C++ backend and Flutter engine.

Changes

New Files

  • FlutterChannel.cpp / FlutterChannel.h — Core channel implementation for bidirectional C++ ↔ Flutter communication
  • FlutterMiddleware.cpp — Middleware layer for intercepting and processing channel messages
  • test_flutter.cpp — Unit tests for the FlutterChannel communication layer

Modified Files

  • CMakeLists.txt (src) — Register new Flutter source files in the build system
  • FlutterPanel.hpp — Wire up FlutterChannel into the Flutter panel component
  • CMakeLists.txt (tests) — Replace old test target with new test_flutter

Removed Files

  • test_flutter_platform.cpp — Superseded by test_flutter.cpp

FlutterViewHost::Reply reply) override {
auto fn = std::make_shared<FlutterViewHost::Reply>(std::move(reply));
auto fired = std::make_shared<bool>(false);
auto t = std::make_unique<wxTimer>(this);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handler 正常返回后主动取消对应的 timer 即可,这样写 m_timers 会无限增长

// Middleware factory functions
std::shared_ptr<FlutterChannel::Middleware> makeLoggingMiddleware();
std::shared_ptr<FlutterChannel::Middleware> makeThreadGuardMiddleware();
std::shared_ptr<FlutterChannel::Middleware> makeTimeoutMiddleware(int seconds);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议用 makeTimeoutMiddleware (std::chrono::seconds seconds)

using MiddlewarePtr = std::shared_ptr<class Middleware>;

explicit FlutterChannel(const std::string& name);
FlutterChannel(const FlutterChannel&) = delete;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

显式删除了拷贝构造/赋值,但没有声明移动构造/赋值,建议显式加上移动构造

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants