main.cpp
1 #include <flutter/dart_project.h> 2 #include <flutter/flutter_view_controller.h> 3 #include <windows.h> 4 5 #include "flutter_window.h" 6 #include "utils.h" 7 8 int APIENTRY wWinMain( 9 _In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, _In_ wchar_t *command_line, 10 _In_ int show_command 11 ) { 12 // Attach to console when present (e.g., 'flutter run') or create a 13 // new console when running with a debugger. 14 if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 15 CreateAndAttachConsole(); 16 } 17 18 // Initialize COM, so that it is available for use in the library and/or 19 // plugins. 20 ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 21 22 flutter::DartProject project(L"data"); 23 24 std::vector<std::string> command_line_arguments = GetCommandLineArguments(); 25 26 project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 27 28 FlutterWindow window(project); 29 Win32Window::Point origin(10, 10); 30 Win32Window::Size size(1280, 720); 31 if (!window.Create(L"amaze", origin, size)) { 32 return EXIT_FAILURE; 33 } 34 window.SetQuitOnClose(true); 35 36 ::MSG msg; 37 while (::GetMessage(&msg, nullptr, 0, 0)) { 38 ::TranslateMessage(&msg); 39 ::DispatchMessage(&msg); 40 } 41 42 ::CoUninitialize(); 43 return EXIT_SUCCESS; 44 }