agent-workspace / flutter /packages /flutter_tools /templates /plugin /windows.tmpl /pluginClassSnakeCase.cpp.tmpl
agent-workspace / flutter /packages /flutter_tools /templates /plugin /windows.tmpl /pluginClassSnakeCase.cpp.tmpl
Download flutter/packages/flutter_tools/templates/plugin/windows.tmpl/pluginClassSnakeCase.cpp.tmpl from luom2645/agent-workspace: direct link, hf CLI and curl.
- Browser
- Download file 1.78 kB
-
https://huggingface.co/luom2645/agent-workspace/resolve/main/flutter/packages/flutter_tools/templates/plugin/windows.tmpl/pluginClassSnakeCase.cpp.tmpl
- Command line
-
hf download hf://luom2645/agent-workspace/flutter/packages/flutter_tools/templates/plugin/windows.tmpl/pluginClassSnakeCase.cpp.tmpl
-
curl -L -o pluginClassSnakeCase.cpp.tmpl https://huggingface.co/luom2645/agent-workspace/resolve/main/flutter/packages/flutter_tools/templates/plugin/windows.tmpl/pluginClassSnakeCase.cpp.tmpl
1.78 kB
| // This must be included before many other Windows headers. | |
| // For getPlatformVersion; remove unless needed for your plugin implementation. | |
| namespace {{projectName}} { | |
| // static | |
| void {{pluginClass}}::RegisterWithRegistrar( | |
| flutter::PluginRegistrarWindows *registrar) { | |
| auto channel = | |
| std::make_unique<flutter::MethodChannel<flutter::EncodableValue>>( | |
| registrar->messenger(), "{{projectName}}", | |
| &flutter::StandardMethodCodec::GetInstance()); | |
| auto plugin = std::make_unique<{{pluginClass}}>(); | |
| channel->SetMethodCallHandler( | |
| [plugin_pointer = plugin.get()](const auto &call, auto result) { | |
| plugin_pointer->HandleMethodCall(call, std::move(result)); | |
| }); | |
| registrar->AddPlugin(std::move(plugin)); | |
| } | |
| {{pluginClass}}::{{pluginClass}}() {} | |
| {{pluginClass}}::~{{pluginClass}}() {} | |
| void {{pluginClass}}::HandleMethodCall( | |
| const flutter::MethodCall<flutter::EncodableValue> &method_call, | |
| std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result) { | |
| if (method_call.method_name().compare("getPlatformVersion") == 0) { | |
| std::ostringstream version_stream; | |
| version_stream << "Windows "; | |
| if (IsWindows10OrGreater()) { | |
| version_stream << "10+"; | |
| } else if (IsWindows8OrGreater()) { | |
| version_stream << "8"; | |
| } else if (IsWindows7OrGreater()) { | |
| version_stream << "7"; | |
| } | |
| result->Success(flutter::EncodableValue(version_stream.str())); | |
| } else { | |
| result->NotImplemented(); | |
| } | |
| } | |
| } // namespace {{projectName}} | |