diff --git a/README.MD b/README.MD index 33b74c7..83807c4 100644 --- a/README.MD +++ b/README.MD @@ -1,33 +1,35 @@ ## Flutter Desktop ### Special thanks -[Go Flutter desktop embedder](https://github.com/Drakirus/go-flutter-desktop-embedder) +[go-flutter](https://github.com/go-flutter-desktop/go-flutter) ### Screenshot ![hot_reload](screenshot/Screenshot_0.gif) ![hot_reload](screenshot/Screenshot_1.gif) ### Feature - Support Hot Reload. (Test Only Visual Studio Code) -- Support Windows and Linux and Mac OS. ([Go Flutter desktop embedder](https://github.com/Drakirus/go-flutter-desktop-embedder)) +- Support Windows and Linux and Mac OS. ([go-flutter](https://github.com/go-flutter-desktop/go-flutter)) - Support window title. - Support Text input. - Support Clipboard. (through shortcuts and UI) - Support Configuration file. - More... ### Deploy -- Clone this project. +- Download release version. +- Extract the file to your path. - Edit main method. +- Edit config.json. ```dart import 'package:flutter/foundation.dart' show debugDefaultTargetPlatformOverride; void main() { // must - debugDefaultTargetPlatformOverride = TargetPlatform.android; + debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; runApp(MyApp()); } ``` -- Copy **assets**, **flutter_engine.dll**, **config.json**, **icudtl.dat**, **launcher.exe**, **run.bat** to flutter project dirctory. if you will be run as Linux or Mac OS, you can to [build target platform](https://github.com/Drakirus/go-flutter-desktop-embedder/blob/master/README.md). -- Run **run.bat**. -- Configuration Visual Studio Code Run configuration (launch.json). + +- Run **launcher.exe**. +- Run with Visual Studio Code. ```json { "version": "0.2.0", @@ -46,15 +48,18 @@ void main() { ### Configuration File ```json { - "WIDTH": 480, - "HEIGHT": 800, - "RATIO": 1.0, - "ICON": "assets/icon.png", - "FLUTTER": "build/flutter_assets", - "ICU": "icudtl.dat", - "ARGS": [ - "--dart-non-checked-mode", - "--observatory-port=50300" - ] + "Width": 480, + "Height": 800, + "MinWidth": 480, + "MinHeight": 800, + "MaxWidth": 480, + "MaxHeight": 800, + "Ratio": 1.0, + "Mode": 0, + "Project": "example", + "ARGS": [ + "--dart-non-checked-mode", + "--observatory-port=50300" + ] } ``` \ No newline at end of file diff --git a/assets/icon.png b/assets/icon.png deleted file mode 100644 index cd4d6f8..0000000 Binary files a/assets/icon.png and /dev/null differ diff --git a/config.json b/config.json index 4cab5ae..5356e4a 100644 --- a/config.json +++ b/config.json @@ -1,10 +1,13 @@ { - "WIDTH": 480, - "HEIGHT": 800, - "RATIO": 1.0, - "ICON": "assets/icon.png", - "FLUTTER": "build/flutter_assets", - "ICU": "icudtl.dat", + "Width": 480, + "Height": 800, + "MinWidth": 480, + "MinHeight": 800, + "MaxWidth": 480, + "MaxHeight": 800, + "Ratio": 1.0, + "Mode": 0, + "Project": "example", "ARGS": [ "--dart-non-checked-mode", "--observatory-port=50300" diff --git a/example/.gitignore b/example/.gitignore new file mode 100644 index 0000000..ac4a906 --- /dev/null +++ b/example/.gitignore @@ -0,0 +1,72 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +.dart_tool/ +.flutter-plugins +.packages +.pub-cache/ +.pub/ +/build/ + +# Android related +**/android/**/gradle-wrapper.jar +**/android/.gradle +**/android/captures/ +**/android/gradlew +**/android/gradlew.bat +**/android/local.properties +**/android/**/GeneratedPluginRegistrant.java + +# iOS/XCode related +**/ios/**/*.mode1v3 +**/ios/**/*.mode2v3 +**/ios/**/*.moved-aside +**/ios/**/*.pbxuser +**/ios/**/*.perspectivev3 +**/ios/**/*sync/ +**/ios/**/.sconsign.dblite +**/ios/**/.tags* +**/ios/**/.vagrant/ +**/ios/**/DerivedData/ +**/ios/**/Icon? +**/ios/**/Pods/ +**/ios/**/.symlinks/ +**/ios/**/profile +**/ios/**/xcuserdata +**/ios/.generated/ +**/ios/Flutter/App.framework +**/ios/Flutter/Flutter.framework +**/ios/Flutter/Generated.xcconfig +**/ios/Flutter/app.flx +**/ios/Flutter/app.zip +**/ios/Flutter/flutter_assets/ +**/ios/ServiceDefinitions.json +**/ios/Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!**/ios/**/default.mode1v3 +!**/ios/**/default.mode2v3 +!**/ios/**/default.pbxuser +!**/ios/**/default.perspectivev3 +!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages diff --git a/.metadata b/example/.metadata similarity index 76% rename from .metadata rename to example/.metadata index 7fccfe9..e023651 100644 --- a/.metadata +++ b/example/.metadata @@ -4,7 +4,7 @@ # This file should be version controlled and should not be manually edited. version: - revision: 985ccb6d14c6ce5ce74823a4d366df2438eac44f - channel: beta + revision: 20e59316b8b8474554b38493b8ca888794b0234a + channel: stable project_type: app diff --git a/example/README.md b/example/README.md new file mode 100644 index 0000000..a135626 --- /dev/null +++ b/example/README.md @@ -0,0 +1,16 @@ +# example + +A new Flutter project. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) + +For help getting started with Flutter, view our +[online documentation](https://flutter.dev/docs), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/android/app/build.gradle b/example/android/app/build.gradle similarity index 94% rename from android/app/build.gradle rename to example/android/app/build.gradle index df4461c..4ed2e25 100644 --- a/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -25,7 +25,7 @@ apply plugin: 'com.android.application' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 27 + compileSdkVersion 28 lintOptions { disable 'InvalidPackage' @@ -33,9 +33,9 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId "com.example.hotloadtest" + applicationId "com.example.example" minSdkVersion 16 - targetSdkVersion 27 + targetSdkVersion 28 versionCode flutterVersionCode.toInteger() versionName flutterVersionName testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..c208884 --- /dev/null +++ b/example/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml similarity index 81% rename from android/app/src/main/AndroidManifest.xml rename to example/android/app/src/main/AndroidManifest.xml index 35659f4..2877140 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -1,11 +1,5 @@ - - - + package="com.example.example"> + + diff --git a/android/build.gradle b/example/android/build.gradle similarity index 100% rename from android/build.gradle rename to example/android/build.gradle diff --git a/android/gradle.properties b/example/android/gradle.properties similarity index 96% rename from android/gradle.properties rename to example/android/gradle.properties index 8bd86f6..2bd6f4f 100644 --- a/android/gradle.properties +++ b/example/android/gradle.properties @@ -1 +1,2 @@ org.gradle.jvmargs=-Xmx1536M + diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from android/gradle/wrapper/gradle-wrapper.properties rename to example/android/gradle/wrapper/gradle-wrapper.properties diff --git a/android/settings.gradle b/example/android/settings.gradle similarity index 100% rename from android/settings.gradle rename to example/android/settings.gradle diff --git a/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist similarity index 94% rename from ios/Flutter/AppFrameworkInfo.plist rename to example/ios/Flutter/AppFrameworkInfo.plist index 9367d48..6b4c0f7 100644 --- a/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -3,7 +3,7 @@ CFBundleDevelopmentRegion - en + $(DEVELOPMENT_LANGUAGE) CFBundleExecutable App CFBundleIdentifier diff --git a/ios/Flutter/Debug.xcconfig b/example/ios/Flutter/Debug.xcconfig similarity index 100% rename from ios/Flutter/Debug.xcconfig rename to example/ios/Flutter/Debug.xcconfig diff --git a/ios/Flutter/Release.xcconfig b/example/ios/Flutter/Release.xcconfig similarity index 100% rename from ios/Flutter/Release.xcconfig rename to example/ios/Flutter/Release.xcconfig diff --git a/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj similarity index 96% rename from ios/Runner.xcodeproj/project.pbxproj rename to example/ios/Runner.xcodeproj/project.pbxproj index 429b82e..556383d 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -8,7 +8,6 @@ /* Begin PBXBuildFile section */ 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; - 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; @@ -40,7 +39,6 @@ /* Begin PBXFileReference section */ 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; - 2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; @@ -73,7 +71,6 @@ 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( - 2D5378251FAA1A9400D5DBA9 /* flutter_assets */, 3B80C3931E831B6300D905FE /* App.framework */, 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 9740EEBA1CF902C7004384FC /* Flutter.framework */, @@ -155,7 +152,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0910; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = "The Chromium Authors"; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -165,7 +162,7 @@ }; buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, @@ -190,7 +187,6 @@ 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */, 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, - 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */, 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -275,12 +271,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -327,7 +325,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.hotLoadTest; + PRODUCT_BUNDLE_IDENTIFIER = com.example.example; PRODUCT_NAME = "$(TARGET_NAME)"; VERSIONING_SYSTEM = "apple-generic"; }; @@ -347,12 +345,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -401,12 +401,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -452,7 +454,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.hotLoadTest; + PRODUCT_BUNDLE_IDENTIFIER = com.example.example; PRODUCT_NAME = "$(TARGET_NAME)"; VERSIONING_SYSTEM = "apple-generic"; }; @@ -475,7 +477,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.example.hotLoadTest; + PRODUCT_BUNDLE_IDENTIFIER = com.example.example; PRODUCT_NAME = "$(TARGET_NAME)"; VERSIONING_SYSTEM = "apple-generic"; }; diff --git a/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata similarity index 100% rename from ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata rename to example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata diff --git a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme similarity index 97% rename from ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme rename to example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 786d6aa..a28140c 100644 --- a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ @@ -46,7 +45,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/ios/Runner.xcworkspace/contents.xcworkspacedata b/example/ios/Runner.xcworkspace/contents.xcworkspacedata similarity index 100% rename from ios/Runner.xcworkspace/contents.xcworkspacedata rename to example/ios/Runner.xcworkspace/contents.xcworkspacedata diff --git a/ios/Runner/AppDelegate.h b/example/ios/Runner/AppDelegate.h similarity index 100% rename from ios/Runner/AppDelegate.h rename to example/ios/Runner/AppDelegate.h diff --git a/ios/Runner/AppDelegate.m b/example/ios/Runner/AppDelegate.m similarity index 100% rename from ios/Runner/AppDelegate.m rename to example/ios/Runner/AppDelegate.m diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png similarity index 100% rename from ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png rename to example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json similarity index 100% rename from ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json rename to example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png similarity index 100% rename from ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png rename to example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png similarity index 100% rename from ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png rename to example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png similarity index 100% rename from ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png rename to example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png diff --git a/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md similarity index 100% rename from ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md rename to example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md diff --git a/ios/Runner/Base.lproj/LaunchScreen.storyboard b/example/ios/Runner/Base.lproj/LaunchScreen.storyboard similarity index 100% rename from ios/Runner/Base.lproj/LaunchScreen.storyboard rename to example/ios/Runner/Base.lproj/LaunchScreen.storyboard diff --git a/ios/Runner/Base.lproj/Main.storyboard b/example/ios/Runner/Base.lproj/Main.storyboard similarity index 100% rename from ios/Runner/Base.lproj/Main.storyboard rename to example/ios/Runner/Base.lproj/Main.storyboard diff --git a/ios/Runner/Info.plist b/example/ios/Runner/Info.plist similarity index 95% rename from ios/Runner/Info.plist rename to example/ios/Runner/Info.plist index 665068f..a060db6 100644 --- a/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -3,7 +3,7 @@ CFBundleDevelopmentRegion - en + $(DEVELOPMENT_LANGUAGE) CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier @@ -11,7 +11,7 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleName - hot_load_test + example CFBundlePackageType APPL CFBundleShortVersionString diff --git a/ios/Runner/main.m b/example/ios/Runner/main.m similarity index 100% rename from ios/Runner/main.m rename to example/ios/Runner/main.m diff --git a/lib/main.dart b/example/lib/main.dart similarity index 98% rename from lib/main.dart rename to example/lib/main.dart index 8084c4b..ec323ff 100644 --- a/lib/main.dart +++ b/example/lib/main.dart @@ -3,7 +3,7 @@ import 'package:flutter/foundation.dart' show debugDefaultTargetPlatformOverride; void main() { - debugDefaultTargetPlatformOverride = TargetPlatform.android; + debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; runApp(MyApp()); } @@ -49,7 +49,7 @@ class MyHomePage extends StatefulWidget { } class _MyHomePageState extends State { - int _counter = 10; + int _counter = 0; void _incrementCounter() { setState(() { diff --git a/pubspec.yaml b/example/pubspec.yaml similarity index 73% rename from pubspec.yaml rename to example/pubspec.yaml index 449b3ce..efca881 100644 --- a/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,4 +1,4 @@ -name: hot_load_test +name: example description: A new Flutter project. # The following defines the version and build number for your application. @@ -6,7 +6,11 @@ description: A new Flutter project. # followed by an optional build number separated by a +. # Both the version and the builder number may be overridden in flutter # build by specifying --build-name and --build-number, respectively. -# Read more about versioning at semver.org. +# In Android, build-name is used as versionName while build-number used as versionCode. +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning +# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html version: 1.0.0+1 environment: @@ -26,7 +30,7 @@ dev_dependencies: # For information on the generic Dart part of this file, see the -# following page: https://www.dartlang.org/tools/pub/pubspec +# following page: https://dart.dev/tools/pub/pubspec # The following section is specific to Flutter. flutter: @@ -42,10 +46,10 @@ flutter: # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.io/assets-and-images/#resolution-aware. + # https://flutter.dev/assets-and-images/#resolution-aware. # For details regarding adding assets from package dependencies, see - # https://flutter.io/assets-and-images/#from-packages + # https://flutter.dev/assets-and-images/#from-packages # To add custom fonts to your application, add a fonts section here, # in this "flutter" section. Each entry in this list should have a @@ -65,4 +69,4 @@ flutter: # weight: 700 # # For details regarding fonts from package dependencies, - # see https://flutter.io/custom-fonts/#from-packages + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/test/widget_test.dart b/example/test/widget_test.dart similarity index 96% rename from test/widget_test.dart rename to example/test/widget_test.dart index ac9cbfa..747db1d 100644 --- a/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -8,7 +8,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:hot_load_test/main.dart'; +import 'package:example/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { diff --git a/flutter_engine.dll b/flutter_engine.dll index 352d8e6..6a3784b 100644 Binary files a/flutter_engine.dll and b/flutter_engine.dll differ diff --git a/launcher.exe b/launcher.exe deleted file mode 100644 index 0b945a7..0000000 Binary files a/launcher.exe and /dev/null differ diff --git a/launcher.go b/launcher.go new file mode 100644 index 0000000..6e3b5a0 --- /dev/null +++ b/launcher.go @@ -0,0 +1,119 @@ +package main + +import ( + "encoding/json" + "fmt" + "io" + "io/ioutil" + "os" + "os/exec" + "path/filepath" + "strings" +) + +type RunConfig struct { + Name string `json:"name"` // Flutter + Request string `json:"request"` // attach + DeviceId string `json:"deviceId"` // flutter-tester + ObservatoryUri string `json:"observatoryUri"` // dynamic + Type string `json:"type"` // dart +} + +type Launcher struct { + Version string `json:"version"` // 0.2.0 + Configurations []interface{} `json:"configurations"` // RunConfig +} + +var url string +var path string +var launchConfig string + +const file string = "/.vscode/launch.json" + +func main() { + cmd := exec.Command("./flutter_engine.exe") + out, _ := cmd.StdoutPipe() + err, _ := cmd.StderrPipe() + defer out.Close() + defer err.Close() + e := cmd.Start() + if e != nil { + fmt.Println(e) + } + go sync(out) + go sync(err) + wait := cmd.Wait() + if wait != nil { + fmt.Println(wait) + } +} + +// 获取输出 +func sync(read io.ReadCloser) { + buf := make([]byte, 1024, 1024) + for { + length, _ := read.Read(buf) + if length > 0 { + bytes := buf[:length] + msg := string(bytes) + fmt.Print(msg) + if url == "" || path == "" { + subStrings(msg) + } else { + if launchConfig == "" { + makeJson() + saveConfig() + } + } + } + } +} + +// 获取参数 +func subStrings(text string) { + begin := "http://" + if strings.Contains(text, begin) { + index := strings.Index(text, begin) + temp := text[index : len(text)-1] + temp = strings.TrimSuffix(temp, "\r") + url = strings.TrimSuffix(temp, "\n") + } else { + start := "Project:" + index := strings.Index(text, start) + temp := text[index+len(start)+1 : len(text)-1] + temp = strings.TrimSuffix(temp, "\r") + path = strings.TrimSuffix(temp, "\n") + } +} + +// 保存配置文件 +func saveConfig() { + content := []byte(launchConfig) + saveJsonConfig := path + file + err := os.MkdirAll(filepath.Dir(saveJsonConfig), os.ModePerm) + if err != nil { + fmt.Println(err) + } + err = ioutil.WriteFile(saveJsonConfig, content, 0644) + if err != nil { + fmt.Println(err.Error()) + } +} + +// 生成启动配置 +func makeJson() { + launcher := &Launcher{ + Version: "0.2.0", + Configurations: []interface{}{ + &RunConfig{ + Name: "Flutter", + Request: "attach", + DeviceId: "flutter-tester", + Type: "dart", + ObservatoryUri: url, + }, + }, + } + bytes, _ := json.Marshal(launcher) + launchConfig = string(bytes) +} diff --git a/main.go b/main.go index efe203a..622ae19 100644 --- a/main.go +++ b/main.go @@ -1,32 +1,38 @@ package main import ( + "encoding/json" + "fmt" + "github.com/go-flutter-desktop/go-flutter" + "github.com/pkg/errors" "image" _ "image/png" + "io/ioutil" "log" "os" - "github.com/Drakirus/go-flutter-desktop-embedder" - "github.com/go-gl/glfw/v3.2/glfw" - "io/ioutil" - "encoding/json" + "path/filepath" ) const configData = "config.json" type Configuration struct { - WIDTH int // 宽度 - HEIGHT int // 高度 - RATIO float64 // 像素密度 - ICON string // 图标 - FLUTTER string // 资源路径 - ICU string // ICUData - ARGS []string // 虚拟机参数 + Project string // 项目路径 + Mode int // 窗口模式 0 = WindowModeDefault 1 = WindowModeBorderless 2 = WindowModeBorderlessFullscreen + Width int // 宽度 + Height int // 高度 + MinWidth int // 最小宽度 + MinHeight int // 最小高度 + MaxWidth int // 最大宽度 + MaxHeight int // 最大高度 + Ratio float64 // 像素密度 + ARGS []string // 虚拟机参数 } type JsonBody struct { } var config Configuration +var root string func main() { var ( @@ -36,38 +42,74 @@ func main() { parse := makeJsonBody() parse.loadConfigFile(configData, &config) - options := []gutter.Option{ - gutter.ProjectAssetPath(config.FLUTTER), - gutter.ApplicationICUDataPath(config.ICU), - gutter.ApplicationWindowDimension(config.WIDTH, config.HEIGHT), - gutter.OptionWindowInitializer(setIcon), - gutter.OptionPixelRatio(config.RATIO), - gutter.OptionVMArguments(config.ARGS), + if err = flutter.Run(setOptions()...); err != nil { + log.Fatalln(err) } +} - if err = gutter.Run(options...); err != nil { - log.Fatalln(err) +// 设置项目路径 +func setProjectPath() { + if config.Project == "" { + root = "." + } else { + root = config.Project + } + fmt.Println("Project: " + filepath.ToSlash(root)) +} + +// 设置启动参数 +func setOptions() []flutter.Option { + setProjectPath() + return []flutter.Option{ + flutter.ProjectAssetsPath(root + "/build/flutter_assets"), + flutter.ApplicationICUDataPath("icudtl.dat"), + flutter.WindowInitialDimensions(config.Width, config.Height), + flutter.WindowDimensionLimits(config.MinWidth, config.MinHeight, config.MaxWidth, config.MaxHeight), + flutter.WindowIcon(setIcon), + flutter.ForcePixelRatio(config.Ratio), + flutter.OptionVMArguments(config.ARGS), + setWindowMode(config.Mode), } +} +// 设置窗口模式 +func setWindowMode(mode int) flutter.Option { + if mode == 1 { + return flutter.WindowMode(flutter.WindowModeBorderless) + } else if mode == 2 { + return flutter.WindowMode(flutter.WindowModeBorderlessFullscreen) + } else { + return flutter.WindowMode(flutter.WindowModeDefault) + } } -func setIcon(window *glfw.Window) error { - imgFile, err := os.Open(config.ICON) +// 设置应用程序图标 +func setIcon() ([]image.Image, error) { + execPath, err := os.Executable() + if err != nil { + return nil, errors.Wrap(err, "failed to resolve executable path") + } + execPath, err = filepath.EvalSymlinks(execPath) + if err != nil { + return nil, errors.Wrap(err, "failed to eval symlinks for executable path") + } + imgFile, err := os.Open(root + "/assets/icon.png") if err != nil { - return err + return nil, errors.Wrap(err, "failed to open assets/icon.png") } img, _, err := image.Decode(imgFile) if err != nil { - return err + return nil, errors.Wrap(err, "failed to decode image") } - window.SetIcon([]image.Image{img}) - return nil + return []image.Image{img}, nil } +// 创建JSON结构体 func makeJsonBody() *JsonBody { return &JsonBody{} } +// 解析配置文件 func (jst *JsonBody) loadConfigFile(filename string, v interface{}) { data, err := ioutil.ReadFile(filename) if err != nil { diff --git a/run b/run deleted file mode 100644 index b928370..0000000 --- a/run +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -flutter build bundle & ./main \ No newline at end of file diff --git a/run.bat b/run.bat deleted file mode 100644 index 6f8aff5..0000000 --- a/run.bat +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -taskkill /f /t /im launcher.exe & flutter build bundle & start /b launcher.exe \ No newline at end of file