Skip to content

Commit

Permalink
Fix Windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernthedev committed Nov 17, 2023
1 parent f0b55e7 commit 73a5fd8
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 13 deletions.
2 changes: 1 addition & 1 deletion generate_channels.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
& dart run pigeon --input native_channels/mouse_event.dart
& dart run pigeon --input pigeon/mouse_event.dart
# --objc_header_out ios/Runner/pigeon.h \
# --objc_source_out ios/Runner/pigeon.m \
# --experimental_swift_out ios/Runner/Pigeon.swift \
Expand Down
11 changes: 10 additions & 1 deletion native_channels/mouse_event.dart → pigeon/mouse_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:pigeon/pigeon.dart';
@ConfigurePigeon(PigeonOptions(
dartOut: 'lib/src/pigeon.g.dart',
dartOptions: DartOptions(),
cppOptions: CppOptions(namespace: "pigeon"),
cppOptions: CppOptions(namespace: "pigeon", ),
cppHeaderOut: 'windows/runner/pigeon.g.h',
cppSourceOut: 'windows/runner/pigeon.g.cpp',
objcHeaderOut: 'macos/Runner/pigeon.g.h',
Expand All @@ -12,10 +12,19 @@ import 'package:pigeon/pigeon.dart';
objcOptions: ObjcOptions(prefix: 'PGN'),
// copyrightHeader: 'pigeons/copyright.txt',
dartPackageName: 'desktop_adb_file_browser',

))

// https://github.com/flutter/flutter/issues/108682
@FlutterApi()
abstract class Native2Flutter {
void onClick(bool forward);
}

// For pigeon bug-testing
// @HostApi()
// abstract class Flutter2Native {
// void random(bool x);
// }


17 changes: 8 additions & 9 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ packages:
dependency: transitive
description:
name: file_selector_web
sha256: dc6622c4d66cb1bee623ddcc029036603c6cc45c85e4a775bb06008d61c809c1
sha256: c0f025d460de3301b7bbbf837fc8d0759df85f182c635f1dd94934b4cdc92352
url: "https://pub.dev"
source: hosted
version: "0.9.2+1"
version: "0.9.3"
file_selector_windows:
dependency: transitive
description:
Expand Down Expand Up @@ -452,10 +452,9 @@ packages:
pigeon:
dependency: "direct dev"
description:
name: pigeon
sha256: e0060b1e70d72d079d9325f58d6e6d656322c71cba826ef9eebb92a9c8bfa3b6
url: "https://pub.dev"
source: hosted
path: "E:\\SSDUse\\ProgrammingProjects\\FlutterProjects\\flutter_packages\\packages\\pigeon"
relative: false
source: path
version: "13.1.1"
platform:
dependency: transitive
Expand Down Expand Up @@ -631,7 +630,7 @@ packages:
source: hosted
version: "2.1.4"
version:
dependency: transitive
dependency: "direct main"
description:
name: version
sha256: "3d4140128e6ea10d83da32fef2fa4003fccbf6852217bb854845802f04191f94"
Expand Down Expand Up @@ -679,5 +678,5 @@ packages:
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.2.0-194.0.dev <4.0.0"
flutter: ">=3.13.0"
dart: ">=3.2.0 <4.0.0"
flutter: ">=3.16.0"
5 changes: 4 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@ dependencies:
# fluent_ui: ^4.4.1
# macos_ui: ^2.0.2
flutter_breadcrumb: ^1.0.1
version: ^3.0.2

dev_dependencies:
flutter_test:
sdk: flutter
pigeon: ^13.1.1
# pigeon: ^13.1.1
pigeon:
path: E:/SSDUse/ProgrammingProjects/FlutterProjects/flutter_packages/packages/pigeon

# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
Expand Down
3 changes: 3 additions & 0 deletions windows/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Project-level configuration.
cmake_minimum_required(VERSION 3.14)

set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)

project(desktop_adb_file_browser LANGUAGES CXX)

# The name of the executable created for the application. Change this to change
Expand Down
2 changes: 2 additions & 0 deletions windows/runner/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
cmake_minimum_required(VERSION 3.14)
project(runner LANGUAGES CXX)

set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)

# Define the application target. To change its name, change BINARY_NAME in the
# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer
# work.
Expand Down
2 changes: 1 addition & 1 deletion windows/runner/flutter_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ FlutterWindow::MessageHandler(HWND hwnd, UINT const message,
if (forward || back) {
nativeToFlutter->OnClick(
forward, []() {},
[](FlutterError const &e) {
[](pigeon::FlutterError const &e) {
std::cout << "Error: " << e.code() << " " << e.message() << std::endl;
// std::cout << "Details: " << e.details() << std::endl;
});
Expand Down
39 changes: 39 additions & 0 deletions windows/runner/pigeon.g.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,45 @@ namespace pigeon {


// Generated class from Pigeon.

class FlutterError {
public:
explicit FlutterError(const std::string& code)
: code_(code) {}
explicit FlutterError(const std::string& code, const std::string& message)
: code_(code), message_(message) {}
explicit FlutterError(const std::string& code, const std::string& message, const flutter::EncodableValue& details)
: code_(code), message_(message), details_(details) {}

const std::string& code() const { return code_; }
const std::string& message() const { return message_; }
const flutter::EncodableValue& details() const { return details_; }

private:
std::string code_;
std::string message_;
flutter::EncodableValue details_;
};

template<class T> class ErrorOr {
public:
ErrorOr(const T& rhs) : v_(rhs) {}
ErrorOr(const T&& rhs) : v_(std::move(rhs)) {}
ErrorOr(const FlutterError& rhs) : v_(rhs) {}
ErrorOr(const FlutterError&& rhs) : v_(std::move(rhs)) {}

bool has_error() const { return std::holds_alternative<FlutterError>(v_); }
const T& value() const { return std::get<T>(v_); };
const FlutterError& error() const { return std::get<FlutterError>(v_); };

private:
friend class Native2Flutter;
ErrorOr() = default;
T TakeValue() && { return std::get<T>(std::move(v_)); }

std::variant<T, FlutterError> v_;
};

// Generated class from Pigeon that represents Flutter messages that can be called from C++.
class Native2Flutter {
public:
Expand Down

0 comments on commit 73a5fd8

Please sign in to comment.