├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── android ├── app │ ├── build.gradle │ ├── old_build.gradle │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── io │ │ │ │ └── flutter │ │ │ │ └── plugins │ │ │ │ └── GeneratedPluginRegistrant.java │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── openlabx │ │ │ │ └── open_qr_code │ │ │ │ ├── MainActivity.kt │ │ │ │ └── old_MainActivity.kt │ │ ├── old_AndroidManifest.xml │ │ └── res │ │ │ ├── drawable-v21 │ │ │ └── launch_background.xml │ │ │ ├── drawable │ │ │ ├── launch_background.xml │ │ │ ├── logo_v1.png │ │ │ └── old_launch_background.xml │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── logo_v1.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── logo_v1.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── logo_v1.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── logo_v1.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── logo_v1.png │ │ │ ├── values-night │ │ │ └── styles.xml │ │ │ └── values │ │ │ └── styles.xml │ │ └── profile │ │ └── AndroidManifest.xml ├── build.gradle ├── f.md ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── local.properties ├── open_qr_code_android.iml └── settings.gradle ├── assets ├── icons │ ├── fb_64px.png │ ├── git_64px.png │ ├── ig_64px.png │ ├── in_64px.png │ ├── x_64px.png │ └── yt_64px.png └── images │ ├── logo.webp │ ├── logo1.png │ ├── logo1.webp │ ├── logo_v1.ico │ └── logo_v1.png ├── downlaod ├── Open QR Code-v1.0.0.apk └── OpenQRCode.zip ├── firebase.json ├── lib ├── app.dart ├── core │ ├── providers │ │ ├── qr_provider.dart │ │ └── theme_provider.dart │ └── themes │ │ ├── dark_theme.dart │ │ └── light_theme.dart ├── main.dart ├── presentation │ └── screens │ │ ├── home │ │ ├── home_screen.dart │ │ └── old_home_screen.dart │ │ ├── qr_generator │ │ ├── old_qr_generator_screen.dart │ │ ├── qr_generator_screen.dart │ │ ├── qr_generator_screen_mobile.dart │ │ └── qr_generator_screen_web.dart │ │ ├── qr_scanner │ │ └── qr_scanner_screen.dart │ │ └── settings │ │ ├── old_settings_screen.dart │ │ └── settings_screen.dart └── services │ ├── history_service.dart │ └── qr_service.dart ├── open_qr_code.iml ├── pubspec.lock ├── pubspec.yaml ├── screenshots ├── android │ ├── 1.jpg │ ├── 10.jpg │ ├── 11.jpg │ ├── 12.jpg │ ├── 13.jpg │ ├── 14.jpg │ ├── 15.jpg │ ├── 17.jpg │ ├── 18.jpg │ ├── 19.jpg │ ├── 2.jpg │ ├── 20.jpg │ ├── 21.jpg │ ├── 22.jpg │ ├── 23.jpg │ ├── 24.jpg │ ├── 25.jpg │ ├── 26.jpg │ ├── 3.jpg │ ├── 4.jpg │ ├── 5.jpg │ ├── 6.jpg │ ├── 7.jpg │ ├── 8.jpg │ ├── 9.jpg │ ├── openlabx QR Code.png │ └── qr_code_1725352250881.png ├── logo_v1.png ├── multiview.png ├── multiview2.png ├── openlabx QR Code.png └── win │ ├── 1.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ ├── 6.png │ ├── 7.png │ └── 8.png ├── test └── f.md ├── web ├── favicon.png ├── icons │ ├── Icon-192.png │ ├── Icon-512.png │ ├── Icon-maskable-192.png │ └── Icon-maskable-512.png ├── index.html └── manifest.json └── windows ├── CMakeLists.txt ├── f.md ├── flutter ├── CMakeLists.txt ├── ephemeral │ ├── cpp_client_wrapper │ │ ├── binary_messenger_impl.h │ │ ├── byte_buffer_streams.h │ │ ├── core_implementations.cc │ │ ├── engine_method_result.cc │ │ ├── flutter_engine.cc │ │ ├── flutter_view_controller.cc │ │ ├── include │ │ │ └── flutter │ │ │ │ ├── basic_message_channel.h │ │ │ │ ├── binary_messenger.h │ │ │ │ ├── byte_streams.h │ │ │ │ ├── dart_project.h │ │ │ │ ├── encodable_value.h │ │ │ │ ├── engine_method_result.h │ │ │ │ ├── event_channel.h │ │ │ │ ├── event_sink.h │ │ │ │ ├── event_stream_handler.h │ │ │ │ ├── event_stream_handler_functions.h │ │ │ │ ├── flutter_engine.h │ │ │ │ ├── flutter_view.h │ │ │ │ ├── flutter_view_controller.h │ │ │ │ ├── message_codec.h │ │ │ │ ├── method_call.h │ │ │ │ ├── method_channel.h │ │ │ │ ├── method_codec.h │ │ │ │ ├── method_result.h │ │ │ │ ├── method_result_functions.h │ │ │ │ ├── plugin_registrar.h │ │ │ │ ├── plugin_registrar_windows.h │ │ │ │ ├── plugin_registry.h │ │ │ │ ├── standard_codec_serializer.h │ │ │ │ ├── standard_message_codec.h │ │ │ │ ├── standard_method_codec.h │ │ │ │ └── texture_registrar.h │ │ ├── plugin_registrar.cc │ │ ├── readme │ │ ├── standard_codec.cc │ │ └── texture_registrar_impl.h │ ├── f.md │ ├── flutter_export.h │ ├── flutter_messenger.h │ ├── flutter_plugin_registrar.h │ ├── flutter_texture_registrar.h │ ├── flutter_windows.dll │ ├── flutter_windows.dll.exp │ └── flutter_windows.dll.lib ├── f.md ├── generated_plugin_registrant.cc ├── generated_plugin_registrant.h └── generated_plugins.cmake └── runner ├── CMakeLists.txt ├── Runner.rc ├── flutter_window.cpp ├── flutter_window.h ├── main.cpp ├── old_CMakeLists.txt ├── old_Runner.rc ├── old_main.cpp ├── resource.h ├── resources ├── app_icon.ico └── logo_v1.ico ├── runner.exe.manifest ├── utils.cpp ├── utils.h ├── win32_window.cpp └── win32_window.h /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 OpenLabX 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "com.android.application" 3 | id "kotlin-android" 4 | // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. 5 | id "dev.flutter.flutter-gradle-plugin" 6 | } 7 | 8 | android { 9 | namespace = "com.openlabx.open_qr_code" 10 | compileSdk = flutter.compileSdkVersion 11 | ndkVersion = flutter.ndkVersion 12 | 13 | compileOptions { 14 | sourceCompatibility = JavaVersion.VERSION_1_8 15 | targetCompatibility = JavaVersion.VERSION_1_8 16 | } 17 | 18 | kotlinOptions { 19 | jvmTarget = "1.8" 20 | } 21 | 22 | defaultConfig { 23 | applicationId = "com.openlabx.open_qr_code" 24 | minSdk = flutter.minSdkVersion 25 | targetSdk = flutter.targetSdkVersion 26 | versionCode = flutter.versionCode 27 | versionName = flutter.versionName 28 | } 29 | 30 | buildTypes { 31 | release { 32 | // Add your signing config for the release build. 33 | signingConfig = signingConfigs.debug 34 | minifyEnabled false 35 | shrinkResources false 36 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 37 | 38 | // Rename the APK file to "Open QR Code-v{versionName}.apk" 39 | applicationVariants.all { variant -> 40 | variant.outputs.all { 41 | def appName = "Open QR Code" 42 | def versionName = variant.versionName 43 | outputFileName = "${appName}-v${versionName}.apk" 44 | } 45 | } 46 | } 47 | } 48 | } 49 | 50 | flutter { 51 | source = "../.." 52 | } 53 | -------------------------------------------------------------------------------- /android/app/old_build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "com.android.application" 3 | id "kotlin-android" 4 | // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. 5 | id "dev.flutter.flutter-gradle-plugin" 6 | } 7 | 8 | android { 9 | namespace = "com.example.open_qr_code" 10 | compileSdk = flutter.compileSdkVersion 11 | ndkVersion = flutter.ndkVersion 12 | 13 | compileOptions { 14 | sourceCompatibility = JavaVersion.VERSION_1_8 15 | targetCompatibility = JavaVersion.VERSION_1_8 16 | } 17 | 18 | kotlinOptions { 19 | jvmTarget = JavaVersion.VERSION_1_8 20 | } 21 | 22 | defaultConfig { 23 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 24 | applicationId = "com.openlabx.open_qr_code" 25 | // You can update the following values to match your application needs. 26 | // For more information, see: https://flutter.dev/to/review-gradle-config. 27 | minSdk = flutter.minSdkVersion 28 | targetSdk = flutter.targetSdkVersion 29 | versionCode = flutter.versionCode 30 | versionName = flutter.versionName 31 | } 32 | 33 | buildTypes { 34 | release { 35 | // TODO: Add your own signing config for the release build. 36 | // Signing with the debug keys for now, so `flutter run --release` works. 37 | signingConfig = signingConfigs.debug 38 | } 39 | } 40 | } 41 | 42 | flutter { 43 | source = "../.." 44 | } 45 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | 25 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java: -------------------------------------------------------------------------------- 1 | package io.flutter.plugins; 2 | 3 | import androidx.annotation.Keep; 4 | import androidx.annotation.NonNull; 5 | import io.flutter.Log; 6 | 7 | import io.flutter.embedding.engine.FlutterEngine; 8 | 9 | /** 10 | * Generated file. Do not edit. 11 | * This file is generated by the Flutter tool based on the 12 | * plugins that support the Android platform. 13 | */ 14 | @Keep 15 | public final class GeneratedPluginRegistrant { 16 | private static final String TAG = "GeneratedPluginRegistrant"; 17 | public static void registerWith(@NonNull FlutterEngine flutterEngine) { 18 | try { 19 | flutterEngine.getPlugins().add(new io.flutter.plugins.camerax.CameraAndroidCameraxPlugin()); 20 | } catch (Exception e) { 21 | Log.e(TAG, "Error registering plugin camera_android_camerax, io.flutter.plugins.camerax.CameraAndroidCameraxPlugin", e); 22 | } 23 | try { 24 | flutterEngine.getPlugins().add(new io.flutter.plugins.firebase.core.FlutterFirebaseCorePlugin()); 25 | } catch (Exception e) { 26 | Log.e(TAG, "Error registering plugin firebase_core, io.flutter.plugins.firebase.core.FlutterFirebaseCorePlugin", e); 27 | } 28 | try { 29 | flutterEngine.getPlugins().add(new io.flutter.plugins.flutter_plugin_android_lifecycle.FlutterAndroidLifecyclePlugin()); 30 | } catch (Exception e) { 31 | Log.e(TAG, "Error registering plugin flutter_plugin_android_lifecycle, io.flutter.plugins.flutter_plugin_android_lifecycle.FlutterAndroidLifecyclePlugin", e); 32 | } 33 | try { 34 | flutterEngine.getPlugins().add(new dev.fluttercommunity.plus.packageinfo.PackageInfoPlugin()); 35 | } catch (Exception e) { 36 | Log.e(TAG, "Error registering plugin package_info_plus, dev.fluttercommunity.plus.packageinfo.PackageInfoPlugin", e); 37 | } 38 | try { 39 | flutterEngine.getPlugins().add(new io.flutter.plugins.pathprovider.PathProviderPlugin()); 40 | } catch (Exception e) { 41 | Log.e(TAG, "Error registering plugin path_provider_android, io.flutter.plugins.pathprovider.PathProviderPlugin", e); 42 | } 43 | try { 44 | flutterEngine.getPlugins().add(new net.touchcapture.qr.flutterqr.FlutterQrPlugin()); 45 | } catch (Exception e) { 46 | Log.e(TAG, "Error registering plugin qr_code_scanner, net.touchcapture.qr.flutterqr.FlutterQrPlugin", e); 47 | } 48 | try { 49 | flutterEngine.getPlugins().add(new dev.fluttercommunity.plus.share.SharePlusPlugin()); 50 | } catch (Exception e) { 51 | Log.e(TAG, "Error registering plugin share_plus, dev.fluttercommunity.plus.share.SharePlusPlugin", e); 52 | } 53 | try { 54 | flutterEngine.getPlugins().add(new io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin()); 55 | } catch (Exception e) { 56 | Log.e(TAG, "Error registering plugin shared_preferences_android, io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin", e); 57 | } 58 | try { 59 | flutterEngine.getPlugins().add(new io.flutter.plugins.urllauncher.UrlLauncherPlugin()); 60 | } catch (Exception e) { 61 | Log.e(TAG, "Error registering plugin url_launcher_android, io.flutter.plugins.urllauncher.UrlLauncherPlugin", e); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/openlabx/open_qr_code/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.openlabx.open_qr_code 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/openlabx/open_qr_code/old_MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.open_qr_code 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() 6 | -------------------------------------------------------------------------------- /android/app/src/main/old_AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 16 | 20 | 24 | 25 | 26 | 27 | 28 | 29 | 31 | 34 | 35 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/logo_v1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/android/app/src/main/res/drawable/logo_v1.png -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/old_launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/logo_v1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/android/app/src/main/res/mipmap-hdpi/logo_v1.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/logo_v1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/android/app/src/main/res/mipmap-mdpi/logo_v1.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/logo_v1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/android/app/src/main/res/mipmap-xhdpi/logo_v1.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/logo_v1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/android/app/src/main/res/mipmap-xxhdpi/logo_v1.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/logo_v1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/android/app/src/main/res/mipmap-xxxhdpi/logo_v1.png -------------------------------------------------------------------------------- /android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | allprojects { 2 | repositories { 3 | google() 4 | mavenCentral() 5 | } 6 | } 7 | 8 | rootProject.buildDir = "../build" 9 | subprojects { 10 | project.buildDir = "${rootProject.buildDir}/${project.name}" 11 | } 12 | subprojects { 13 | project.evaluationDependsOn(":app") 14 | } 15 | 16 | tasks.register("clean", Delete) { 17 | delete rootProject.buildDir 18 | } 19 | -------------------------------------------------------------------------------- /android/f.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip 6 | -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /android/local.properties: -------------------------------------------------------------------------------- 1 | sdk.dir=C:\\Users\\demo\\AppData\\Local\\Android\\sdk 2 | flutter.sdk=C:\\src\\flutter 3 | flutter.buildMode=release 4 | flutter.versionName=1.0.0 5 | flutter.versionCode=1 -------------------------------------------------------------------------------- /android/open_qr_code_android.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | def flutterSdkPath = { 3 | def properties = new Properties() 4 | file("local.properties").withInputStream { properties.load(it) } 5 | def flutterSdkPath = properties.getProperty("flutter.sdk") 6 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 7 | return flutterSdkPath 8 | }() 9 | 10 | includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") 11 | 12 | repositories { 13 | google() 14 | mavenCentral() 15 | gradlePluginPortal() 16 | } 17 | } 18 | 19 | plugins { 20 | id "dev.flutter.flutter-plugin-loader" version "1.0.0" 21 | id "com.android.application" version "7.3.0" apply false 22 | id "org.jetbrains.kotlin.android" version "1.7.10" apply false 23 | } 24 | 25 | include ":app" 26 | -------------------------------------------------------------------------------- /assets/icons/fb_64px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/assets/icons/fb_64px.png -------------------------------------------------------------------------------- /assets/icons/git_64px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/assets/icons/git_64px.png -------------------------------------------------------------------------------- /assets/icons/ig_64px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/assets/icons/ig_64px.png -------------------------------------------------------------------------------- /assets/icons/in_64px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/assets/icons/in_64px.png -------------------------------------------------------------------------------- /assets/icons/x_64px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/assets/icons/x_64px.png -------------------------------------------------------------------------------- /assets/icons/yt_64px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/assets/icons/yt_64px.png -------------------------------------------------------------------------------- /assets/images/logo.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/assets/images/logo.webp -------------------------------------------------------------------------------- /assets/images/logo1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/assets/images/logo1.png -------------------------------------------------------------------------------- /assets/images/logo1.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/assets/images/logo1.webp -------------------------------------------------------------------------------- /assets/images/logo_v1.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/assets/images/logo_v1.ico -------------------------------------------------------------------------------- /assets/images/logo_v1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/assets/images/logo_v1.png -------------------------------------------------------------------------------- /downlaod/Open QR Code-v1.0.0.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/downlaod/Open QR Code-v1.0.0.apk -------------------------------------------------------------------------------- /downlaod/OpenQRCode.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/downlaod/OpenQRCode.zip -------------------------------------------------------------------------------- /firebase.json: -------------------------------------------------------------------------------- 1 | { 2 | "hosting": { 3 | "public": "build/web", 4 | "ignore": [ 5 | "firebase.json", 6 | "**/.*", 7 | "**/node_modules/**" 8 | ] 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /lib/app.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:provider/provider.dart'; 3 | import 'presentation/screens/home/home_screen.dart'; 4 | import 'core/themes/light_theme.dart'; 5 | import 'core/themes/dark_theme.dart'; 6 | import 'core/providers/theme_provider.dart'; 7 | 8 | class MyApp extends StatelessWidget { 9 | @override 10 | Widget build(BuildContext context) { 11 | return Consumer( 12 | builder: (context, themeProvider, child) { 13 | return MaterialApp( 14 | title: 'Open QR Code', 15 | theme: lightTheme, 16 | darkTheme: darkTheme, 17 | themeMode: themeProvider.themeMode, 18 | home: HomeScreen(), 19 | debugShowCheckedModeBanner: false, // Disable the debug banner 20 | ); 21 | }, 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/core/providers/qr_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class QRProvider extends ChangeNotifier { 4 | String? _qrData; 5 | 6 | String? get qrData => _qrData; 7 | 8 | void setQRData(String data) { 9 | _qrData = data; 10 | notifyListeners(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/core/providers/theme_provider.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:shared_preferences/shared_preferences.dart'; 3 | 4 | class ThemeProvider extends ChangeNotifier { 5 | ThemeMode _themeMode = ThemeMode.system; 6 | 7 | ThemeMode get themeMode => _themeMode; 8 | 9 | ThemeProvider() { 10 | _loadThemePreference(); 11 | } 12 | 13 | void _loadThemePreference() async { 14 | final prefs = await SharedPreferences.getInstance(); 15 | final themeMode = prefs.getString('themeMode'); 16 | 17 | if (themeMode != null) { 18 | _themeMode = ThemeMode.values 19 | .firstWhere((element) => element.toString() == themeMode); 20 | } 21 | notifyListeners(); 22 | } 23 | 24 | void setTheme(ThemeMode mode) async { 25 | _themeMode = mode; 26 | notifyListeners(); 27 | 28 | final prefs = await SharedPreferences.getInstance(); 29 | await prefs.setString('themeMode', mode.toString()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /lib/core/themes/dark_theme.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | final ThemeData darkTheme = ThemeData( 4 | primarySwatch: Colors.blue, 5 | brightness: Brightness.dark, 6 | visualDensity: VisualDensity.adaptivePlatformDensity, 7 | ); 8 | -------------------------------------------------------------------------------- /lib/core/themes/light_theme.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | final ThemeData lightTheme = ThemeData( 4 | primarySwatch: Colors.blue, 5 | brightness: Brightness.light, 6 | visualDensity: VisualDensity.adaptivePlatformDensity, 7 | ); 8 | -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:provider/provider.dart'; 3 | import 'app.dart'; 4 | import 'core/providers/theme_provider.dart'; 5 | import 'package:firebase_core/firebase_core.dart'; 6 | 7 | void main() { 8 | runApp( 9 | MultiProvider( 10 | providers: [ 11 | ChangeNotifierProvider(create: (_) => ThemeProvider()), 12 | ], 13 | child: MyApp(), 14 | ), 15 | ); 16 | } 17 | -------------------------------------------------------------------------------- /lib/presentation/screens/home/home_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import '../qr_generator/qr_generator_screen.dart'; 3 | import '../qr_scanner/qr_scanner_screen.dart'; 4 | import '../settings/settings_screen.dart'; 5 | 6 | class HomeScreen extends StatelessWidget { 7 | @override 8 | Widget build(BuildContext context) { 9 | return Scaffold( 10 | appBar: AppBar( 11 | title: Text('Open QR Code'), 12 | actions: [ 13 | IconButton( 14 | icon: Icon(Icons.settings), 15 | onPressed: () { 16 | Navigator.of(context).push( 17 | MaterialPageRoute(builder: (context) => SettingsScreen()), 18 | ); 19 | }, 20 | ), 21 | ], 22 | ), 23 | body: Column( 24 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 25 | children: [ 26 | Expanded( 27 | child: Center( 28 | child: Column( 29 | mainAxisAlignment: MainAxisAlignment.center, 30 | children: [ 31 | // Logo Image 32 | Image.asset( 33 | 'assets/images/logo_v1.png', 34 | height: 360, // Adjust height as needed 35 | ), 36 | SizedBox(height: 20), 37 | Text( 38 | 'Welcome to Open QR Code', 39 | style: Theme.of(context).textTheme.titleLarge, 40 | ), 41 | SizedBox(height: 40), 42 | ElevatedButton( 43 | onPressed: () { 44 | Navigator.of(context).push( 45 | MaterialPageRoute( 46 | builder: (context) => QRGeneratorScreen()), 47 | ); 48 | }, 49 | style: ElevatedButton.styleFrom( 50 | shape: RoundedRectangleBorder( 51 | borderRadius: BorderRadius.circular(8.0), 52 | ), 53 | padding: 54 | EdgeInsets.symmetric(horizontal: 60, vertical: 20), 55 | ), 56 | child: Text( 57 | 'Generate QR Code', 58 | style: TextStyle(fontSize: 18), 59 | ), 60 | ), 61 | SizedBox(height: 20), 62 | ElevatedButton( 63 | onPressed: () { 64 | Navigator.of(context).push( 65 | MaterialPageRoute( 66 | builder: (context) => QRScannerScreen()), 67 | ); 68 | }, 69 | style: ElevatedButton.styleFrom( 70 | shape: RoundedRectangleBorder( 71 | borderRadius: BorderRadius.circular(8.0), 72 | ), 73 | padding: 74 | EdgeInsets.symmetric(horizontal: 60, vertical: 20), 75 | ), 76 | child: Text( 77 | 'Scan QR Code', 78 | style: TextStyle(fontSize: 18), 79 | ), 80 | ), 81 | ], 82 | ), 83 | ), 84 | ), 85 | Padding( 86 | padding: const EdgeInsets.all(8.0), 87 | child: Column( 88 | children: [ 89 | Text( 90 | 'Made with 🧡 and developed by OpenLabX', 91 | style: TextStyle( 92 | fontSize: 16, 93 | fontWeight: FontWeight.w400, 94 | ), 95 | ), 96 | Text( 97 | '© 2024 OpenLabX', 98 | style: TextStyle( 99 | fontSize: 14, 100 | fontWeight: FontWeight.w300, 101 | ), 102 | ), 103 | ], 104 | ), 105 | ), 106 | ], 107 | ), 108 | ); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /lib/presentation/screens/home/old_home_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import '../qr_generator/qr_generator_screen.dart'; 3 | import '../qr_scanner/qr_scanner_screen.dart'; 4 | import '../settings/settings_screen.dart'; 5 | 6 | class HomeScreen extends StatelessWidget { 7 | @override 8 | Widget build(BuildContext context) { 9 | return Scaffold( 10 | appBar: AppBar( 11 | title: Text('Open QR Code'), 12 | actions: [ 13 | IconButton( 14 | icon: Icon(Icons.settings), 15 | onPressed: () { 16 | Navigator.of(context).push( 17 | MaterialPageRoute(builder: (context) => SettingsScreen()), 18 | ); 19 | }, 20 | ), 21 | ], 22 | ), 23 | body: Column( 24 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 25 | children: [ 26 | Expanded( 27 | child: Center( 28 | child: Column( 29 | mainAxisAlignment: MainAxisAlignment.center, 30 | children: [ 31 | // Logo Image 32 | Image.asset( 33 | 'assets/images/logo_v1.png', 34 | height: 360, // Adjust height as needed 35 | ), 36 | SizedBox(height: 20), 37 | Text( 38 | 'Welcome to Open QR Code', 39 | style: Theme.of(context).textTheme.titleLarge, 40 | ), 41 | SizedBox(height: 40), 42 | ElevatedButton( 43 | onPressed: () { 44 | Navigator.of(context).push( 45 | MaterialPageRoute( 46 | builder: (context) => QRGeneratorScreen()), 47 | ); 48 | }, 49 | style: ElevatedButton.styleFrom( 50 | shape: RoundedRectangleBorder( 51 | borderRadius: BorderRadius.circular(8.0), 52 | ), 53 | padding: 54 | EdgeInsets.symmetric(horizontal: 60, vertical: 20), 55 | ), 56 | child: Text( 57 | 'Generate QR Code', 58 | style: TextStyle(fontSize: 18), 59 | ), 60 | ), 61 | SizedBox(height: 20), 62 | ElevatedButton( 63 | onPressed: () { 64 | Navigator.of(context).push( 65 | MaterialPageRoute( 66 | builder: (context) => QRScannerScreen()), 67 | ); 68 | }, 69 | style: ElevatedButton.styleFrom( 70 | shape: RoundedRectangleBorder( 71 | borderRadius: BorderRadius.circular(8.0), 72 | ), 73 | padding: 74 | EdgeInsets.symmetric(horizontal: 60, vertical: 20), 75 | ), 76 | child: Text( 77 | 'Scan QR Code', 78 | style: TextStyle(fontSize: 18), 79 | ), 80 | ), 81 | ], 82 | ), 83 | ), 84 | ), 85 | Padding( 86 | padding: const EdgeInsets.all(8.0), 87 | child: Column( 88 | children: [ 89 | Text( 90 | 'Made with 🧡 and developed by OpenLabX', 91 | style: TextStyle( 92 | fontSize: 16, 93 | fontWeight: FontWeight.w400, 94 | ), 95 | ), 96 | Text( 97 | '© 2024 OpenLabX', 98 | style: TextStyle( 99 | fontSize: 14, 100 | fontWeight: FontWeight.w300, 101 | ), 102 | ), 103 | ], 104 | ), 105 | ), 106 | ], 107 | ), 108 | ); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /lib/presentation/screens/qr_generator/qr_generator_screen.dart: -------------------------------------------------------------------------------- 1 | // qr_generator_screen.dart 2 | 3 | export 'qr_generator_screen_mobile.dart' 4 | if (dart.library.html) 'qr_generator_screen_web.dart'; 5 | -------------------------------------------------------------------------------- /lib/presentation/screens/qr_generator/qr_generator_screen_mobile.dart: -------------------------------------------------------------------------------- 1 | import 'dart:typed_data'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:qr_flutter/qr_flutter.dart'; 4 | import 'package:path_provider/path_provider.dart'; 5 | import 'package:share_plus/share_plus.dart'; 6 | import 'package:screenshot/screenshot.dart'; 7 | import 'dart:io' as io; 8 | 9 | class QRGeneratorScreen extends StatefulWidget { 10 | @override 11 | _QRGeneratorScreenState createState() => _QRGeneratorScreenState(); 12 | } 13 | 14 | class _QRGeneratorScreenState extends State { 15 | final TextEditingController _controller = TextEditingController(); 16 | final ScreenshotController _screenshotController = ScreenshotController(); 17 | String _inputData = ''; 18 | 19 | Future _saveQRCode() async { 20 | try { 21 | // Get the external storage directory 22 | final directory = await getExternalStorageDirectory(); 23 | 24 | // Define the path to the Pictures directory 25 | final path = '/storage/emulated/0/Pictures/QR_Codes'; 26 | 27 | // Ensure the directory exists 28 | await io.Directory(path).create(recursive: true); 29 | 30 | // Save the screenshot to the specified directory 31 | final imagePath = await _screenshotController.captureAndSave(path, 32 | fileName: 'qr_code_${DateTime.now().millisecondsSinceEpoch}.png'); 33 | 34 | ScaffoldMessenger.of(context).showSnackBar( 35 | SnackBar(content: Text('QR Code saved to $imagePath')), 36 | ); 37 | 38 | // Optionally, refresh the gallery so the image appears immediately 39 | await io.File(imagePath!).create(); 40 | } catch (e) { 41 | print('Error saving QR code: $e'); 42 | ScaffoldMessenger.of(context).showSnackBar( 43 | SnackBar(content: Text('Failed to save QR code.')), 44 | ); 45 | } 46 | } 47 | 48 | Future _shareQRCode() async { 49 | try { 50 | final directory = await getApplicationDocumentsDirectory(); 51 | final imagePath = await _screenshotController 52 | .captureAndSave(directory.path, fileName: 'qr_code.png'); 53 | if (imagePath != null) { 54 | final file = io.File(imagePath); 55 | await Share.shareXFiles([XFile(file.path)], 56 | text: 'Here is your QR code!'); 57 | } else { 58 | ScaffoldMessenger.of(context).showSnackBar( 59 | SnackBar(content: Text('Failed to capture QR code image.')), 60 | ); 61 | } 62 | } catch (e) { 63 | print('Error sharing QR code: $e'); 64 | ScaffoldMessenger.of(context).showSnackBar( 65 | SnackBar(content: Text('Failed to share QR code.')), 66 | ); 67 | } 68 | } 69 | 70 | @override 71 | Widget build(BuildContext context) { 72 | return Scaffold( 73 | appBar: AppBar( 74 | title: Text('Generate QR Code'), 75 | ), 76 | body: Padding( 77 | padding: const EdgeInsets.all(16.0), 78 | child: Column( 79 | children: [ 80 | TextField( 81 | controller: _controller, 82 | decoration: InputDecoration( 83 | labelText: 'Enter data for QR Code', 84 | border: OutlineInputBorder(), 85 | ), 86 | onChanged: (value) { 87 | setState(() { 88 | _inputData = value; 89 | }); 90 | }, 91 | ), 92 | SizedBox(height: 20), 93 | _inputData.isEmpty 94 | ? Container() 95 | : Screenshot( 96 | controller: _screenshotController, 97 | child: Container( 98 | color: Colors.white, 99 | padding: const EdgeInsets.all(20.0), 100 | child: QrImageView( 101 | data: _inputData, 102 | version: QrVersions.auto, 103 | size: 200.0, 104 | backgroundColor: Colors.white, 105 | ), 106 | ), 107 | ), 108 | SizedBox(height: 20), 109 | Row( 110 | mainAxisAlignment: MainAxisAlignment.spaceEvenly, 111 | children: [ 112 | ElevatedButton( 113 | onPressed: () { 114 | if (_inputData.isNotEmpty) { 115 | _saveQRCode(); 116 | } 117 | }, 118 | child: Text('Save'), 119 | ), 120 | ElevatedButton( 121 | onPressed: () { 122 | if (_inputData.isNotEmpty) { 123 | _shareQRCode(); 124 | } 125 | }, 126 | child: Text('Share'), 127 | ), 128 | ], 129 | ), 130 | ], 131 | ), 132 | ), 133 | ); 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /lib/presentation/screens/qr_generator/qr_generator_screen_web.dart: -------------------------------------------------------------------------------- 1 | // qr_generator_screen_web.dart 2 | 3 | import 'dart:typed_data'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:qr_flutter/qr_flutter.dart'; 6 | import 'package:screenshot/screenshot.dart'; 7 | import 'dart:html' as html; 8 | 9 | class QRGeneratorScreen extends StatefulWidget { 10 | @override 11 | _QRGeneratorScreenState createState() => _QRGeneratorScreenState(); 12 | } 13 | 14 | class _QRGeneratorScreenState extends State { 15 | final TextEditingController _controller = TextEditingController(); 16 | final ScreenshotController _screenshotController = ScreenshotController(); 17 | String _inputData = ''; 18 | 19 | Future _saveQRCode() async { 20 | Uint8List? capturedImage = await _screenshotController.capture(); 21 | if (capturedImage != null) { 22 | final blob = html.Blob([capturedImage]); 23 | final url = html.Url.createObjectUrlFromBlob(blob); 24 | final anchor = html.AnchorElement(href: url) 25 | ..setAttribute('download', 'qr_code.png') 26 | ..click(); 27 | html.Url.revokeObjectUrl(url); 28 | } else { 29 | ScaffoldMessenger.of(context).showSnackBar( 30 | SnackBar(content: Text('Failed to capture QR code image.')), 31 | ); 32 | } 33 | } 34 | 35 | Future _shareQRCode() async { 36 | Uint8List? capturedImage = await _screenshotController.capture(); 37 | if (capturedImage != null) { 38 | final blob = html.Blob([capturedImage]); 39 | final url = html.Url.createObjectUrlFromBlob(blob); 40 | final anchor = html.AnchorElement(href: url) 41 | ..setAttribute('download', 'qr_code.png') 42 | ..click(); 43 | html.Url.revokeObjectUrl(url); 44 | } else { 45 | ScaffoldMessenger.of(context).showSnackBar( 46 | SnackBar(content: Text('Failed to capture QR code image.')), 47 | ); 48 | } 49 | } 50 | 51 | @override 52 | Widget build(BuildContext context) { 53 | return Scaffold( 54 | appBar: AppBar( 55 | title: Text('Generate QR Code'), 56 | ), 57 | body: Padding( 58 | padding: const EdgeInsets.all(16.0), 59 | child: Column( 60 | children: [ 61 | TextField( 62 | controller: _controller, 63 | decoration: InputDecoration( 64 | labelText: 'Enter data for QR Code', 65 | border: OutlineInputBorder(), 66 | ), 67 | onChanged: (value) { 68 | setState(() { 69 | _inputData = value; 70 | }); 71 | }, 72 | ), 73 | SizedBox(height: 20), 74 | _inputData.isEmpty 75 | ? Container() 76 | : Screenshot( 77 | controller: _screenshotController, 78 | child: Container( 79 | color: Colors.white, 80 | padding: const EdgeInsets.all(20.0), 81 | child: QrImageView( 82 | data: _inputData, 83 | version: QrVersions.auto, 84 | size: 200.0, 85 | backgroundColor: Colors.white, 86 | ), 87 | ), 88 | ), 89 | SizedBox(height: 20), 90 | Row( 91 | mainAxisAlignment: MainAxisAlignment.spaceEvenly, 92 | children: [ 93 | ElevatedButton( 94 | onPressed: () { 95 | if (_inputData.isNotEmpty) { 96 | _saveQRCode(); 97 | } 98 | }, 99 | child: Text('Save'), 100 | ), 101 | ElevatedButton( 102 | onPressed: () { 103 | if (_inputData.isNotEmpty) { 104 | _shareQRCode(); 105 | } 106 | }, 107 | child: Text('Share'), 108 | ), 109 | ], 110 | ), 111 | ], 112 | ), 113 | ), 114 | ); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /lib/presentation/screens/qr_scanner/qr_scanner_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:qr_code_scanner/qr_code_scanner.dart'; 3 | import 'package:url_launcher/url_launcher.dart'; 4 | import 'package:share_plus/share_plus.dart'; 5 | 6 | class QRScannerScreen extends StatefulWidget { 7 | @override 8 | _QRScannerScreenState createState() => _QRScannerScreenState(); 9 | } 10 | 11 | class _QRScannerScreenState extends State 12 | with SingleTickerProviderStateMixin { 13 | final GlobalKey qrKey = GlobalKey(debugLabel: 'QR'); 14 | QRViewController? controller; 15 | String? scannedData; 16 | bool isScanning = true; 17 | late AnimationController _animationController; 18 | 19 | @override 20 | void initState() { 21 | super.initState(); 22 | _animationController = AnimationController( 23 | duration: const Duration(seconds: 2), 24 | vsync: this, 25 | )..repeat(reverse: true); 26 | } 27 | 28 | @override 29 | void dispose() { 30 | controller?.dispose(); 31 | _animationController.dispose(); 32 | super.dispose(); 33 | } 34 | 35 | void _handleScannedData(String data) async { 36 | if (!isScanning) return; 37 | setState(() { 38 | isScanning = false; 39 | }); 40 | await controller?.pauseCamera(); 41 | 42 | showModalBottomSheet( 43 | context: context, 44 | builder: (context) { 45 | return Container( 46 | padding: EdgeInsets.all(16.0), 47 | child: Column( 48 | mainAxisSize: MainAxisSize.min, 49 | children: [ 50 | Text('Scanned Data', 51 | style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)), 52 | SizedBox(height: 10), 53 | Text(data, style: TextStyle(fontSize: 16)), 54 | SizedBox(height: 20), 55 | ElevatedButton.icon( 56 | icon: Icon(Icons.open_in_browser), 57 | label: Text('Open in Browser'), 58 | onPressed: () async { 59 | _launchURL(context, data); 60 | Navigator.pop(context); 61 | await controller?.resumeCamera(); 62 | setState(() { 63 | isScanning = true; 64 | }); 65 | }, 66 | ), 67 | ElevatedButton.icon( 68 | icon: Icon(Icons.share), 69 | label: Text('Share'), 70 | onPressed: () { 71 | Share.share(data); 72 | Navigator.pop(context); 73 | setState(() { 74 | isScanning = true; 75 | }); 76 | }, 77 | ), 78 | ], 79 | ), 80 | ); 81 | }, 82 | ); 83 | } 84 | 85 | void _launchURL(BuildContext context, String url) async { 86 | if (Uri.tryParse(url)?.hasAbsolutePath ?? false) { 87 | if (await canLaunch(url)) { 88 | await launch(url); 89 | } else { 90 | _showErrorDialog(context, 'Cannot launch this URL'); 91 | } 92 | } else { 93 | _showErrorDialog(context, 'Invalid URL format'); 94 | } 95 | } 96 | 97 | void _showErrorDialog(BuildContext context, String message) { 98 | showDialog( 99 | context: context, 100 | builder: (context) => AlertDialog( 101 | title: Text('Error'), 102 | content: Text(message), 103 | actions: [ 104 | TextButton( 105 | onPressed: () => Navigator.of(context).pop(), 106 | child: Text('OK'), 107 | ), 108 | ], 109 | ), 110 | ); 111 | } 112 | 113 | @override 114 | Widget build(BuildContext context) { 115 | return Scaffold( 116 | appBar: AppBar( 117 | title: Text('Scan QR Code'), 118 | ), 119 | body: Stack( 120 | children: [ 121 | QRView( 122 | key: qrKey, 123 | onQRViewCreated: _onQRViewCreated, 124 | overlay: QrScannerOverlayShape( 125 | borderColor: Colors.red, 126 | borderRadius: 10, 127 | borderLength: 30, 128 | borderWidth: 10, 129 | cutOutSize: 300, 130 | ), 131 | ), 132 | Center( 133 | child: AnimatedBuilder( 134 | animation: _animationController, 135 | builder: (context, child) { 136 | return Transform.translate( 137 | offset: Offset(0, _animationController.value * 300 - 150), 138 | child: Container( 139 | width: 300, 140 | height: 2, 141 | color: Colors.red, 142 | ), 143 | ); 144 | }, 145 | ), 146 | ), 147 | ], 148 | ), 149 | ); 150 | } 151 | 152 | void _onQRViewCreated(QRViewController controller) { 153 | this.controller = controller; 154 | controller.scannedDataStream.listen((scanData) { 155 | if (scanData.code != null && isScanning) { 156 | _handleScannedData(scanData.code!); 157 | } 158 | }); 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /lib/services/history_service.dart: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/lib/services/history_service.dart -------------------------------------------------------------------------------- /lib/services/qr_service.dart: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/lib/services/qr_service.dart -------------------------------------------------------------------------------- /open_qr_code.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: open_qr_code 2 | description: "A new Flutter project." 3 | # The following line prevents the package from being accidentally published to 4 | # pub.dev using `flutter pub publish`. This is preferred for private packages. 5 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev 6 | 7 | # The following defines the version and build number for your application. 8 | # A version number is three numbers separated by dots, like 1.2.43 9 | # followed by an optional build number separated by a +. 10 | # Both the version and the builder number may be overridden in flutter 11 | # build by specifying --build-name and --build-number, respectively. 12 | # In Android, build-name is used as versionName while build-number used as versionCode. 13 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 14 | # In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. 15 | # Read more about iOS versioning at 16 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 17 | # In Windows, build-name is used as the major, minor, and patch parts 18 | # of the product and file versions while build-number is used as the build suffix. 19 | version: 1.0.0+1 20 | 21 | environment: 22 | sdk: ^3.5.0 23 | 24 | # Dependencies specify other packages that your package needs in order to work. 25 | # To automatically upgrade your package dependencies to the latest versions 26 | # consider running `flutter pub upgrade --major-versions`. Alternatively, 27 | # dependencies can be manually updated by changing the version numbers below to 28 | # the latest version available on pub.dev. To see which dependencies have newer 29 | # versions available, run `flutter pub outdated`. 30 | dependencies: 31 | flutter: 32 | sdk: flutter 33 | provider: ^6.0.0 34 | shared_preferences: ^2.0.13 35 | qr_flutter: ^4.1.0 36 | qr_code_scanner: ^1.0.1 # Update to the latest version 37 | camera: ^0.11.0+2 # Update to the latest version 38 | 39 | # Necessary dependencies for Save and Share Functionality 40 | path_provider: ^2.0.11 41 | share_plus: ^10.0.2 42 | screenshot: ^3.0.0 43 | url_launcher: ^6.0.20 # To open URLs in the browser 44 | package_info_plus: ^8.0.2 45 | flutter_launcher_icons: ^0.13.1 46 | firebase_core: ^2.24.2 47 | 48 | 49 | dev_dependencies: 50 | flutter_test: 51 | sdk: flutter 52 | 53 | 54 | flutter_icons: 55 | android: true 56 | ios: true 57 | image_path: "assets/images/logo_v1.png" # Replace with the correct path to your icon 58 | adaptive_icon_background: "assets/images/logo_v1.png" # Replace with the correct path 59 | adaptive_icon_foreground: "assets/images/logo_v1.png" # Replace with the correct path 60 | 61 | 62 | # The "flutter_lints" package below contains a set of recommended lints to 63 | # encourage good coding practices. The lint set provided by the package is 64 | # activated in the `analysis_options.yaml` file located at the root of your 65 | # package. See that file for information about deactivating specific lint 66 | # rules and activating additional ones. 67 | flutter_lints: ^4.0.0 68 | 69 | # For information on the generic Dart part of this file, see the 70 | # following page: https://dart.dev/tools/pub/pubspec 71 | 72 | # The following section is specific to Flutter packages. 73 | flutter: 74 | assets: 75 | - assets/images/logo_v1.png 76 | - assets/icons/ig_64px.png 77 | - assets/icons/x_64px.png 78 | - assets/icons/fb_64px.png 79 | - assets/icons/yt_64px.png 80 | - assets/icons/git_64px.png 81 | # The following line ensures that the Material Icons font is 82 | # included with your application, so that you can use the icons in 83 | # the material Icons class. 84 | uses-material-design: true 85 | 86 | # To add assets to your application, add an assets section, like this: 87 | # assets: 88 | # - images/a_dot_burr.jpeg 89 | # - images/a_dot_ham.jpeg 90 | 91 | # An image asset can refer to one or more resolution-specific "variants", see 92 | # https://flutter.dev/to/resolution-aware-images 93 | 94 | # For details regarding adding assets from package dependencies, see 95 | # https://flutter.dev/to/asset-from-package 96 | 97 | # To add custom fonts to your application, add a fonts section here, 98 | # in this "flutter" section. Each entry in this list should have a 99 | # "family" key with the font family name, and a "fonts" key with a 100 | # list giving the asset and other descriptors for the font. For 101 | # example: 102 | # fonts: 103 | # - family: Schyler 104 | # fonts: 105 | # - asset: fonts/Schyler-Regular.ttf 106 | # - asset: fonts/Schyler-Italic.ttf 107 | # style: italic 108 | # - family: Trajan Pro 109 | # fonts: 110 | # - asset: fonts/TrajanPro.ttf 111 | # - asset: fonts/TrajanPro_Bold.ttf 112 | # weight: 700 113 | # 114 | # For details regarding fonts from package dependencies, 115 | # see https://flutter.dev/to/font-from-package 116 | 117 | -------------------------------------------------------------------------------- /screenshots/android/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/android/1.jpg -------------------------------------------------------------------------------- /screenshots/android/10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/android/10.jpg -------------------------------------------------------------------------------- /screenshots/android/11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/android/11.jpg -------------------------------------------------------------------------------- /screenshots/android/12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/android/12.jpg -------------------------------------------------------------------------------- /screenshots/android/13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/android/13.jpg -------------------------------------------------------------------------------- /screenshots/android/14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/android/14.jpg -------------------------------------------------------------------------------- /screenshots/android/15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/android/15.jpg -------------------------------------------------------------------------------- /screenshots/android/17.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/android/17.jpg -------------------------------------------------------------------------------- /screenshots/android/18.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/android/18.jpg -------------------------------------------------------------------------------- /screenshots/android/19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/android/19.jpg -------------------------------------------------------------------------------- /screenshots/android/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/android/2.jpg -------------------------------------------------------------------------------- /screenshots/android/20.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/android/20.jpg -------------------------------------------------------------------------------- /screenshots/android/21.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/android/21.jpg -------------------------------------------------------------------------------- /screenshots/android/22.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/android/22.jpg -------------------------------------------------------------------------------- /screenshots/android/23.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/android/23.jpg -------------------------------------------------------------------------------- /screenshots/android/24.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/android/24.jpg -------------------------------------------------------------------------------- /screenshots/android/25.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/android/25.jpg -------------------------------------------------------------------------------- /screenshots/android/26.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/android/26.jpg -------------------------------------------------------------------------------- /screenshots/android/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/android/3.jpg -------------------------------------------------------------------------------- /screenshots/android/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/android/4.jpg -------------------------------------------------------------------------------- /screenshots/android/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/android/5.jpg -------------------------------------------------------------------------------- /screenshots/android/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/android/6.jpg -------------------------------------------------------------------------------- /screenshots/android/7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/android/7.jpg -------------------------------------------------------------------------------- /screenshots/android/8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/android/8.jpg -------------------------------------------------------------------------------- /screenshots/android/9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/android/9.jpg -------------------------------------------------------------------------------- /screenshots/android/openlabx QR Code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/android/openlabx QR Code.png -------------------------------------------------------------------------------- /screenshots/android/qr_code_1725352250881.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/android/qr_code_1725352250881.png -------------------------------------------------------------------------------- /screenshots/logo_v1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/logo_v1.png -------------------------------------------------------------------------------- /screenshots/multiview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/multiview.png -------------------------------------------------------------------------------- /screenshots/multiview2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/multiview2.png -------------------------------------------------------------------------------- /screenshots/openlabx QR Code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/openlabx QR Code.png -------------------------------------------------------------------------------- /screenshots/win/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/win/1.png -------------------------------------------------------------------------------- /screenshots/win/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/win/2.png -------------------------------------------------------------------------------- /screenshots/win/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/win/3.png -------------------------------------------------------------------------------- /screenshots/win/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/win/4.png -------------------------------------------------------------------------------- /screenshots/win/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/win/5.png -------------------------------------------------------------------------------- /screenshots/win/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/win/6.png -------------------------------------------------------------------------------- /screenshots/win/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/win/7.png -------------------------------------------------------------------------------- /screenshots/win/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/screenshots/win/8.png -------------------------------------------------------------------------------- /test/f.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/web/favicon.png -------------------------------------------------------------------------------- /web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/web/icons/Icon-192.png -------------------------------------------------------------------------------- /web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/web/icons/Icon-512.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | Open QR Code 33 | 34 | 35 | 36 | 37 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "open_qr_code", 3 | "short_name": "open_qr_code", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.14) 3 | project(open_qr_code LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "OpenQRCode") 8 | 9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 10 | # versions of CMake. 11 | cmake_policy(VERSION 3.14...3.25) 12 | 13 | # Define build configuration option. 14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 15 | if(IS_MULTICONFIG) 16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 17 | CACHE STRING "" FORCE) 18 | else() 19 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 20 | set(CMAKE_BUILD_TYPE "Debug" CACHE 21 | STRING "Flutter build mode" FORCE) 22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 23 | "Debug" "Profile" "Release") 24 | endif() 25 | endif() 26 | # Define settings for the Profile build mode. 27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 31 | 32 | # Use Unicode for all projects. 33 | add_definitions(-DUNICODE -D_UNICODE) 34 | 35 | # Compilation settings that should be applied to most targets. 36 | # 37 | # Be cautious about adding new options here, as plugins use this function by 38 | # default. In most cases, you should add new options to specific targets instead 39 | # of modifying this function. 40 | function(APPLY_STANDARD_SETTINGS TARGET) 41 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 43 | target_compile_options(${TARGET} PRIVATE /EHsc) 44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 46 | endfunction() 47 | 48 | # Flutter library and tool build rules. 49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 50 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 51 | 52 | # Application build; see runner/CMakeLists.txt. 53 | add_subdirectory("runner") 54 | 55 | 56 | # Generated plugin build rules, which manage building the plugins and adding 57 | # them to the application. 58 | include(flutter/generated_plugins.cmake) 59 | 60 | 61 | # === Installation === 62 | # Support files are copied into place next to the executable, so that it can 63 | # run in place. This is done instead of making a separate bundle (as on Linux) 64 | # so that building and running from within Visual Studio will work. 65 | set(BUILD_BUNDLE_DIR "$") 66 | # Make the "install" step default, as it's required to run. 67 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 68 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 69 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 70 | endif() 71 | 72 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 73 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 74 | 75 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 76 | COMPONENT Runtime) 77 | 78 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 79 | COMPONENT Runtime) 80 | 81 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 82 | COMPONENT Runtime) 83 | 84 | if(PLUGIN_BUNDLED_LIBRARIES) 85 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 86 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 87 | COMPONENT Runtime) 88 | endif() 89 | 90 | # Copy the native assets provided by the build.dart from all packages. 91 | set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") 92 | install(DIRECTORY "${NATIVE_ASSETS_DIR}" 93 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 94 | COMPONENT Runtime) 95 | 96 | # Fully re-copy the assets directory on each build to avoid having stale files 97 | # from a previous install. 98 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 99 | install(CODE " 100 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 101 | " COMPONENT Runtime) 102 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 103 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 104 | 105 | # Install the AOT library on non-Debug builds only. 106 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 107 | CONFIGURATIONS Profile;Release 108 | COMPONENT Runtime) 109 | -------------------------------------------------------------------------------- /windows/f.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.14) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 12 | 13 | # Set fallback configurations for older versions of the flutter tool. 14 | if (NOT DEFINED FLUTTER_TARGET_PLATFORM) 15 | set(FLUTTER_TARGET_PLATFORM "windows-x64") 16 | endif() 17 | 18 | # === Flutter Library === 19 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 20 | 21 | # Published to parent scope for install step. 22 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 23 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 24 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 25 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 26 | 27 | list(APPEND FLUTTER_LIBRARY_HEADERS 28 | "flutter_export.h" 29 | "flutter_windows.h" 30 | "flutter_messenger.h" 31 | "flutter_plugin_registrar.h" 32 | "flutter_texture_registrar.h" 33 | ) 34 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 35 | add_library(flutter INTERFACE) 36 | target_include_directories(flutter INTERFACE 37 | "${EPHEMERAL_DIR}" 38 | ) 39 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 40 | add_dependencies(flutter flutter_assemble) 41 | 42 | # === Wrapper === 43 | list(APPEND CPP_WRAPPER_SOURCES_CORE 44 | "core_implementations.cc" 45 | "standard_codec.cc" 46 | ) 47 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 48 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 49 | "plugin_registrar.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 52 | list(APPEND CPP_WRAPPER_SOURCES_APP 53 | "flutter_engine.cc" 54 | "flutter_view_controller.cc" 55 | ) 56 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 57 | 58 | # Wrapper sources needed for a plugin. 59 | add_library(flutter_wrapper_plugin STATIC 60 | ${CPP_WRAPPER_SOURCES_CORE} 61 | ${CPP_WRAPPER_SOURCES_PLUGIN} 62 | ) 63 | apply_standard_settings(flutter_wrapper_plugin) 64 | set_target_properties(flutter_wrapper_plugin PROPERTIES 65 | POSITION_INDEPENDENT_CODE ON) 66 | set_target_properties(flutter_wrapper_plugin PROPERTIES 67 | CXX_VISIBILITY_PRESET hidden) 68 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 69 | target_include_directories(flutter_wrapper_plugin PUBLIC 70 | "${WRAPPER_ROOT}/include" 71 | ) 72 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 73 | 74 | # Wrapper sources needed for the runner. 75 | add_library(flutter_wrapper_app STATIC 76 | ${CPP_WRAPPER_SOURCES_CORE} 77 | ${CPP_WRAPPER_SOURCES_APP} 78 | ) 79 | apply_standard_settings(flutter_wrapper_app) 80 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 81 | target_include_directories(flutter_wrapper_app PUBLIC 82 | "${WRAPPER_ROOT}/include" 83 | ) 84 | add_dependencies(flutter_wrapper_app flutter_assemble) 85 | 86 | # === Flutter tool backend === 87 | # _phony_ is a non-existent file to force this command to run every time, 88 | # since currently there's no way to get a full input/output list from the 89 | # flutter tool. 90 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 91 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 92 | add_custom_command( 93 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 94 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 95 | ${CPP_WRAPPER_SOURCES_APP} 96 | ${PHONY_OUTPUT} 97 | COMMAND ${CMAKE_COMMAND} -E env 98 | ${FLUTTER_TOOL_ENVIRONMENT} 99 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 100 | ${FLUTTER_TARGET_PLATFORM} $ 101 | VERBATIM 102 | ) 103 | add_custom_target(flutter_assemble DEPENDS 104 | "${FLUTTER_LIBRARY}" 105 | ${FLUTTER_LIBRARY_HEADERS} 106 | ${CPP_WRAPPER_SOURCES_CORE} 107 | ${CPP_WRAPPER_SOURCES_PLUGIN} 108 | ${CPP_WRAPPER_SOURCES_APP} 109 | ) 110 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/binary_messenger_impl.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_BINARY_MESSENGER_IMPL_H_ 6 | #define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_BINARY_MESSENGER_IMPL_H_ 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | #include "include/flutter/binary_messenger.h" 14 | 15 | namespace flutter { 16 | 17 | // Wrapper around a FlutterDesktopMessengerRef that implements the 18 | // BinaryMessenger API. 19 | class BinaryMessengerImpl : public BinaryMessenger { 20 | public: 21 | explicit BinaryMessengerImpl(FlutterDesktopMessengerRef core_messenger); 22 | 23 | virtual ~BinaryMessengerImpl(); 24 | 25 | // Prevent copying. 26 | BinaryMessengerImpl(BinaryMessengerImpl const&) = delete; 27 | BinaryMessengerImpl& operator=(BinaryMessengerImpl const&) = delete; 28 | 29 | // |flutter::BinaryMessenger| 30 | void Send(const std::string& channel, 31 | const uint8_t* message, 32 | size_t message_size, 33 | BinaryReply reply) const override; 34 | 35 | // |flutter::BinaryMessenger| 36 | void SetMessageHandler(const std::string& channel, 37 | BinaryMessageHandler handler) override; 38 | 39 | private: 40 | // Handle for interacting with the C API. 41 | FlutterDesktopMessengerRef messenger_; 42 | 43 | // A map from channel names to the BinaryMessageHandler that should be called 44 | // for incoming messages on that channel. 45 | std::map handlers_; 46 | }; 47 | 48 | } // namespace flutter 49 | 50 | #endif // FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_BINARY_MESSENGER_IMPL_H_ 51 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/byte_buffer_streams.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_BYTE_BUFFER_STREAMS_H_ 6 | #define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_BYTE_BUFFER_STREAMS_H_ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "include/flutter/byte_streams.h" 15 | 16 | namespace flutter { 17 | 18 | // Implementation of ByteStreamReader base on a byte array. 19 | class ByteBufferStreamReader : public ByteStreamReader { 20 | public: 21 | // Createa a reader reading from |bytes|, which must have a length of |size|. 22 | // |bytes| must remain valid for the lifetime of this object. 23 | explicit ByteBufferStreamReader(const uint8_t* bytes, size_t size) 24 | : bytes_(bytes), size_(size) {} 25 | 26 | virtual ~ByteBufferStreamReader() = default; 27 | 28 | // |ByteStreamReader| 29 | uint8_t ReadByte() override { 30 | if (location_ >= size_) { 31 | std::cerr << "Invalid read in StandardCodecByteStreamReader" << std::endl; 32 | return 0; 33 | } 34 | return bytes_[location_++]; 35 | } 36 | 37 | // |ByteStreamReader| 38 | void ReadBytes(uint8_t* buffer, size_t length) override { 39 | if (location_ + length > size_) { 40 | std::cerr << "Invalid read in StandardCodecByteStreamReader" << std::endl; 41 | return; 42 | } 43 | std::memcpy(buffer, &bytes_[location_], length); 44 | location_ += length; 45 | } 46 | 47 | // |ByteStreamReader| 48 | void ReadAlignment(uint8_t alignment) override { 49 | uint8_t mod = location_ % alignment; 50 | if (mod) { 51 | location_ += alignment - mod; 52 | } 53 | } 54 | 55 | private: 56 | // The buffer to read from. 57 | const uint8_t* bytes_; 58 | // The total size of the buffer. 59 | size_t size_; 60 | // The current read location. 61 | size_t location_ = 0; 62 | }; 63 | 64 | // Implementation of ByteStreamWriter based on a byte array. 65 | class ByteBufferStreamWriter : public ByteStreamWriter { 66 | public: 67 | // Creates a writer that writes into |buffer|. 68 | // |buffer| must remain valid for the lifetime of this object. 69 | explicit ByteBufferStreamWriter(std::vector* buffer) 70 | : bytes_(buffer) { 71 | assert(buffer); 72 | } 73 | 74 | virtual ~ByteBufferStreamWriter() = default; 75 | 76 | // |ByteStreamWriter| 77 | void WriteByte(uint8_t byte) { bytes_->push_back(byte); } 78 | 79 | // |ByteStreamWriter| 80 | void WriteBytes(const uint8_t* bytes, size_t length) { 81 | assert(length > 0); 82 | bytes_->insert(bytes_->end(), bytes, bytes + length); 83 | } 84 | 85 | // |ByteStreamWriter| 86 | void WriteAlignment(uint8_t alignment) { 87 | uint8_t mod = bytes_->size() % alignment; 88 | if (mod) { 89 | for (int i = 0; i < alignment - mod; ++i) { 90 | WriteByte(0); 91 | } 92 | } 93 | } 94 | 95 | private: 96 | // The buffer to write to. 97 | std::vector* bytes_; 98 | }; 99 | 100 | } // namespace flutter 101 | 102 | #endif // FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_BYTE_BUFFER_STREAMS_H_ 103 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/engine_method_result.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | // This file is deprecated in favor of core_implementations.cc. This is a 6 | // temporary forwarding implementation so that the switch to 7 | // core_implementations.cc isn't an immediate breaking change, allowing for the 8 | // template to be updated to include it and update the template version before 9 | // removing this file. 10 | 11 | #include "core_implementations.cc" 12 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/flutter_engine.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "include/flutter/flutter_engine.h" 6 | 7 | #include 8 | #include 9 | 10 | #include "binary_messenger_impl.h" 11 | 12 | namespace flutter { 13 | 14 | FlutterEngine::FlutterEngine(const DartProject& project) { 15 | FlutterDesktopEngineProperties c_engine_properties = {}; 16 | c_engine_properties.assets_path = project.assets_path().c_str(); 17 | c_engine_properties.icu_data_path = project.icu_data_path().c_str(); 18 | c_engine_properties.aot_library_path = project.aot_library_path().c_str(); 19 | c_engine_properties.dart_entrypoint = project.dart_entrypoint().c_str(); 20 | 21 | const std::vector& entrypoint_args = 22 | project.dart_entrypoint_arguments(); 23 | std::vector entrypoint_argv; 24 | std::transform( 25 | entrypoint_args.begin(), entrypoint_args.end(), 26 | std::back_inserter(entrypoint_argv), 27 | [](const std::string& arg) -> const char* { return arg.c_str(); }); 28 | 29 | c_engine_properties.dart_entrypoint_argc = 30 | static_cast(entrypoint_argv.size()); 31 | c_engine_properties.dart_entrypoint_argv = 32 | entrypoint_argv.empty() ? nullptr : entrypoint_argv.data(); 33 | 34 | engine_ = FlutterDesktopEngineCreate(&c_engine_properties); 35 | 36 | auto core_messenger = FlutterDesktopEngineGetMessenger(engine_); 37 | messenger_ = std::make_unique(core_messenger); 38 | } 39 | 40 | FlutterEngine::~FlutterEngine() { 41 | ShutDown(); 42 | } 43 | 44 | bool FlutterEngine::Run() { 45 | return Run(nullptr); 46 | } 47 | 48 | bool FlutterEngine::Run(const char* entry_point) { 49 | if (!engine_) { 50 | std::cerr << "Cannot run an engine that failed creation." << std::endl; 51 | return false; 52 | } 53 | if (run_succeeded_) { 54 | std::cerr << "Cannot run an engine more than once." << std::endl; 55 | return false; 56 | } 57 | bool run_succeeded = FlutterDesktopEngineRun(engine_, entry_point); 58 | if (!run_succeeded) { 59 | std::cerr << "Failed to start engine." << std::endl; 60 | } 61 | run_succeeded_ = true; 62 | return run_succeeded; 63 | } 64 | 65 | void FlutterEngine::ShutDown() { 66 | if (engine_ && owns_engine_) { 67 | FlutterDesktopEngineDestroy(engine_); 68 | } 69 | engine_ = nullptr; 70 | } 71 | 72 | std::chrono::nanoseconds FlutterEngine::ProcessMessages() { 73 | return std::chrono::nanoseconds(FlutterDesktopEngineProcessMessages(engine_)); 74 | } 75 | 76 | void FlutterEngine::ReloadSystemFonts() { 77 | FlutterDesktopEngineReloadSystemFonts(engine_); 78 | } 79 | 80 | FlutterDesktopPluginRegistrarRef FlutterEngine::GetRegistrarForPlugin( 81 | const std::string& plugin_name) { 82 | if (!engine_) { 83 | std::cerr << "Cannot get plugin registrar on an engine that isn't running; " 84 | "call Run first." 85 | << std::endl; 86 | return nullptr; 87 | } 88 | return FlutterDesktopEngineGetPluginRegistrar(engine_, plugin_name.c_str()); 89 | } 90 | 91 | void FlutterEngine::SetNextFrameCallback(std::function callback) { 92 | next_frame_callback_ = std::move(callback); 93 | FlutterDesktopEngineSetNextFrameCallback( 94 | engine_, 95 | [](void* user_data) { 96 | FlutterEngine* self = static_cast(user_data); 97 | self->next_frame_callback_(); 98 | self->next_frame_callback_ = nullptr; 99 | }, 100 | this); 101 | } 102 | 103 | std::optional FlutterEngine::ProcessExternalWindowMessage( 104 | HWND hwnd, 105 | UINT message, 106 | WPARAM wparam, 107 | LPARAM lparam) { 108 | LRESULT result; 109 | if (FlutterDesktopEngineProcessExternalWindowMessage( 110 | engine_, hwnd, message, wparam, lparam, &result)) { 111 | return result; 112 | } 113 | return std::nullopt; 114 | } 115 | 116 | FlutterDesktopEngineRef FlutterEngine::RelinquishEngine() { 117 | owns_engine_ = false; 118 | return engine_; 119 | } 120 | 121 | } // namespace flutter 122 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/flutter_view_controller.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "include/flutter/flutter_view_controller.h" 6 | 7 | #include 8 | #include 9 | 10 | namespace flutter { 11 | 12 | FlutterViewController::FlutterViewController(int width, 13 | int height, 14 | const DartProject& project) { 15 | engine_ = std::make_shared(project); 16 | controller_ = FlutterDesktopViewControllerCreate(width, height, 17 | engine_->RelinquishEngine()); 18 | if (!controller_) { 19 | std::cerr << "Failed to create view controller." << std::endl; 20 | return; 21 | } 22 | view_ = std::make_unique( 23 | FlutterDesktopViewControllerGetView(controller_)); 24 | } 25 | 26 | FlutterViewController::~FlutterViewController() { 27 | if (controller_) { 28 | FlutterDesktopViewControllerDestroy(controller_); 29 | } 30 | } 31 | 32 | FlutterViewId FlutterViewController::view_id() const { 33 | auto view_id = FlutterDesktopViewControllerGetViewId(controller_); 34 | 35 | return static_cast(view_id); 36 | } 37 | 38 | void FlutterViewController::ForceRedraw() { 39 | FlutterDesktopViewControllerForceRedraw(controller_); 40 | } 41 | 42 | std::optional FlutterViewController::HandleTopLevelWindowProc( 43 | HWND hwnd, 44 | UINT message, 45 | WPARAM wparam, 46 | LPARAM lparam) { 47 | LRESULT result; 48 | bool handled = FlutterDesktopViewControllerHandleTopLevelWindowProc( 49 | controller_, hwnd, message, wparam, lparam, &result); 50 | return handled ? result : std::optional(std::nullopt); 51 | } 52 | 53 | } // namespace flutter 54 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/include/flutter/binary_messenger.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_BINARY_MESSENGER_H_ 6 | #define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_BINARY_MESSENGER_H_ 7 | 8 | #include 9 | #include 10 | 11 | namespace flutter { 12 | 13 | // A binary message reply callback. 14 | // 15 | // Used for submitting a binary reply back to a Flutter message sender. 16 | typedef std::function 17 | BinaryReply; 18 | 19 | // A message handler callback. 20 | // 21 | // Used for receiving messages from Flutter and providing an asynchronous reply. 22 | typedef std::function< 23 | void(const uint8_t* message, size_t message_size, BinaryReply reply)> 24 | BinaryMessageHandler; 25 | 26 | // A protocol for a class that handles communication of binary data on named 27 | // channels to and from the Flutter engine. 28 | class BinaryMessenger { 29 | public: 30 | virtual ~BinaryMessenger() = default; 31 | 32 | // Sends a binary message to the Flutter engine on the specified channel. 33 | // 34 | // If |reply| is provided, it will be called back with the response from the 35 | // engine. 36 | virtual void Send(const std::string& channel, 37 | const uint8_t* message, 38 | size_t message_size, 39 | BinaryReply reply = nullptr) const = 0; 40 | 41 | // Registers a message handler for incoming binary messages from the Flutter 42 | // side on the specified channel. 43 | // 44 | // Replaces any existing handler. Provide a null handler to unregister the 45 | // existing handler. 46 | virtual void SetMessageHandler(const std::string& channel, 47 | BinaryMessageHandler handler) = 0; 48 | }; 49 | 50 | } // namespace flutter 51 | 52 | #endif // FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_BINARY_MESSENGER_H_ 53 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/include/flutter/byte_streams.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_BYTE_STREAMS_H_ 6 | #define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_BYTE_STREAMS_H_ 7 | 8 | // Interfaces for interacting with a stream of bytes, for use in codecs. 9 | 10 | namespace flutter { 11 | 12 | // An interface for a class that reads from a byte stream. 13 | class ByteStreamReader { 14 | public: 15 | explicit ByteStreamReader() = default; 16 | virtual ~ByteStreamReader() = default; 17 | 18 | // Reads and returns the next byte from the stream. 19 | virtual uint8_t ReadByte() = 0; 20 | 21 | // Reads the next |length| bytes from the stream into |buffer|. The caller 22 | // is responsible for ensuring that |buffer| is large enough. 23 | virtual void ReadBytes(uint8_t* buffer, size_t length) = 0; 24 | 25 | // Advances the read cursor to the next multiple of |alignment| relative to 26 | // the start of the stream, unless it is already aligned. 27 | virtual void ReadAlignment(uint8_t alignment) = 0; 28 | 29 | // Reads and returns the next 32-bit integer from the stream. 30 | int32_t ReadInt32() { 31 | int32_t value = 0; 32 | ReadBytes(reinterpret_cast(&value), 4); 33 | return value; 34 | } 35 | 36 | // Reads and returns the next 64-bit integer from the stream. 37 | int64_t ReadInt64() { 38 | int64_t value = 0; 39 | ReadBytes(reinterpret_cast(&value), 8); 40 | return value; 41 | } 42 | 43 | // Reads and returns the next 64-bit floating point number from the stream. 44 | double ReadDouble() { 45 | double value = 0; 46 | ReadBytes(reinterpret_cast(&value), 8); 47 | return value; 48 | } 49 | }; 50 | 51 | // An interface for a class that writes to a byte stream. 52 | class ByteStreamWriter { 53 | public: 54 | explicit ByteStreamWriter() = default; 55 | virtual ~ByteStreamWriter() = default; 56 | 57 | // Writes |byte| to the stream. 58 | virtual void WriteByte(uint8_t byte) = 0; 59 | 60 | // Writes the next |length| bytes from |bytes| to the stream 61 | virtual void WriteBytes(const uint8_t* bytes, size_t length) = 0; 62 | 63 | // Writes 0s until the next multiple of |alignment| relative to the start 64 | // of the stream, unless the write positition is already aligned. 65 | virtual void WriteAlignment(uint8_t alignment) = 0; 66 | 67 | // Writes the given 32-bit int to the stream. 68 | void WriteInt32(int32_t value) { 69 | WriteBytes(reinterpret_cast(&value), 4); 70 | } 71 | 72 | // Writes the given 64-bit int to the stream. 73 | void WriteInt64(int64_t value) { 74 | WriteBytes(reinterpret_cast(&value), 8); 75 | } 76 | 77 | // Writes the given 36-bit double to the stream. 78 | void WriteDouble(double value) { 79 | WriteBytes(reinterpret_cast(&value), 8); 80 | } 81 | }; 82 | 83 | } // namespace flutter 84 | 85 | #endif // FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_BYTE_STREAMS_H_ 86 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/include/flutter/dart_project.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_CLIENT_WRAPPER_INCLUDE_FLUTTER_DART_PROJECT_H_ 6 | #define FLUTTER_SHELL_PLATFORM_WINDOWS_CLIENT_WRAPPER_INCLUDE_FLUTTER_DART_PROJECT_H_ 7 | 8 | #include 9 | #include 10 | 11 | namespace flutter { 12 | 13 | // A set of Flutter and Dart assets used to initialize a Flutter engine. 14 | class DartProject { 15 | public: 16 | // Creates a DartProject from a series of absolute paths. 17 | // The three paths are: 18 | // - assets_path: Path to the assets directory as built by the Flutter tool. 19 | // - icu_data_path: Path to the icudtl.dat file. 20 | // - aot_library_path: Path to the AOT snapshot file. 21 | // 22 | // The paths may either be absolute or relative to the directory containing 23 | // the running executable. 24 | explicit DartProject(const std::wstring& assets_path, 25 | const std::wstring& icu_data_path, 26 | const std::wstring& aot_library_path) { 27 | assets_path_ = assets_path; 28 | icu_data_path_ = icu_data_path; 29 | aot_library_path_ = aot_library_path; 30 | } 31 | 32 | // Creates a DartProject from a directory path. The directory should contain 33 | // the following top-level items: 34 | // - icudtl.dat (provided as a resource by the Flutter tool) 35 | // - flutter_assets (as built by the Flutter tool) 36 | // - app.so, for an AOT build (as built by the Flutter tool) 37 | // 38 | // The path can either be absolute, or relative to the directory containing 39 | // the running executable. 40 | explicit DartProject(const std::wstring& path) { 41 | assets_path_ = path + L"\\flutter_assets"; 42 | icu_data_path_ = path + L"\\icudtl.dat"; 43 | aot_library_path_ = path + L"\\app.so"; 44 | } 45 | 46 | ~DartProject() = default; 47 | 48 | // Sets the Dart entrypoint to the specified value. 49 | // 50 | // If not set, the default entrypoint (main) is used. Custom Dart entrypoints 51 | // must be decorated with `@pragma('vm:entry-point')`. 52 | void set_dart_entrypoint(const std::string& entrypoint) { 53 | if (entrypoint.empty()) { 54 | return; 55 | } 56 | dart_entrypoint_ = entrypoint; 57 | } 58 | 59 | // Returns the Dart entrypoint. 60 | const std::string& dart_entrypoint() const { return dart_entrypoint_; } 61 | 62 | // Sets the command line arguments that should be passed to the Dart 63 | // entrypoint. 64 | void set_dart_entrypoint_arguments(std::vector arguments) { 65 | dart_entrypoint_arguments_ = std::move(arguments); 66 | } 67 | 68 | // Returns any command line arguments that should be passed to the Dart 69 | // entrypoint. 70 | const std::vector& dart_entrypoint_arguments() const { 71 | return dart_entrypoint_arguments_; 72 | } 73 | 74 | private: 75 | // Accessors for internals are private, so that they can be changed if more 76 | // flexible options for project structures are needed later without it 77 | // being a breaking change. Provide access to internal classes that need 78 | // them. 79 | friend class FlutterEngine; 80 | friend class FlutterViewController; 81 | friend class DartProjectTest; 82 | 83 | const std::wstring& assets_path() const { return assets_path_; } 84 | const std::wstring& icu_data_path() const { return icu_data_path_; } 85 | const std::wstring& aot_library_path() const { return aot_library_path_; } 86 | 87 | // The path to the assets directory. 88 | std::wstring assets_path_; 89 | // The path to the ICU data. 90 | std::wstring icu_data_path_; 91 | // The path to the AOT library. This will always return a path, but non-AOT 92 | // builds will not be expected to actually have a library at that path. 93 | std::wstring aot_library_path_; 94 | // The Dart entrypoint to launch. 95 | std::string dart_entrypoint_; 96 | // The list of arguments to pass through to the Dart entrypoint. 97 | std::vector dart_entrypoint_arguments_; 98 | }; 99 | 100 | } // namespace flutter 101 | 102 | #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_CLIENT_WRAPPER_INCLUDE_FLUTTER_DART_PROJECT_H_ 103 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/include/flutter/engine_method_result.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_ENGINE_METHOD_RESULT_H_ 6 | #define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_ENGINE_METHOD_RESULT_H_ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include "binary_messenger.h" 13 | #include "method_codec.h" 14 | #include "method_result.h" 15 | 16 | namespace flutter { 17 | 18 | namespace internal { 19 | // Manages the one-time sending of response data. This is an internal helper 20 | // class for EngineMethodResult, separated out since the implementation doesn't 21 | // vary based on the template type. 22 | class ReplyManager { 23 | public: 24 | explicit ReplyManager(BinaryReply reply_handler_); 25 | ~ReplyManager(); 26 | 27 | // Prevent copying. 28 | ReplyManager(ReplyManager const&) = delete; 29 | ReplyManager& operator=(ReplyManager const&) = delete; 30 | 31 | // Sends the given response data (which must either be nullptr, which 32 | // indicates an unhandled method, or a response serialized with |codec_|) to 33 | // the engine. 34 | void SendResponseData(const std::vector* data); 35 | 36 | private: 37 | BinaryReply reply_handler_; 38 | }; 39 | } // namespace internal 40 | 41 | // Implemention of MethodResult that sends a response to the Flutter engine 42 | // exactly once, encoded using a given codec. 43 | template 44 | class EngineMethodResult : public MethodResult { 45 | public: 46 | // Creates a result object that will send results to |reply_handler|, encoded 47 | // using |codec|. The |codec| pointer must remain valid for as long as this 48 | // object exists. 49 | EngineMethodResult(BinaryReply reply_handler, const MethodCodec* codec) 50 | : reply_manager_( 51 | std::make_unique(std::move(reply_handler))), 52 | codec_(codec) {} 53 | 54 | ~EngineMethodResult() = default; 55 | 56 | protected: 57 | // |flutter::MethodResult| 58 | void SuccessInternal(const T* result) override { 59 | std::unique_ptr> data = 60 | codec_->EncodeSuccessEnvelope(result); 61 | reply_manager_->SendResponseData(data.get()); 62 | } 63 | 64 | // |flutter::MethodResult| 65 | void ErrorInternal(const std::string& error_code, 66 | const std::string& error_message, 67 | const T* error_details) override { 68 | std::unique_ptr> data = 69 | codec_->EncodeErrorEnvelope(error_code, error_message, error_details); 70 | reply_manager_->SendResponseData(data.get()); 71 | } 72 | 73 | // |flutter::MethodResult| 74 | void NotImplementedInternal() override { 75 | reply_manager_->SendResponseData(nullptr); 76 | } 77 | 78 | private: 79 | std::unique_ptr reply_manager_; 80 | 81 | const MethodCodec* codec_; 82 | }; 83 | 84 | } // namespace flutter 85 | 86 | #endif // FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_ENGINE_METHOD_RESULT_H_ 87 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/include/flutter/event_sink.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_EVENT_SINK_H_ 6 | #define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_EVENT_SINK_H_ 7 | 8 | namespace flutter { 9 | 10 | class EncodableValue; 11 | 12 | // Event callback. Events to be sent to Flutter application 13 | // act as clients of this interface for sending events. 14 | template 15 | class EventSink { 16 | public: 17 | EventSink() = default; 18 | virtual ~EventSink() = default; 19 | 20 | // Prevent copying. 21 | EventSink(EventSink const&) = delete; 22 | EventSink& operator=(EventSink const&) = delete; 23 | 24 | // Consumes a successful event 25 | void Success(const T& event) { SuccessInternal(&event); } 26 | 27 | // Consumes a successful event. 28 | void Success() { SuccessInternal(nullptr); } 29 | 30 | // Consumes an error event. 31 | void Error(const std::string& error_code, 32 | const std::string& error_message, 33 | const T& error_details) { 34 | ErrorInternal(error_code, error_message, &error_details); 35 | } 36 | 37 | // Consumes an error event. 38 | void Error(const std::string& error_code, 39 | const std::string& error_message = "") { 40 | ErrorInternal(error_code, error_message, nullptr); 41 | } 42 | 43 | // Consumes end of stream. Ensuing calls to Success() or 44 | // Error(), if any, are ignored. 45 | void EndOfStream() { EndOfStreamInternal(); } 46 | 47 | protected: 48 | // Implementation of the public interface, to be provided by subclasses. 49 | virtual void SuccessInternal(const T* event = nullptr) = 0; 50 | 51 | // Implementation of the public interface, to be provided by subclasses. 52 | virtual void ErrorInternal(const std::string& error_code, 53 | const std::string& error_message, 54 | const T* error_details) = 0; 55 | 56 | // Implementation of the public interface, to be provided by subclasses. 57 | virtual void EndOfStreamInternal() = 0; 58 | }; 59 | 60 | } // namespace flutter 61 | 62 | #endif // FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_EVENT_SINK_H_ 63 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/include/flutter/event_stream_handler.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_EVENT_STREAM_HANDLER_H_ 6 | #define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_EVENT_STREAM_HANDLER_H_ 7 | 8 | #include 9 | #include 10 | 11 | #include "event_sink.h" 12 | 13 | namespace flutter { 14 | 15 | class EncodableValue; 16 | 17 | template 18 | struct StreamHandlerError { 19 | const std::string error_code; 20 | const std::string error_message; 21 | const std::unique_ptr error_details; 22 | 23 | StreamHandlerError(const std::string& error_code, 24 | const std::string& error_message, 25 | std::unique_ptr&& error_details) 26 | : error_code(error_code), 27 | error_message(error_message), 28 | error_details(std::move(error_details)) {} 29 | }; 30 | 31 | // Handler for stream setup and teardown requests. 32 | // Implementations must be prepared to accept sequences of alternating calls to 33 | // OnListen() and OnCancel(). Implementations should ideally consume no 34 | // resources when the last such call is not OnListen(). In typical situations, 35 | // this means that the implementation should register itself with 36 | // platform-specific event sources OnListen() and deregister again OnCancel(). 37 | template 38 | class StreamHandler { 39 | public: 40 | StreamHandler() = default; 41 | virtual ~StreamHandler() = default; 42 | 43 | // Prevent copying. 44 | StreamHandler(StreamHandler const&) = delete; 45 | StreamHandler& operator=(StreamHandler const&) = delete; 46 | 47 | // Handles a request to set up an event stream. Returns nullptr on success, 48 | // or an error on failure. 49 | // |arguments| is stream configuration arguments and 50 | // |events| is an EventSink for emitting events to the Flutter receiver. 51 | std::unique_ptr> OnListen( 52 | const T* arguments, 53 | std::unique_ptr>&& events) { 54 | return OnListenInternal(arguments, std::move(events)); 55 | } 56 | 57 | // Handles a request to tear down the most recently created event stream. 58 | // Returns nullptr on success, or an error on failure. 59 | // |arguments| is stream configuration arguments. 60 | std::unique_ptr> OnCancel(const T* arguments) { 61 | return OnCancelInternal(arguments); 62 | } 63 | 64 | protected: 65 | // Implementation of the public interface, to be provided by subclasses. 66 | virtual std::unique_ptr> OnListenInternal( 67 | const T* arguments, 68 | std::unique_ptr>&& events) = 0; 69 | 70 | // Implementation of the public interface, to be provided by subclasses. 71 | virtual std::unique_ptr> OnCancelInternal( 72 | const T* arguments) = 0; 73 | }; 74 | 75 | } // namespace flutter 76 | 77 | #endif // FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_EVENT_STREAM_HANDLER_H_ 78 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/include/flutter/event_stream_handler_functions.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_EVENT_STREAM_HANDLER_FUNCTIONS_H_ 6 | #define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_EVENT_STREAM_HANDLER_FUNCTIONS_H_ 7 | 8 | #include 9 | 10 | #include "event_sink.h" 11 | #include "event_stream_handler.h" 12 | 13 | namespace flutter { 14 | 15 | class EncodableValue; 16 | 17 | // Handler types for each of the StreamHandler setup and teardown 18 | // requests. 19 | template 20 | using StreamHandlerListen = 21 | std::function>( 22 | const T* arguments, 23 | std::unique_ptr>&& events)>; 24 | 25 | template 26 | using StreamHandlerCancel = 27 | std::function>(const T* arguments)>; 28 | 29 | // An implementation of StreamHandler that pass calls through to 30 | // provided function objects. 31 | template 32 | class StreamHandlerFunctions : public StreamHandler { 33 | public: 34 | // Creates a handler object that calls the provided functions 35 | // for the corresponding StreamHandler outcomes. 36 | StreamHandlerFunctions(StreamHandlerListen on_listen, 37 | StreamHandlerCancel on_cancel) 38 | : on_listen_(on_listen), on_cancel_(on_cancel) {} 39 | 40 | virtual ~StreamHandlerFunctions() = default; 41 | 42 | // Prevent copying. 43 | StreamHandlerFunctions(StreamHandlerFunctions const&) = delete; 44 | StreamHandlerFunctions& operator=(StreamHandlerFunctions const&) = delete; 45 | 46 | protected: 47 | // |flutter::StreamHandler| 48 | std::unique_ptr> OnListenInternal( 49 | const T* arguments, 50 | std::unique_ptr>&& events) override { 51 | if (on_listen_) { 52 | return on_listen_(arguments, std::move(events)); 53 | } 54 | 55 | auto error = std::make_unique>( 56 | "error", "No OnListen handler set", nullptr); 57 | return std::move(error); 58 | } 59 | 60 | // |flutter::StreamHandler| 61 | std::unique_ptr> OnCancelInternal( 62 | const T* arguments) override { 63 | if (on_cancel_) { 64 | return on_cancel_(arguments); 65 | } 66 | 67 | auto error = std::make_unique>( 68 | "error", "No OnCancel handler set", nullptr); 69 | return std::move(error); 70 | } 71 | 72 | StreamHandlerListen on_listen_; 73 | StreamHandlerCancel on_cancel_; 74 | }; 75 | 76 | } // namespace flutter 77 | 78 | #endif // FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_EVENT_STREAM_HANDLER_FUNCTIONS_H_ 79 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/include/flutter/flutter_engine.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_CLIENT_WRAPPER_INCLUDE_FLUTTER_FLUTTER_ENGINE_H_ 6 | #define FLUTTER_SHELL_PLATFORM_WINDOWS_CLIENT_WRAPPER_INCLUDE_FLUTTER_FLUTTER_ENGINE_H_ 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "binary_messenger.h" 16 | #include "dart_project.h" 17 | #include "plugin_registrar.h" 18 | #include "plugin_registry.h" 19 | 20 | namespace flutter { 21 | 22 | // An instance of a Flutter engine. 23 | // 24 | // In the future, this will be the API surface used for all interactions with 25 | // the engine, rather than having them duplicated on FlutterViewController. 26 | // For now it is only used in the rare case where you need a headless Flutter 27 | // engine. 28 | class FlutterEngine : public PluginRegistry { 29 | public: 30 | // Creates a new engine for running the given project. 31 | explicit FlutterEngine(const DartProject& project); 32 | 33 | virtual ~FlutterEngine(); 34 | 35 | // Prevent copying. 36 | FlutterEngine(FlutterEngine const&) = delete; 37 | FlutterEngine& operator=(FlutterEngine const&) = delete; 38 | 39 | // Starts running the engine at the entrypoint function specified in the 40 | // DartProject used to configure the engine, or main() by default. 41 | bool Run(); 42 | 43 | // Starts running the engine, with an optional entry point. 44 | // 45 | // If provided, entry_point must be the name of a top-level function from the 46 | // same Dart library that contains the app's main() function, and must be 47 | // decorated with `@pragma(vm:entry-point)` to ensure the method is not 48 | // tree-shaken by the Dart compiler. If not provided, defaults to main(). 49 | bool Run(const char* entry_point); 50 | 51 | // Terminates the running engine. 52 | void ShutDown(); 53 | 54 | // Processes any pending events in the Flutter engine, and returns the 55 | // nanosecond delay until the next scheduled event (or max, if none). 56 | // 57 | // This should be called on every run of the application-level runloop, and 58 | // a wait for native events in the runloop should never be longer than the 59 | // last return value from this function. 60 | std::chrono::nanoseconds ProcessMessages(); 61 | 62 | // Tells the engine that the system font list has changed. Should be called 63 | // by clients when OS-level font changes happen (e.g., WM_FONTCHANGE in a 64 | // Win32 application). 65 | void ReloadSystemFonts(); 66 | 67 | // Tells the engine that the platform brightness value has changed. Should be 68 | // called by clients when OS-level theme changes happen (e.g., 69 | // WM_DWMCOLORIZATIONCOLORCHANGED in a Win32 application). 70 | void ReloadPlatformBrightness(); 71 | 72 | // flutter::PluginRegistry: 73 | FlutterDesktopPluginRegistrarRef GetRegistrarForPlugin( 74 | const std::string& plugin_name) override; 75 | 76 | // Returns the messenger to use for creating channels to communicate with the 77 | // Flutter engine. 78 | // 79 | // This pointer will remain valid for the lifetime of this instance. 80 | BinaryMessenger* messenger() { return messenger_.get(); } 81 | 82 | // Schedule a callback to be called after the next frame is drawn. 83 | // 84 | // This must be called from the platform thread. The callback is executed only 85 | // once on the platform thread. 86 | void SetNextFrameCallback(std::function callback); 87 | 88 | // Called to pass an external window message to the engine for lifecycle 89 | // state updates. Non-Flutter windows must call this method in their WndProc 90 | // in order to be included in the logic for application lifecycle state 91 | // updates. Returns a result if the message should be consumed. 92 | std::optional ProcessExternalWindowMessage(HWND hwnd, 93 | UINT message, 94 | WPARAM wparam, 95 | LPARAM lparam); 96 | 97 | private: 98 | // For access to the engine handle. 99 | friend class FlutterViewController; 100 | 101 | // Gives up ownership of |engine_|, but keeps a weak reference to it. 102 | // 103 | // This is intended to be used by FlutterViewController, since the underlying 104 | // C API for view controllers takes over engine ownership. 105 | FlutterDesktopEngineRef RelinquishEngine(); 106 | 107 | // Handle for interacting with the C API's engine reference. 108 | FlutterDesktopEngineRef engine_ = nullptr; 109 | 110 | // Messenger for communicating with the engine. 111 | std::unique_ptr messenger_; 112 | 113 | // Whether or not this wrapper owns |engine_|. 114 | bool owns_engine_ = true; 115 | 116 | // Whether |Run| has been called successfully. 117 | // 118 | // This is used to improve error messages. This can be false while the engine 119 | // is running if the engine was started by creating a view. 120 | bool run_succeeded_ = false; 121 | 122 | // The callback to execute once the next frame is drawn. 123 | std::function next_frame_callback_ = nullptr; 124 | }; 125 | 126 | } // namespace flutter 127 | 128 | #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_CLIENT_WRAPPER_INCLUDE_FLUTTER_FLUTTER_ENGINE_H_ 129 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/include/flutter/flutter_view.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_CLIENT_WRAPPER_INCLUDE_FLUTTER_FLUTTER_VIEW_H_ 6 | #define FLUTTER_SHELL_PLATFORM_WINDOWS_CLIENT_WRAPPER_INCLUDE_FLUTTER_FLUTTER_VIEW_H_ 7 | 8 | #include 9 | 10 | namespace flutter { 11 | 12 | // The unique identifier for a view. 13 | typedef int64_t FlutterViewId; 14 | 15 | // A view displaying Flutter content. 16 | class FlutterView { 17 | public: 18 | explicit FlutterView(FlutterDesktopViewRef view) : view_(view) {} 19 | 20 | // Destroys this reference to the view. The underlying view is not destroyed. 21 | virtual ~FlutterView() = default; 22 | 23 | // Prevent copying. 24 | FlutterView(FlutterView const&) = delete; 25 | FlutterView& operator=(FlutterView const&) = delete; 26 | 27 | // Returns the backing HWND for the view. 28 | HWND GetNativeWindow() { return FlutterDesktopViewGetHWND(view_); } 29 | 30 | // Returns the DXGI adapter used for rendering or nullptr in case of error. 31 | IDXGIAdapter* GetGraphicsAdapter() { 32 | return FlutterDesktopViewGetGraphicsAdapter(view_); 33 | } 34 | 35 | private: 36 | // Handle for interacting with the C API's view. 37 | FlutterDesktopViewRef view_ = nullptr; 38 | }; 39 | 40 | } // namespace flutter 41 | 42 | #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_CLIENT_WRAPPER_INCLUDE_FLUTTER_FLUTTER_VIEW_H_ 43 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/include/flutter/flutter_view_controller.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_CLIENT_WRAPPER_INCLUDE_FLUTTER_FLUTTER_VIEW_CONTROLLER_H_ 6 | #define FLUTTER_SHELL_PLATFORM_WINDOWS_CLIENT_WRAPPER_INCLUDE_FLUTTER_FLUTTER_VIEW_CONTROLLER_H_ 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | #include "dart_project.h" 15 | #include "flutter_engine.h" 16 | #include "flutter_view.h" 17 | 18 | namespace flutter { 19 | 20 | // A controller for a view displaying Flutter content. 21 | // 22 | // This is the primary wrapper class for the desktop C API. 23 | // If you use this class, you should not call any of the setup or teardown 24 | // methods in the C API directly, as this class will do that internally. 25 | class FlutterViewController { 26 | public: 27 | // Creates a FlutterView that can be parented into a Windows View hierarchy 28 | // either using HWNDs. 29 | // 30 | // This also creates a new FlutterEngine. 31 | // 32 | // |dart_project| will be used to configure the engine backing this view. 33 | FlutterViewController(int width, int height, const DartProject& project); 34 | 35 | virtual ~FlutterViewController(); 36 | 37 | // Prevent copying. 38 | FlutterViewController(FlutterViewController const&) = delete; 39 | FlutterViewController& operator=(FlutterViewController const&) = delete; 40 | 41 | // Returns the view controller's view ID. 42 | FlutterViewId view_id() const; 43 | 44 | // Returns the engine running Flutter content in this view. 45 | FlutterEngine* engine() const { return engine_.get(); } 46 | 47 | // Returns the view managed by this controller. 48 | FlutterView* view() const { return view_.get(); } 49 | 50 | // Requests new frame from the engine and repaints the view. 51 | void ForceRedraw(); 52 | 53 | // Allows the Flutter engine and any interested plugins an opportunity to 54 | // handle the given message. 55 | // 56 | // If a result is returned, then the message was handled in such a way that 57 | // further handling should not be done. 58 | std::optional HandleTopLevelWindowProc(HWND hwnd, 59 | UINT message, 60 | WPARAM wparam, 61 | LPARAM lparam); 62 | 63 | private: 64 | // Handle for interacting with the C API's view controller, if any. 65 | FlutterDesktopViewControllerRef controller_ = nullptr; 66 | 67 | // The backing engine 68 | std::shared_ptr engine_; 69 | 70 | // The owned FlutterView. 71 | std::unique_ptr view_; 72 | }; 73 | 74 | } // namespace flutter 75 | 76 | #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_CLIENT_WRAPPER_INCLUDE_FLUTTER_FLUTTER_VIEW_CONTROLLER_H_ 77 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/include/flutter/message_codec.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_MESSAGE_CODEC_H_ 6 | #define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_MESSAGE_CODEC_H_ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace flutter { 13 | 14 | // Translates between a binary message and higher-level method call and 15 | // response/error objects. 16 | template 17 | class MessageCodec { 18 | public: 19 | MessageCodec() = default; 20 | 21 | virtual ~MessageCodec() = default; 22 | 23 | // Prevent copying. 24 | MessageCodec(MessageCodec const&) = delete; 25 | MessageCodec& operator=(MessageCodec const&) = delete; 26 | 27 | // Returns the message encoded in |binary_message|, or nullptr if it cannot be 28 | // decoded by this codec. 29 | std::unique_ptr DecodeMessage(const uint8_t* binary_message, 30 | const size_t message_size) const { 31 | return std::move(DecodeMessageInternal(binary_message, message_size)); 32 | } 33 | 34 | // Returns the message encoded in |binary_message|, or nullptr if it cannot be 35 | // decoded by this codec. 36 | std::unique_ptr DecodeMessage( 37 | const std::vector& binary_message) const { 38 | size_t size = binary_message.size(); 39 | const uint8_t* data = size > 0 ? &binary_message[0] : nullptr; 40 | return std::move(DecodeMessageInternal(data, size)); 41 | } 42 | 43 | // Returns a binary encoding of the given |message|, or nullptr if the 44 | // message cannot be serialized by this codec. 45 | std::unique_ptr> EncodeMessage(const T& message) const { 46 | return std::move(EncodeMessageInternal(message)); 47 | } 48 | 49 | protected: 50 | // Implementation of the public interface, to be provided by subclasses. 51 | virtual std::unique_ptr DecodeMessageInternal( 52 | const uint8_t* binary_message, 53 | const size_t message_size) const = 0; 54 | 55 | // Implementation of the public interface, to be provided by subclasses. 56 | virtual std::unique_ptr> EncodeMessageInternal( 57 | const T& message) const = 0; 58 | }; 59 | 60 | } // namespace flutter 61 | 62 | #endif // FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_MESSAGE_CODEC_H_ 63 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/include/flutter/method_call.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_METHOD_CALL_H_ 6 | #define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_METHOD_CALL_H_ 7 | 8 | #include 9 | #include 10 | 11 | namespace flutter { 12 | 13 | class EncodableValue; 14 | 15 | // An object encapsulating a method call from Flutter whose arguments are of 16 | // type T. 17 | template 18 | class MethodCall { 19 | public: 20 | // Creates a MethodCall with the given name and arguments. 21 | MethodCall(const std::string& method_name, std::unique_ptr arguments) 22 | : method_name_(method_name), arguments_(std::move(arguments)) {} 23 | 24 | virtual ~MethodCall() = default; 25 | 26 | // Prevent copying. 27 | MethodCall(MethodCall const&) = delete; 28 | MethodCall& operator=(MethodCall const&) = delete; 29 | 30 | // The name of the method being called. 31 | const std::string& method_name() const { return method_name_; } 32 | 33 | // The arguments to the method call, or NULL if there are none. 34 | const T* arguments() const { return arguments_.get(); } 35 | 36 | private: 37 | std::string method_name_; 38 | std::unique_ptr arguments_; 39 | }; 40 | 41 | } // namespace flutter 42 | 43 | #endif // FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_METHOD_CALL_H_ 44 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/include/flutter/method_codec.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_METHOD_CODEC_H_ 6 | #define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_METHOD_CODEC_H_ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include "method_call.h" 13 | #include "method_result.h" 14 | 15 | namespace flutter { 16 | 17 | // Translates between a binary message and higher-level method call and 18 | // response/error objects. 19 | template 20 | class MethodCodec { 21 | public: 22 | MethodCodec() = default; 23 | 24 | virtual ~MethodCodec() = default; 25 | 26 | // Prevent copying. 27 | MethodCodec(MethodCodec const&) = delete; 28 | MethodCodec& operator=(MethodCodec const&) = delete; 29 | 30 | // Returns the MethodCall encoded in |message|, or nullptr if it cannot be 31 | // decoded. 32 | std::unique_ptr> DecodeMethodCall(const uint8_t* message, 33 | size_t message_size) const { 34 | return std::move(DecodeMethodCallInternal(message, message_size)); 35 | } 36 | 37 | // Returns the MethodCall encoded in |message|, or nullptr if it cannot be 38 | // decoded. 39 | std::unique_ptr> DecodeMethodCall( 40 | const std::vector& message) const { 41 | size_t size = message.size(); 42 | const uint8_t* data = size > 0 ? &message[0] : nullptr; 43 | return std::move(DecodeMethodCallInternal(data, size)); 44 | } 45 | 46 | // Returns a binary encoding of the given |method_call|, or nullptr if the 47 | // method call cannot be serialized by this codec. 48 | std::unique_ptr> EncodeMethodCall( 49 | const MethodCall& method_call) const { 50 | return std::move(EncodeMethodCallInternal(method_call)); 51 | } 52 | 53 | // Returns a binary encoding of |result|. |result| must be a type supported 54 | // by the codec. 55 | std::unique_ptr> EncodeSuccessEnvelope( 56 | const T* result = nullptr) const { 57 | return std::move(EncodeSuccessEnvelopeInternal(result)); 58 | } 59 | 60 | // Returns a binary encoding of |error|. The |error_details| must be a type 61 | // supported by the codec. 62 | std::unique_ptr> EncodeErrorEnvelope( 63 | const std::string& error_code, 64 | const std::string& error_message = "", 65 | const T* error_details = nullptr) const { 66 | return std::move( 67 | EncodeErrorEnvelopeInternal(error_code, error_message, error_details)); 68 | } 69 | 70 | // Decodes the response envelope encoded in |response|, calling the 71 | // appropriate method on |result|. 72 | // 73 | // Returns false if |response| cannot be decoded. In that case the caller is 74 | // responsible for calling a |result| method. 75 | bool DecodeAndProcessResponseEnvelope(const uint8_t* response, 76 | size_t response_size, 77 | MethodResult* result) const { 78 | return DecodeAndProcessResponseEnvelopeInternal(response, response_size, 79 | result); 80 | } 81 | 82 | protected: 83 | // Implementation of the public interface, to be provided by subclasses. 84 | virtual std::unique_ptr> DecodeMethodCallInternal( 85 | const uint8_t* message, 86 | size_t message_size) const = 0; 87 | 88 | // Implementation of the public interface, to be provided by subclasses. 89 | virtual std::unique_ptr> EncodeMethodCallInternal( 90 | const MethodCall& method_call) const = 0; 91 | 92 | // Implementation of the public interface, to be provided by subclasses. 93 | virtual std::unique_ptr> EncodeSuccessEnvelopeInternal( 94 | const T* result) const = 0; 95 | 96 | // Implementation of the public interface, to be provided by subclasses. 97 | virtual std::unique_ptr> EncodeErrorEnvelopeInternal( 98 | const std::string& error_code, 99 | const std::string& error_message, 100 | const T* error_details) const = 0; 101 | 102 | // Implementation of the public interface, to be provided by subclasses. 103 | virtual bool DecodeAndProcessResponseEnvelopeInternal( 104 | const uint8_t* response, 105 | size_t response_size, 106 | MethodResult* result) const = 0; 107 | }; 108 | 109 | } // namespace flutter 110 | 111 | #endif // FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_METHOD_CODEC_H_ 112 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/include/flutter/method_result.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_METHOD_RESULT_H_ 6 | #define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_METHOD_RESULT_H_ 7 | 8 | #include 9 | 10 | namespace flutter { 11 | 12 | class EncodableValue; 13 | 14 | // Encapsulates a result returned from a MethodCall. Only one method should be 15 | // called on any given instance. 16 | template 17 | class MethodResult { 18 | public: 19 | MethodResult() = default; 20 | 21 | virtual ~MethodResult() = default; 22 | 23 | // Prevent copying. 24 | MethodResult(MethodResult const&) = delete; 25 | MethodResult& operator=(MethodResult const&) = delete; 26 | 27 | // Sends a success response, indicating that the call completed successfully 28 | // with the given result. 29 | void Success(const T& result) { SuccessInternal(&result); } 30 | 31 | // Sends a success response, indicating that the call completed successfully 32 | // with no result. 33 | void Success() { SuccessInternal(nullptr); } 34 | 35 | // Sends an error response, indicating that the call was understood but 36 | // handling failed in some way. 37 | // 38 | // error_code: A string error code describing the error. 39 | // error_message: A user-readable error message. 40 | // error_details: Arbitrary extra details about the error. 41 | void Error(const std::string& error_code, 42 | const std::string& error_message, 43 | const T& error_details) { 44 | ErrorInternal(error_code, error_message, &error_details); 45 | } 46 | 47 | // Sends an error response, indicating that the call was understood but 48 | // handling failed in some way. 49 | // 50 | // error_code: A string error code describing the error. 51 | // error_message: A user-readable error message (optional). 52 | void Error(const std::string& error_code, 53 | const std::string& error_message = "") { 54 | ErrorInternal(error_code, error_message, nullptr); 55 | } 56 | 57 | // Sends a not-implemented response, indicating that the method either was not 58 | // recognized, or has not been implemented. 59 | void NotImplemented() { NotImplementedInternal(); } 60 | 61 | protected: 62 | // Implementation of the public interface, to be provided by subclasses. 63 | virtual void SuccessInternal(const T* result) = 0; 64 | 65 | // Implementation of the public interface, to be provided by subclasses. 66 | virtual void ErrorInternal(const std::string& error_code, 67 | const std::string& error_message, 68 | const T* error_details) = 0; 69 | 70 | // Implementation of the public interface, to be provided by subclasses. 71 | virtual void NotImplementedInternal() = 0; 72 | }; 73 | 74 | } // namespace flutter 75 | 76 | #endif // FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_METHOD_RESULT_H_ 77 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/include/flutter/method_result_functions.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_METHOD_RESULT_FUNCTIONS_H_ 6 | #define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_METHOD_RESULT_FUNCTIONS_H_ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include "method_result.h" 13 | 14 | namespace flutter { 15 | 16 | class EncodableValue; 17 | 18 | // Handler types for each of the MethodResult outcomes. 19 | template 20 | using ResultHandlerSuccess = std::function; 21 | template 22 | using ResultHandlerError = std::function; 25 | template 26 | using ResultHandlerNotImplemented = std::function; 27 | 28 | // An implementation of MethodResult that pass calls through to provided 29 | // function objects, for ease of constructing one-off result handlers. 30 | template 31 | class MethodResultFunctions : public MethodResult { 32 | public: 33 | // Creates a result object that calls the provided functions for the 34 | // corresponding MethodResult outcomes. 35 | MethodResultFunctions(ResultHandlerSuccess on_success, 36 | ResultHandlerError on_error, 37 | ResultHandlerNotImplemented on_not_implemented) 38 | : on_success_(on_success), 39 | on_error_(on_error), 40 | on_not_implemented_(std::move(on_not_implemented)) {} 41 | 42 | virtual ~MethodResultFunctions() = default; 43 | 44 | // Prevent copying. 45 | MethodResultFunctions(MethodResultFunctions const&) = delete; 46 | MethodResultFunctions& operator=(MethodResultFunctions const&) = delete; 47 | 48 | protected: 49 | // |flutter::MethodResult| 50 | void SuccessInternal(const T* result) override { 51 | if (on_success_) { 52 | on_success_(result); 53 | } 54 | } 55 | 56 | // |flutter::MethodResult| 57 | void ErrorInternal(const std::string& error_code, 58 | const std::string& error_message, 59 | const T* error_details) override { 60 | if (on_error_) { 61 | on_error_(error_code, error_message, error_details); 62 | } 63 | } 64 | 65 | // |flutter::MethodResult| 66 | void NotImplementedInternal() override { 67 | if (on_not_implemented_) { 68 | on_not_implemented_(); 69 | } 70 | } 71 | 72 | private: 73 | ResultHandlerSuccess on_success_; 74 | ResultHandlerError on_error_; 75 | ResultHandlerNotImplemented on_not_implemented_; 76 | }; 77 | 78 | } // namespace flutter 79 | 80 | #endif // FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_METHOD_RESULT_FUNCTIONS_H_ 81 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/include/flutter/plugin_registrar.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_PLUGIN_REGISTRAR_H_ 6 | #define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_PLUGIN_REGISTRAR_H_ 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "binary_messenger.h" 16 | #include "texture_registrar.h" 17 | 18 | namespace flutter { 19 | 20 | class Plugin; 21 | 22 | // A object managing the registration of a plugin for various events. 23 | // 24 | // Currently this class has very limited functionality, but is expected to 25 | // expand over time to more closely match the functionality of 26 | // the Flutter mobile plugin APIs' plugin registrars. 27 | class PluginRegistrar { 28 | public: 29 | // Creates a new PluginRegistrar. |core_registrar| and the messenger it 30 | // provides must remain valid as long as this object exists. 31 | explicit PluginRegistrar(FlutterDesktopPluginRegistrarRef core_registrar); 32 | 33 | virtual ~PluginRegistrar(); 34 | 35 | // Prevent copying. 36 | PluginRegistrar(PluginRegistrar const&) = delete; 37 | PluginRegistrar& operator=(PluginRegistrar const&) = delete; 38 | 39 | // Returns the messenger to use for creating channels to communicate with the 40 | // Flutter engine. 41 | // 42 | // This pointer will remain valid for the lifetime of this instance. 43 | BinaryMessenger* messenger() { return messenger_.get(); } 44 | 45 | // Returns the texture registrar to use for the plugin to render a pixel 46 | // buffer. 47 | TextureRegistrar* texture_registrar() { return texture_registrar_.get(); } 48 | 49 | // Takes ownership of |plugin|. 50 | // 51 | // Plugins are not required to call this method if they have other lifetime 52 | // management, but this is a convenient place for plugins to be owned to 53 | // ensure that they stay valid for any registered callbacks. 54 | void AddPlugin(std::unique_ptr plugin); 55 | 56 | protected: 57 | FlutterDesktopPluginRegistrarRef registrar() const { return registrar_; } 58 | 59 | // Destroys all owned plugins. Subclasses should call this at the beginning of 60 | // their destructors to prevent the possibility of an owned plugin trying to 61 | // access destroyed state during its own destruction. 62 | void ClearPlugins(); 63 | 64 | private: 65 | // Handle for interacting with the C API's registrar. 66 | FlutterDesktopPluginRegistrarRef registrar_; 67 | 68 | std::unique_ptr messenger_; 69 | 70 | std::unique_ptr texture_registrar_; 71 | 72 | // Plugins registered for ownership. 73 | std::set> plugins_; 74 | }; 75 | 76 | // A plugin that can be registered for ownership by a PluginRegistrar. 77 | class Plugin { 78 | public: 79 | virtual ~Plugin() = default; 80 | }; 81 | 82 | // A singleton to own PluginRegistrars. This is intended for use in plugins, 83 | // where there is no higher-level object to own a PluginRegistrar that can 84 | // own plugin instances and ensure that they live as long as the engine they 85 | // are registered with. 86 | class PluginRegistrarManager { 87 | public: 88 | static PluginRegistrarManager* GetInstance(); 89 | 90 | // Prevent copying. 91 | PluginRegistrarManager(PluginRegistrarManager const&) = delete; 92 | PluginRegistrarManager& operator=(PluginRegistrarManager const&) = delete; 93 | 94 | // Returns a plugin registrar wrapper of type T, which must be a kind of 95 | // PluginRegistrar, creating it if necessary. The returned registrar will 96 | // live as long as the underlying FlutterDesktopPluginRegistrarRef, so 97 | // can be used to own plugin instances. 98 | // 99 | // Calling this multiple times for the same registrar_ref with different 100 | // template types results in undefined behavior. 101 | template 102 | T* GetRegistrar(FlutterDesktopPluginRegistrarRef registrar_ref) { 103 | auto insert_result = 104 | registrars_.emplace(registrar_ref, std::make_unique(registrar_ref)); 105 | auto& registrar_pair = *(insert_result.first); 106 | FlutterDesktopPluginRegistrarSetDestructionHandler(registrar_pair.first, 107 | OnRegistrarDestroyed); 108 | return static_cast(registrar_pair.second.get()); 109 | } 110 | 111 | // Destroys all registrar wrappers created by the manager. 112 | // 113 | // This is intended primarily for use in tests. 114 | void Reset() { registrars_.clear(); } 115 | 116 | private: 117 | PluginRegistrarManager(); 118 | 119 | using WrapperMap = std::map>; 121 | 122 | static void OnRegistrarDestroyed(FlutterDesktopPluginRegistrarRef registrar); 123 | 124 | WrapperMap* registrars() { return ®istrars_; } 125 | 126 | WrapperMap registrars_; 127 | }; 128 | 129 | } // namespace flutter 130 | 131 | #endif // FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_PLUGIN_REGISTRAR_H_ 132 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/include/flutter/plugin_registry.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_PLUGIN_REGISTRY_H_ 6 | #define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_PLUGIN_REGISTRY_H_ 7 | 8 | #include 9 | 10 | #include 11 | 12 | namespace flutter { 13 | 14 | // Vends PluginRegistrars for named plugins. 15 | // 16 | // Plugins are identified by unique string keys, typically the name of the 17 | // plugin's main class. 18 | class PluginRegistry { 19 | public: 20 | PluginRegistry() = default; 21 | virtual ~PluginRegistry() = default; 22 | 23 | // Prevent copying. 24 | PluginRegistry(PluginRegistry const&) = delete; 25 | PluginRegistry& operator=(PluginRegistry const&) = delete; 26 | 27 | // Returns the FlutterDesktopPluginRegistrarRef to register a plugin with the 28 | // given name. 29 | // 30 | // The name must be unique across the application. 31 | virtual FlutterDesktopPluginRegistrarRef GetRegistrarForPlugin( 32 | const std::string& plugin_name) = 0; 33 | }; 34 | 35 | } // namespace flutter 36 | 37 | #endif // FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_PLUGIN_REGISTRY_H_ 38 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/include/flutter/standard_codec_serializer.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_STANDARD_CODEC_SERIALIZER_H_ 6 | #define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_STANDARD_CODEC_SERIALIZER_H_ 7 | 8 | #include "byte_streams.h" 9 | #include "encodable_value.h" 10 | 11 | namespace flutter { 12 | 13 | // Encapsulates the logic for encoding/decoding EncodableValues to/from the 14 | // standard codec binary representation. 15 | // 16 | // This can be subclassed to extend the standard codec with support for new 17 | // types. 18 | class StandardCodecSerializer { 19 | public: 20 | virtual ~StandardCodecSerializer(); 21 | 22 | // Returns the shared serializer instance. 23 | static const StandardCodecSerializer& GetInstance(); 24 | 25 | // Prevent copying. 26 | StandardCodecSerializer(StandardCodecSerializer const&) = delete; 27 | StandardCodecSerializer& operator=(StandardCodecSerializer const&) = delete; 28 | 29 | // Reads and returns the next value from |stream|. 30 | EncodableValue ReadValue(ByteStreamReader* stream) const; 31 | 32 | // Writes the encoding of |value| to |stream|, including the initial type 33 | // discrimination byte. 34 | // 35 | // Can be overridden by a subclass to extend the codec. 36 | virtual void WriteValue(const EncodableValue& value, 37 | ByteStreamWriter* stream) const; 38 | 39 | protected: 40 | // Codecs require long-lived serializers, so clients should always use 41 | // GetInstance(). 42 | StandardCodecSerializer(); 43 | 44 | // Reads and returns the next value from |stream|, whose discrimination byte 45 | // was |type|. 46 | // 47 | // The discrimination byte will already have been read from the stream when 48 | // this is called. 49 | // 50 | // Can be overridden by a subclass to extend the codec. 51 | virtual EncodableValue ReadValueOfType(uint8_t type, 52 | ByteStreamReader* stream) const; 53 | 54 | // Reads the variable-length size from the current position in |stream|. 55 | size_t ReadSize(ByteStreamReader* stream) const; 56 | 57 | // Writes the variable-length size encoding to |stream|. 58 | void WriteSize(size_t size, ByteStreamWriter* stream) const; 59 | 60 | private: 61 | // Reads a fixed-type list whose values are of type T from the current 62 | // position in |stream|, and returns it as the corresponding EncodableValue. 63 | // |T| must correspond to one of the supported list value types of 64 | // EncodableValue. 65 | template 66 | EncodableValue ReadVector(ByteStreamReader* stream) const; 67 | 68 | // Writes |vector| to |stream| as a fixed-type list. |T| must correspond to 69 | // one of the supported list value types of EncodableValue. 70 | template 71 | void WriteVector(const std::vector vector, ByteStreamWriter* stream) const; 72 | }; 73 | 74 | } // namespace flutter 75 | 76 | #endif // FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_STANDARD_CODEC_SERIALIZER_H_ 77 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/include/flutter/standard_message_codec.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_STANDARD_MESSAGE_CODEC_H_ 6 | #define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_STANDARD_MESSAGE_CODEC_H_ 7 | 8 | #include 9 | 10 | #include "encodable_value.h" 11 | #include "message_codec.h" 12 | #include "standard_codec_serializer.h" 13 | 14 | namespace flutter { 15 | 16 | // A binary message encoding/decoding mechanism for communications to/from the 17 | // Flutter engine via message channels. 18 | class StandardMessageCodec : public MessageCodec { 19 | public: 20 | // Returns an instance of the codec, optionally using a custom serializer to 21 | // add support for more types. 22 | // 23 | // If provided, |serializer| must be long-lived. If no serializer is provided, 24 | // the default will be used. 25 | // 26 | // The instance returned for a given |serializer| will be shared, and 27 | // any instance returned from this will be long-lived, and can be safely 28 | // passed to, e.g., channel constructors. 29 | static const StandardMessageCodec& GetInstance( 30 | const StandardCodecSerializer* serializer = nullptr); 31 | 32 | ~StandardMessageCodec(); 33 | 34 | // Prevent copying. 35 | StandardMessageCodec(StandardMessageCodec const&) = delete; 36 | StandardMessageCodec& operator=(StandardMessageCodec const&) = delete; 37 | 38 | protected: 39 | // |flutter::MessageCodec| 40 | std::unique_ptr DecodeMessageInternal( 41 | const uint8_t* binary_message, 42 | const size_t message_size) const override; 43 | 44 | // |flutter::MessageCodec| 45 | std::unique_ptr> EncodeMessageInternal( 46 | const EncodableValue& message) const override; 47 | 48 | private: 49 | // Instances should be obtained via GetInstance. 50 | explicit StandardMessageCodec(const StandardCodecSerializer* serializer); 51 | 52 | const StandardCodecSerializer* serializer_; 53 | }; 54 | 55 | } // namespace flutter 56 | 57 | #endif // FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_STANDARD_MESSAGE_CODEC_H_ 58 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/include/flutter/standard_method_codec.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_STANDARD_METHOD_CODEC_H_ 6 | #define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_STANDARD_METHOD_CODEC_H_ 7 | 8 | #include 9 | 10 | #include "encodable_value.h" 11 | #include "method_call.h" 12 | #include "method_codec.h" 13 | #include "standard_codec_serializer.h" 14 | 15 | namespace flutter { 16 | 17 | // An implementation of MethodCodec that uses a binary serialization. 18 | class StandardMethodCodec : public MethodCodec { 19 | public: 20 | // Returns an instance of the codec, optionally using a custom serializer to 21 | // add support for more types. 22 | // 23 | // If provided, |serializer| must be long-lived. If no serializer is provided, 24 | // the default will be used. 25 | // 26 | // The instance returned for a given |extension| will be shared, and 27 | // any instance returned from this will be long-lived, and can be safely 28 | // passed to, e.g., channel constructors. 29 | static const StandardMethodCodec& GetInstance( 30 | const StandardCodecSerializer* serializer = nullptr); 31 | 32 | ~StandardMethodCodec(); 33 | 34 | // Prevent copying. 35 | StandardMethodCodec(StandardMethodCodec const&) = delete; 36 | StandardMethodCodec& operator=(StandardMethodCodec const&) = delete; 37 | 38 | protected: 39 | // |flutter::MethodCodec| 40 | std::unique_ptr> DecodeMethodCallInternal( 41 | const uint8_t* message, 42 | size_t message_size) const override; 43 | 44 | // |flutter::MethodCodec| 45 | std::unique_ptr> EncodeMethodCallInternal( 46 | const MethodCall& method_call) const override; 47 | 48 | // |flutter::MethodCodec| 49 | std::unique_ptr> EncodeSuccessEnvelopeInternal( 50 | const EncodableValue* result) const override; 51 | 52 | // |flutter::MethodCodec| 53 | std::unique_ptr> EncodeErrorEnvelopeInternal( 54 | const std::string& error_code, 55 | const std::string& error_message, 56 | const EncodableValue* error_details) const override; 57 | 58 | // |flutter::MethodCodec| 59 | bool DecodeAndProcessResponseEnvelopeInternal( 60 | const uint8_t* response, 61 | size_t response_size, 62 | MethodResult* result) const override; 63 | 64 | private: 65 | // Instances should be obtained via GetInstance. 66 | explicit StandardMethodCodec(const StandardCodecSerializer* serializer); 67 | 68 | const StandardCodecSerializer* serializer_; 69 | }; 70 | 71 | } // namespace flutter 72 | 73 | #endif // FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_STANDARD_METHOD_CODEC_H_ 74 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/include/flutter/texture_registrar.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_TEXTURE_REGISTRAR_H_ 6 | #define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_TEXTURE_REGISTRAR_H_ 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | namespace flutter { 17 | 18 | // A pixel buffer texture. 19 | class PixelBufferTexture { 20 | public: 21 | // A callback used for retrieving pixel buffers. 22 | typedef std::function 24 | CopyBufferCallback; 25 | 26 | // Creates a pixel buffer texture that uses the provided |copy_buffer_cb| to 27 | // retrieve the buffer. 28 | // As the callback is usually invoked from the render thread, the callee must 29 | // take care of proper synchronization. It also needs to be ensured that the 30 | // returned buffer isn't released prior to unregistering this texture. 31 | explicit PixelBufferTexture(CopyBufferCallback copy_buffer_callback) 32 | : copy_buffer_callback_(std::move(copy_buffer_callback)) {} 33 | 34 | // Returns the callback-provided FlutterDesktopPixelBuffer that contains the 35 | // actual pixel data. The intended surface size is specified by |width| and 36 | // |height|. 37 | const FlutterDesktopPixelBuffer* CopyPixelBuffer(size_t width, 38 | size_t height) const { 39 | return copy_buffer_callback_(width, height); 40 | } 41 | 42 | private: 43 | const CopyBufferCallback copy_buffer_callback_; 44 | }; 45 | 46 | // A GPU surface-based texture. 47 | class GpuSurfaceTexture { 48 | public: 49 | // A callback used for retrieving surface descriptors. 50 | typedef std::function< 51 | const FlutterDesktopGpuSurfaceDescriptor*(size_t width, size_t height)> 52 | ObtainDescriptorCallback; 53 | 54 | GpuSurfaceTexture(FlutterDesktopGpuSurfaceType surface_type, 55 | ObtainDescriptorCallback obtain_descriptor_callback) 56 | : surface_type_(surface_type), 57 | obtain_descriptor_callback_(std::move(obtain_descriptor_callback)) {} 58 | 59 | // Returns the callback-provided FlutterDesktopGpuSurfaceDescriptor that 60 | // contains the surface handle. The intended surface size is specified by 61 | // |width| and |height|. 62 | const FlutterDesktopGpuSurfaceDescriptor* ObtainDescriptor( 63 | size_t width, 64 | size_t height) const { 65 | return obtain_descriptor_callback_(width, height); 66 | } 67 | 68 | // Gets the surface type. 69 | FlutterDesktopGpuSurfaceType surface_type() const { return surface_type_; } 70 | 71 | private: 72 | const FlutterDesktopGpuSurfaceType surface_type_; 73 | const ObtainDescriptorCallback obtain_descriptor_callback_; 74 | }; 75 | 76 | // The available texture variants. 77 | // Only PixelBufferTexture is currently implemented. 78 | // Other variants are expected to be added in the future. 79 | typedef std::variant TextureVariant; 80 | 81 | // An object keeping track of external textures. 82 | // 83 | // Thread safety: 84 | // It's safe to call the member methods from any thread. 85 | class TextureRegistrar { 86 | public: 87 | virtual ~TextureRegistrar() = default; 88 | 89 | // Registers a |texture| object and returns the ID for that texture. 90 | virtual int64_t RegisterTexture(TextureVariant* texture) = 0; 91 | 92 | // Notifies the flutter engine that the texture object corresponding 93 | // to |texure_id| needs to render a new frame. 94 | // 95 | // For PixelBufferTextures, this will effectively make the engine invoke 96 | // the callback that was provided upon creating the texture. 97 | virtual bool MarkTextureFrameAvailable(int64_t texture_id) = 0; 98 | 99 | // Asynchronously unregisters an existing texture object. 100 | // Upon completion, the optional |callback| gets invoked. 101 | virtual void UnregisterTexture(int64_t texture_id, 102 | std::function callback) = 0; 103 | 104 | // Unregisters an existing texture object. 105 | // DEPRECATED: Use UnregisterTexture(texture_id, optional_callback) instead. 106 | virtual bool UnregisterTexture(int64_t texture_id) = 0; 107 | }; 108 | 109 | } // namespace flutter 110 | 111 | #endif // FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_TEXTURE_REGISTRAR_H_ 112 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/plugin_registrar.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "include/flutter/plugin_registrar.h" 6 | 7 | #include 8 | #include 9 | 10 | #include "binary_messenger_impl.h" 11 | #include "include/flutter/engine_method_result.h" 12 | #include "include/flutter/method_channel.h" 13 | #include "texture_registrar_impl.h" 14 | 15 | namespace flutter { 16 | 17 | // ===== PluginRegistrar ===== 18 | 19 | PluginRegistrar::PluginRegistrar(FlutterDesktopPluginRegistrarRef registrar) 20 | : registrar_(registrar) { 21 | auto core_messenger = FlutterDesktopPluginRegistrarGetMessenger(registrar_); 22 | messenger_ = std::make_unique(core_messenger); 23 | 24 | auto texture_registrar = 25 | FlutterDesktopRegistrarGetTextureRegistrar(registrar_); 26 | texture_registrar_ = 27 | std::make_unique(texture_registrar); 28 | } 29 | 30 | PluginRegistrar::~PluginRegistrar() { 31 | // This must always be the first call. 32 | ClearPlugins(); 33 | 34 | // Explicitly cleared to facilitate testing of destruction order. 35 | messenger_.reset(); 36 | } 37 | 38 | void PluginRegistrar::AddPlugin(std::unique_ptr plugin) { 39 | plugins_.insert(std::move(plugin)); 40 | } 41 | 42 | void PluginRegistrar::ClearPlugins() { 43 | plugins_.clear(); 44 | } 45 | 46 | // ===== PluginRegistrarManager ===== 47 | 48 | // static 49 | PluginRegistrarManager* PluginRegistrarManager::GetInstance() { 50 | static PluginRegistrarManager* instance = new PluginRegistrarManager(); 51 | return instance; 52 | } 53 | 54 | PluginRegistrarManager::PluginRegistrarManager() = default; 55 | 56 | // static 57 | void PluginRegistrarManager::OnRegistrarDestroyed( 58 | FlutterDesktopPluginRegistrarRef registrar) { 59 | GetInstance()->registrars()->erase(registrar); 60 | } 61 | 62 | } // namespace flutter 63 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/readme: -------------------------------------------------------------------------------- 1 | This code is intended to be built into plugins and applications to provide 2 | higher-level, C++ abstractions for interacting with the Flutter library. 3 | 4 | Over time, the goal is to move more of this code into the library in a way that 5 | provides a usable ABI (e.g., does not use standard library in the interfaces). 6 | 7 | Note that this wrapper is still in early stages. Expect significant churn in 8 | both the APIs and the structure of the wrapper (e.g., the exact set of files 9 | that need to be built). 10 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/cpp_client_wrapper/texture_registrar_impl.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_TEXTURE_REGISTRAR_IMPL_H_ 6 | #define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_TEXTURE_REGISTRAR_IMPL_H_ 7 | 8 | #include "include/flutter/texture_registrar.h" 9 | 10 | namespace flutter { 11 | 12 | // Wrapper around a FlutterDesktopTextureRegistrarRef that implements the 13 | // TextureRegistrar API. 14 | class TextureRegistrarImpl : public TextureRegistrar { 15 | public: 16 | explicit TextureRegistrarImpl( 17 | FlutterDesktopTextureRegistrarRef texture_registrar_ref); 18 | virtual ~TextureRegistrarImpl(); 19 | 20 | // Prevent copying. 21 | TextureRegistrarImpl(TextureRegistrarImpl const&) = delete; 22 | TextureRegistrarImpl& operator=(TextureRegistrarImpl const&) = delete; 23 | 24 | // |flutter::TextureRegistrar| 25 | int64_t RegisterTexture(TextureVariant* texture) override; 26 | 27 | // |flutter::TextureRegistrar| 28 | bool MarkTextureFrameAvailable(int64_t texture_id) override; 29 | 30 | // |flutter::TextureRegistrar| 31 | void UnregisterTexture(int64_t texture_id, 32 | std::function callback) override; 33 | 34 | // |flutter::TextureRegistrar| 35 | bool UnregisterTexture(int64_t texture_id) override; 36 | 37 | private: 38 | // Handle for interacting with the C API. 39 | FlutterDesktopTextureRegistrarRef texture_registrar_ref_; 40 | }; 41 | 42 | } // namespace flutter 43 | 44 | #endif // FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_TEXTURE_REGISTRAR_IMPL_H_ 45 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/f.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/flutter_export.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_SHELL_PLATFORM_COMMON_PUBLIC_FLUTTER_EXPORT_H_ 6 | #define FLUTTER_SHELL_PLATFORM_COMMON_PUBLIC_FLUTTER_EXPORT_H_ 7 | 8 | #ifdef FLUTTER_DESKTOP_LIBRARY 9 | 10 | // Add visibility/export annotations when building the library. 11 | #ifdef _WIN32 12 | #define FLUTTER_EXPORT __declspec(dllexport) 13 | #else 14 | #define FLUTTER_EXPORT __attribute__((visibility("default"))) 15 | #endif 16 | 17 | #else // FLUTTER_DESKTOP_LIBRARY 18 | 19 | // Add import annotations when consuming the library. 20 | #ifdef _WIN32 21 | #define FLUTTER_EXPORT __declspec(dllimport) 22 | #else 23 | #define FLUTTER_EXPORT 24 | #endif 25 | 26 | #endif // FLUTTER_DESKTOP_LIBRARY 27 | 28 | #endif // FLUTTER_SHELL_PLATFORM_COMMON_PUBLIC_FLUTTER_EXPORT_H_ 29 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/flutter_messenger.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_SHELL_PLATFORM_COMMON_PUBLIC_FLUTTER_MESSENGER_H_ 6 | #define FLUTTER_SHELL_PLATFORM_COMMON_PUBLIC_FLUTTER_MESSENGER_H_ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include "flutter_export.h" 13 | 14 | #if defined(__cplusplus) 15 | extern "C" { 16 | #endif // defined(__cplusplus) 17 | 18 | // Opaque reference to a Flutter engine messenger. 19 | typedef struct FlutterDesktopMessenger* FlutterDesktopMessengerRef; 20 | 21 | // Opaque handle for tracking responses to messages. 22 | typedef struct _FlutterPlatformMessageResponseHandle 23 | FlutterDesktopMessageResponseHandle; 24 | 25 | // The callback expected as a response of a binary message. 26 | typedef void (*FlutterDesktopBinaryReply)(const uint8_t* data, 27 | size_t data_size, 28 | void* user_data); 29 | 30 | // A message received from Flutter. 31 | typedef struct { 32 | // Size of this struct as created by Flutter. 33 | size_t struct_size; 34 | // The name of the channel used for this message. 35 | const char* channel; 36 | // The raw message data. 37 | const uint8_t* message; 38 | // The length of |message|. 39 | size_t message_size; 40 | // The response handle. If non-null, the receiver of this message must call 41 | // FlutterDesktopSendMessageResponse exactly once with this handle. 42 | const FlutterDesktopMessageResponseHandle* response_handle; 43 | } FlutterDesktopMessage; 44 | 45 | // Function pointer type for message handler callback registration. 46 | // 47 | // The user data will be whatever was passed to FlutterDesktopSetMessageHandler 48 | // for the channel the message is received on. 49 | typedef void (*FlutterDesktopMessageCallback)( 50 | FlutterDesktopMessengerRef /* messenger */, 51 | const FlutterDesktopMessage* /* message*/, 52 | void* /* user data */); 53 | 54 | // Sends a binary message to the Flutter side on the specified channel. 55 | FLUTTER_EXPORT bool FlutterDesktopMessengerSend( 56 | FlutterDesktopMessengerRef messenger, 57 | const char* channel, 58 | const uint8_t* message, 59 | const size_t message_size); 60 | 61 | // Sends a binary message to the Flutter side on the specified channel. 62 | // The |reply| callback will be executed when a response is received. 63 | FLUTTER_EXPORT bool FlutterDesktopMessengerSendWithReply( 64 | FlutterDesktopMessengerRef messenger, 65 | const char* channel, 66 | const uint8_t* message, 67 | const size_t message_size, 68 | const FlutterDesktopBinaryReply reply, 69 | void* user_data); 70 | 71 | // Sends a reply to a FlutterDesktopMessage for the given response handle. 72 | // 73 | // Once this has been called, |handle| is invalid and must not be used again. 74 | FLUTTER_EXPORT void FlutterDesktopMessengerSendResponse( 75 | FlutterDesktopMessengerRef messenger, 76 | const FlutterDesktopMessageResponseHandle* handle, 77 | const uint8_t* data, 78 | size_t data_length); 79 | 80 | // Registers a callback function for incoming binary messages from the Flutter 81 | // side on the specified channel. 82 | // 83 | // Replaces any existing callback. Provide a null handler to unregister the 84 | // existing callback. 85 | // 86 | // If |user_data| is provided, it will be passed in |callback| calls. 87 | FLUTTER_EXPORT void FlutterDesktopMessengerSetCallback( 88 | FlutterDesktopMessengerRef messenger, 89 | const char* channel, 90 | FlutterDesktopMessageCallback callback, 91 | void* user_data); 92 | 93 | // Increments the reference count for the |messenger|. 94 | // 95 | // Operation is thread-safe. 96 | // 97 | // See also: |FlutterDesktopMessengerRelease| 98 | FLUTTER_EXPORT FlutterDesktopMessengerRef FlutterDesktopMessengerAddRef( 99 | FlutterDesktopMessengerRef messenger); 100 | 101 | // Decrements the reference count for the |messenger|. 102 | // 103 | // Operation is thread-safe. 104 | // 105 | // See also: |FlutterDesktopMessengerAddRef| 106 | FLUTTER_EXPORT void FlutterDesktopMessengerRelease( 107 | FlutterDesktopMessengerRef messenger); 108 | 109 | // Returns `true` if the |FlutterDesktopMessengerRef| still references a running 110 | // engine. 111 | // 112 | // This check should be made inside of a |FlutterDesktopMessengerLock| and 113 | // before any other calls are made to the FlutterDesktopMessengerRef when using 114 | // it from a thread other than the platform thread. 115 | FLUTTER_EXPORT bool FlutterDesktopMessengerIsAvailable( 116 | FlutterDesktopMessengerRef messenger); 117 | 118 | // Locks the `FlutterDesktopMessengerRef` ensuring that 119 | // |FlutterDesktopMessengerIsAvailable| does not change while locked. 120 | // 121 | // All calls to the FlutterDesktopMessengerRef from threads other than the 122 | // platform thread should happen inside of a lock. 123 | // 124 | // Operation is thread-safe. 125 | // 126 | // Returns the |messenger| value. 127 | // 128 | // See also: |FlutterDesktopMessengerUnlock| 129 | FLUTTER_EXPORT FlutterDesktopMessengerRef FlutterDesktopMessengerLock( 130 | FlutterDesktopMessengerRef messenger); 131 | 132 | // Unlocks the `FlutterDesktopMessengerRef`. 133 | // 134 | // Operation is thread-safe. 135 | // 136 | // See also: |FlutterDesktopMessengerLock| 137 | FLUTTER_EXPORT void FlutterDesktopMessengerUnlock( 138 | FlutterDesktopMessengerRef messenger); 139 | 140 | #if defined(__cplusplus) 141 | } // extern "C" 142 | #endif 143 | 144 | #endif // FLUTTER_SHELL_PLATFORM_COMMON_PUBLIC_FLUTTER_MESSENGER_H_ 145 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/flutter_plugin_registrar.h: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef FLUTTER_SHELL_PLATFORM_COMMON_PUBLIC_FLUTTER_PLUGIN_REGISTRAR_H_ 6 | #define FLUTTER_SHELL_PLATFORM_COMMON_PUBLIC_FLUTTER_PLUGIN_REGISTRAR_H_ 7 | 8 | #include 9 | #include 10 | 11 | #include "flutter_export.h" 12 | #include "flutter_messenger.h" 13 | #include "flutter_texture_registrar.h" 14 | 15 | #if defined(__cplusplus) 16 | extern "C" { 17 | #endif // defined(__cplusplus) 18 | 19 | // Opaque reference to a plugin registrar. 20 | typedef struct FlutterDesktopPluginRegistrar* FlutterDesktopPluginRegistrarRef; 21 | 22 | // Function pointer type for registrar destruction callback. 23 | typedef void (*FlutterDesktopOnPluginRegistrarDestroyed)( 24 | FlutterDesktopPluginRegistrarRef); 25 | 26 | // Returns the engine messenger associated with this registrar. 27 | FLUTTER_EXPORT FlutterDesktopMessengerRef 28 | FlutterDesktopPluginRegistrarGetMessenger( 29 | FlutterDesktopPluginRegistrarRef registrar); 30 | 31 | // Returns the texture registrar associated with this registrar. 32 | FLUTTER_EXPORT FlutterDesktopTextureRegistrarRef 33 | FlutterDesktopRegistrarGetTextureRegistrar( 34 | FlutterDesktopPluginRegistrarRef registrar); 35 | 36 | // Registers a callback to be called when the plugin registrar is destroyed. 37 | FLUTTER_EXPORT void FlutterDesktopPluginRegistrarSetDestructionHandler( 38 | FlutterDesktopPluginRegistrarRef registrar, 39 | FlutterDesktopOnPluginRegistrarDestroyed callback); 40 | 41 | #if defined(__cplusplus) 42 | } // extern "C" 43 | #endif 44 | 45 | #endif // FLUTTER_SHELL_PLATFORM_COMMON_PUBLIC_FLUTTER_PLUGIN_REGISTRAR_H_ 46 | -------------------------------------------------------------------------------- /windows/flutter/ephemeral/flutter_windows.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/windows/flutter/ephemeral/flutter_windows.dll -------------------------------------------------------------------------------- /windows/flutter/ephemeral/flutter_windows.dll.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/windows/flutter/ephemeral/flutter_windows.dll.exp -------------------------------------------------------------------------------- /windows/flutter/ephemeral/flutter_windows.dll.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/windows/flutter/ephemeral/flutter_windows.dll.lib -------------------------------------------------------------------------------- /windows/flutter/f.md: -------------------------------------------------------------------------------- 1 | sdsdd 2 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | void RegisterPlugins(flutter::PluginRegistry* registry) { 14 | FirebaseCorePluginCApiRegisterWithRegistrar( 15 | registry->GetRegistrarForPlugin("FirebaseCorePluginCApi")); 16 | SharePlusWindowsPluginCApiRegisterWithRegistrar( 17 | registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi")); 18 | UrlLauncherWindowsRegisterWithRegistrar( 19 | registry->GetRegistrarForPlugin("UrlLauncherWindows")); 20 | } 21 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | firebase_core 7 | share_plus 8 | url_launcher_windows 9 | ) 10 | 11 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 12 | ) 13 | 14 | set(PLUGIN_BUNDLED_LIBRARIES) 15 | 16 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 17 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 18 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 20 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 21 | endforeach(plugin) 22 | 23 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 24 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 25 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 26 | endforeach(ffi_plugin) 27 | -------------------------------------------------------------------------------- /windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Set the application icon 20 | set(WINDOWS_ICON_PATH "${CMAKE_SOURCE_DIR}/resources/logo_v1.ico") 21 | set_target_properties(${BINARY_NAME} PROPERTIES WIN32_EXECUTABLE TRUE) 22 | set_target_properties(${BINARY_NAME} PROPERTIES ICON ${WINDOWS_ICON_PATH}) 23 | 24 | # Apply the standard set of build settings. This can be removed for applications 25 | # that need different build settings. 26 | apply_standard_settings(${BINARY_NAME}) 27 | 28 | # Add preprocessor definitions for the build version. 29 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") 30 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") 31 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") 32 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") 33 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") 34 | 35 | # Disable Windows macros that collide with C++ standard library functions. 36 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 37 | 38 | # Add dependency libraries and include directories. Add any application-specific 39 | # dependencies here. 40 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 41 | target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") 42 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 43 | 44 | # Run the Flutter tool portions of the build. This must not be removed. 45 | add_dependencies(${BINARY_NAME} flutter_assemble) 46 | -------------------------------------------------------------------------------- /windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\logo_v1.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) 64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0,0 67 | #endif 68 | 69 | #if defined(FLUTTER_VERSION) 70 | #define VERSION_AS_STRING FLUTTER_VERSION 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "OpenLabX" "\0" 93 | VALUE "FileDescription", "Open QR Code" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "Open QR Code" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2024 OpenLabX. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "Open QR Code.exe" "\0" 98 | VALUE "ProductName", "Open QR Code" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | 30 | flutter_controller_->engine()->SetNextFrameCallback([&]() { 31 | this->Show(); 32 | }); 33 | 34 | // Flutter can complete the first frame before the "show window" callback is 35 | // registered. The following call ensures a frame is pending to ensure the 36 | // window is shown. It is a no-op if the first frame hasn't completed yet. 37 | flutter_controller_->ForceRedraw(); 38 | 39 | return true; 40 | } 41 | 42 | void FlutterWindow::OnDestroy() { 43 | if (flutter_controller_) { 44 | flutter_controller_ = nullptr; 45 | } 46 | 47 | Win32Window::OnDestroy(); 48 | } 49 | 50 | LRESULT 51 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 52 | WPARAM const wparam, 53 | LPARAM const lparam) noexcept { 54 | // Give Flutter, including plugins, an opportunity to handle window messages. 55 | if (flutter_controller_) { 56 | std::optional result = 57 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 58 | lparam); 59 | if (result) { 60 | return *result; 61 | } 62 | } 63 | 64 | switch (message) { 65 | case WM_FONTCHANGE: 66 | flutter_controller_->engine()->ReloadSystemFonts(); 67 | break; 68 | } 69 | 70 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 71 | } 72 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | 30 | // Updated window size to be a bit larger 31 | Win32Window::Size size(1400, 900); 32 | 33 | if (!window.Create(L"Open QR Code", origin, size)) { 34 | return EXIT_FAILURE; 35 | } 36 | window.SetQuitOnClose(true); 37 | 38 | ::MSG msg; 39 | while (::GetMessage(&msg, nullptr, 0, 0)) { 40 | ::TranslateMessage(&msg); 41 | ::DispatchMessage(&msg); 42 | } 43 | 44 | ::CoUninitialize(); 45 | return EXIT_SUCCESS; 46 | } 47 | -------------------------------------------------------------------------------- /windows/runner/old_CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Add preprocessor definitions for the build version. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") 25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") 26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") 27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") 28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") 29 | 30 | # Disable Windows macros that collide with C++ standard library functions. 31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 32 | 33 | # Add dependency libraries and include directories. Add any application-specific 34 | # dependencies here. 35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 36 | target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") 37 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 38 | 39 | # Run the Flutter tool portions of the build. This must not be removed. 40 | add_dependencies(${BINARY_NAME} flutter_assemble) 41 | -------------------------------------------------------------------------------- /windows/runner/old_Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) 64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0,0 67 | #endif 68 | 69 | #if defined(FLUTTER_VERSION) 70 | #define VERSION_AS_STRING FLUTTER_VERSION 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.example" "\0" 93 | VALUE "FileDescription", "open_qr_code" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "open_qr_code" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2024 com.example. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "open_qr_code.exe" "\0" 98 | VALUE "ProductName", "open_qr_code" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /windows/runner/old_main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.Create(L"open_qr_code", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /windows/runner/resources/logo_v1.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openlab-x/OpenQRCode/e50bcf0e6caf8af12a1bab0d989a787f2b7e313b/windows/runner/resources/logo_v1.ico -------------------------------------------------------------------------------- /windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | unsigned int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr) 51 | -1; // remove the trailing null character 52 | int input_length = (int)wcslen(utf16_string); 53 | std::string utf8_string; 54 | if (target_length == 0 || target_length > utf8_string.max_size()) { 55 | return utf8_string; 56 | } 57 | utf8_string.resize(target_length); 58 | int converted_length = ::WideCharToMultiByte( 59 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 60 | input_length, utf8_string.data(), target_length, nullptr, nullptr); 61 | if (converted_length == 0) { 62 | return std::string(); 63 | } 64 | return utf8_string; 65 | } 66 | -------------------------------------------------------------------------------- /windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates a win32 window with |title| that is positioned and sized using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size this function will scale the inputted width and height as 35 | // as appropriate for the default monitor. The window is invisible until 36 | // |Show| is called. Returns true if the window was created successfully. 37 | bool Create(const std::wstring& title, const Point& origin, const Size& size); 38 | 39 | // Show the current window. Returns true if the window was successfully shown. 40 | bool Show(); 41 | 42 | // Release OS resources associated with window. 43 | void Destroy(); 44 | 45 | // Inserts |content| into the window tree. 46 | void SetChildContent(HWND content); 47 | 48 | // Returns the backing Window handle to enable clients to set icon and other 49 | // window properties. Returns nullptr if the window has been destroyed. 50 | HWND GetHandle(); 51 | 52 | // If true, closing this window will quit the application. 53 | void SetQuitOnClose(bool quit_on_close); 54 | 55 | // Return a RECT representing the bounds of the current client area. 56 | RECT GetClientArea(); 57 | 58 | protected: 59 | // Processes and route salient window messages for mouse handling, 60 | // size change and DPI. Delegates handling of these to member overloads that 61 | // inheriting classes can handle. 62 | virtual LRESULT MessageHandler(HWND window, 63 | UINT const message, 64 | WPARAM const wparam, 65 | LPARAM const lparam) noexcept; 66 | 67 | // Called when CreateAndShow is called, allowing subclass window-related 68 | // setup. Subclasses should return false if setup fails. 69 | virtual bool OnCreate(); 70 | 71 | // Called when Destroy is called. 72 | virtual void OnDestroy(); 73 | 74 | private: 75 | friend class WindowClassRegistrar; 76 | 77 | // OS callback called by message pump. Handles the WM_NCCREATE message which 78 | // is passed when the non-client area is being created and enables automatic 79 | // non-client DPI scaling so that the non-client area automatically 80 | // responds to changes in DPI. All other messages are handled by 81 | // MessageHandler. 82 | static LRESULT CALLBACK WndProc(HWND const window, 83 | UINT const message, 84 | WPARAM const wparam, 85 | LPARAM const lparam) noexcept; 86 | 87 | // Retrieves a class instance pointer for |window| 88 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 89 | 90 | // Update the window frame's theme to match the system theme. 91 | static void UpdateTheme(HWND const window); 92 | 93 | bool quit_on_close_ = false; 94 | 95 | // window handle for top level window. 96 | HWND window_handle_ = nullptr; 97 | 98 | // window handle for hosted content. 99 | HWND child_content_ = nullptr; 100 | }; 101 | 102 | #endif // RUNNER_WIN32_WINDOW_H_ 103 | --------------------------------------------------------------------------------