flutter: Catcher: Only enable on Android or iOS

This commit is contained in:
Calcitem 2021-02-17 22:25:11 +08:00
parent ffa1bf986c
commit a96268d720
3 changed files with 20 additions and 11 deletions

View File

@ -34,6 +34,11 @@ import 'widgets/main_menu.dart';
//import 'package:sentry_flutter/sentry_flutter.dart';
Future<void> main() async {
if (!(Platform.isAndroid || Platform.isIOS)) {
runApp(SanmillApp());
return;
}
var catcher = Catcher(rootWidget: SanmillApp(), ensureInitialized: true);
//DateTime now = DateTime.now();

View File

@ -53,15 +53,19 @@ bool FlutterWindow::OnCreate() {
}
RegisterPlugins(flutter_controller_->engine());
engine = new MillEngine();
auto channel = std::make_unique<flutter::MethodChannel<>>(
flutter_controller_->engine()->messenger(), "com.calcitem.sanmill/engine",
&flutter::StandardMethodCodec::GetInstance());
channel->SetMethodCallHandler(
[this](const auto &call, auto result) {
HandleMethodCall(call, std::move(result));
}
);
if (engine == nullptr) {
engine = new MillEngine();
auto channel = std::make_unique<flutter::MethodChannel<>>(
flutter_controller_->engine()->messenger(), "com.calcitem.sanmill/engine",
&flutter::StandardMethodCodec::GetInstance());
channel->SetMethodCallHandler(
[this](const auto &call, auto result) {
HandleMethodCall(call, std::move(result));
}
);
}
run_loop_->RegisterFlutterInstance(flutter_controller_->engine());
SetChildContent(flutter_controller_->view()->GetNativeWindow());

View File

@ -38,7 +38,7 @@ extern "C" {
EngineState state = EngineState::STATE_READY;
pthread_t thread_id = nullptr;
void *engineThread(void *)
DWORD WINAPI engineThread(LPVOID lpParam)
{
printf("Engine Think Thread enter.\n");
@ -46,7 +46,7 @@ void *engineThread(void *)
printf("Engine Think Thread exit.\n");
return nullptr;
return 0;
}
int MillEngine::startup()