├── .gitattributes
├── LICENSE
├── README.md
├── ffi_normal
├── .gitignore
├── .metadata
├── CHANGELOG.md
├── LICENSE
├── README.md
├── analysis_options.yaml
├── android
│ ├── .gitignore
│ ├── CMakeLists.txt
│ ├── build.gradle
│ ├── settings.gradle
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ └── kotlin
│ │ └── com
│ │ └── xdd
│ │ └── ffi_normal
│ │ └── FfiNormalPlugin.kt
├── example
│ ├── .gitignore
│ ├── README.md
│ ├── analysis_options.yaml
│ ├── android
│ │ ├── .gitignore
│ │ ├── app
│ │ │ ├── build.gradle
│ │ │ └── src
│ │ │ │ ├── debug
│ │ │ │ └── AndroidManifest.xml
│ │ │ │ ├── main
│ │ │ │ ├── AndroidManifest.xml
│ │ │ │ ├── kotlin
│ │ │ │ │ └── com
│ │ │ │ │ │ └── xdd
│ │ │ │ │ │ └── ffi_normal_example
│ │ │ │ │ │ └── MainActivity.kt
│ │ │ │ └── res
│ │ │ │ │ ├── drawable-v21
│ │ │ │ │ └── launch_background.xml
│ │ │ │ │ ├── drawable
│ │ │ │ │ └── launch_background.xml
│ │ │ │ │ ├── mipmap-hdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ ├── mipmap-mdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ ├── mipmap-xhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ ├── values-night
│ │ │ │ │ └── styles.xml
│ │ │ │ │ └── values
│ │ │ │ │ └── styles.xml
│ │ │ │ └── profile
│ │ │ │ └── AndroidManifest.xml
│ │ ├── build.gradle
│ │ ├── gradle.properties
│ │ ├── gradle
│ │ │ └── wrapper
│ │ │ │ └── gradle-wrapper.properties
│ │ └── settings.gradle
│ ├── ios
│ │ ├── .gitignore
│ │ ├── Flutter
│ │ │ ├── AppFrameworkInfo.plist
│ │ │ ├── Debug.xcconfig
│ │ │ └── Release.xcconfig
│ │ ├── Runner.xcodeproj
│ │ │ ├── project.pbxproj
│ │ │ ├── project.xcworkspace
│ │ │ │ ├── contents.xcworkspacedata
│ │ │ │ └── xcshareddata
│ │ │ │ │ ├── IDEWorkspaceChecks.plist
│ │ │ │ │ └── WorkspaceSettings.xcsettings
│ │ │ └── xcshareddata
│ │ │ │ └── xcschemes
│ │ │ │ └── Runner.xcscheme
│ │ ├── Runner.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcshareddata
│ │ │ │ ├── IDEWorkspaceChecks.plist
│ │ │ │ └── WorkspaceSettings.xcsettings
│ │ └── Runner
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Assets.xcassets
│ │ │ ├── AppIcon.appiconset
│ │ │ │ ├── Contents.json
│ │ │ │ ├── Icon-App-1024x1024@1x.png
│ │ │ │ ├── Icon-App-20x20@1x.png
│ │ │ │ ├── Icon-App-20x20@2x.png
│ │ │ │ ├── Icon-App-20x20@3x.png
│ │ │ │ ├── Icon-App-29x29@1x.png
│ │ │ │ ├── Icon-App-29x29@2x.png
│ │ │ │ ├── Icon-App-29x29@3x.png
│ │ │ │ ├── Icon-App-40x40@1x.png
│ │ │ │ ├── Icon-App-40x40@2x.png
│ │ │ │ ├── Icon-App-40x40@3x.png
│ │ │ │ ├── Icon-App-60x60@2x.png
│ │ │ │ ├── Icon-App-60x60@3x.png
│ │ │ │ ├── Icon-App-76x76@1x.png
│ │ │ │ ├── Icon-App-76x76@2x.png
│ │ │ │ └── Icon-App-83.5x83.5@2x.png
│ │ │ └── LaunchImage.imageset
│ │ │ │ ├── Contents.json
│ │ │ │ ├── LaunchImage.png
│ │ │ │ ├── LaunchImage@2x.png
│ │ │ │ ├── LaunchImage@3x.png
│ │ │ │ └── README.md
│ │ │ ├── Base.lproj
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ │ ├── Info.plist
│ │ │ └── Runner-Bridging-Header.h
│ ├── lib
│ │ └── main.dart
│ ├── linux
│ │ ├── .gitignore
│ │ ├── CMakeLists.txt
│ │ ├── flutter
│ │ │ ├── CMakeLists.txt
│ │ │ ├── generated_plugin_registrant.cc
│ │ │ ├── generated_plugin_registrant.h
│ │ │ └── generated_plugins.cmake
│ │ ├── main.cc
│ │ ├── my_application.cc
│ │ └── my_application.h
│ ├── macos
│ │ ├── .gitignore
│ │ ├── Flutter
│ │ │ ├── Flutter-Debug.xcconfig
│ │ │ ├── Flutter-Release.xcconfig
│ │ │ └── GeneratedPluginRegistrant.swift
│ │ ├── Runner.xcodeproj
│ │ │ ├── project.pbxproj
│ │ │ ├── project.xcworkspace
│ │ │ │ └── xcshareddata
│ │ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcshareddata
│ │ │ │ └── xcschemes
│ │ │ │ └── Runner.xcscheme
│ │ ├── Runner.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcshareddata
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ └── Runner
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Assets.xcassets
│ │ │ └── AppIcon.appiconset
│ │ │ │ ├── Contents.json
│ │ │ │ ├── app_icon_1024.png
│ │ │ │ ├── app_icon_128.png
│ │ │ │ ├── app_icon_16.png
│ │ │ │ ├── app_icon_256.png
│ │ │ │ ├── app_icon_32.png
│ │ │ │ ├── app_icon_512.png
│ │ │ │ └── app_icon_64.png
│ │ │ ├── Base.lproj
│ │ │ └── MainMenu.xib
│ │ │ ├── Configs
│ │ │ ├── AppInfo.xcconfig
│ │ │ ├── Debug.xcconfig
│ │ │ ├── Release.xcconfig
│ │ │ └── Warnings.xcconfig
│ │ │ ├── DebugProfile.entitlements
│ │ │ ├── Info.plist
│ │ │ ├── MainFlutterWindow.swift
│ │ │ └── Release.entitlements
│ ├── pubspec.lock
│ ├── pubspec.yaml
│ ├── test
│ │ └── widget_test.dart
│ ├── web
│ │ ├── favicon.png
│ │ ├── icons
│ │ │ ├── Icon-192.png
│ │ │ ├── Icon-512.png
│ │ │ ├── Icon-maskable-192.png
│ │ │ └── Icon-maskable-512.png
│ │ ├── index.html
│ │ └── manifest.json
│ └── windows
│ │ ├── .gitignore
│ │ ├── CMakeLists.txt
│ │ ├── flutter
│ │ ├── CMakeLists.txt
│ │ ├── generated_plugin_registrant.cc
│ │ ├── generated_plugin_registrant.h
│ │ └── generated_plugins.cmake
│ │ └── runner
│ │ ├── CMakeLists.txt
│ │ ├── Runner.rc
│ │ ├── flutter_window.cpp
│ │ ├── flutter_window.h
│ │ ├── main.cpp
│ │ ├── resource.h
│ │ ├── resources
│ │ └── app_icon.ico
│ │ ├── runner.exe.manifest
│ │ ├── utils.cpp
│ │ ├── utils.h
│ │ ├── win32_window.cpp
│ │ └── win32_window.h
├── ios
│ ├── .gitignore
│ ├── Assets
│ │ └── .gitkeep
│ ├── Classes
│ │ ├── FfiNormalPlugin.h
│ │ ├── FfiNormalPlugin.m
│ │ ├── SwiftFfiNormalPlugin.swift
│ │ └── native
│ │ │ ├── dart_api
│ │ │ ├── dart_api.h
│ │ │ ├── dart_api_dl.c
│ │ │ ├── dart_api_dl.h
│ │ │ ├── dart_native_api.h
│ │ │ ├── dart_version.h
│ │ │ └── internal
│ │ │ │ └── dart_api_dl_impl.h
│ │ │ ├── ffigen
│ │ │ └── add.cpp
│ │ │ ├── message_interaction.cpp
│ │ │ ├── sync_callback.cpp
│ │ │ └── sync_invoke.cpp
│ └── ffi_normal.podspec
├── lib
│ ├── ffi_normal.dart
│ ├── native
│ │ └── CMakeLists.txt
│ └── src
│ │ ├── ffigen
│ │ └── two_num_add.dart
│ │ ├── native_ffi.dart
│ │ ├── native_invoke.dart
│ │ └── native_use
│ │ ├── message_interaction.dart
│ │ ├── sync_callback.dart
│ │ └── sync_invoke.dart
├── linux
│ ├── CMakeLists.txt
│ ├── ffi_normal_plugin.cc
│ └── include
│ │ └── ffi_normal
│ │ └── ffi_normal_plugin.h
├── macos
│ ├── Classes
│ │ ├── FfiNormalPlugin.swift
│ │ └── native
│ │ │ ├── ffigen
│ │ │ └── add.cpp
│ │ │ ├── sync_callback.cpp
│ │ │ └── sync_invoke.cpp
│ └── ffi_normal.podspec
├── pubspec.yaml
└── windows
│ ├── .gitignore
│ ├── CMakeLists.txt
│ ├── ffi_normal_plugin.cpp
│ ├── ffi_normal_plugin.h
│ ├── ffi_normal_plugin_c_api.cpp
│ └── include
│ └── ffi_normal
│ └── ffi_normal_plugin_c_api.h
└── rust_bridge
├── .gitignore
├── .metadata
├── README.md
├── analysis_options.yaml
├── android
├── .gitignore
├── app
│ ├── build.gradle
│ └── src
│ │ ├── debug
│ │ └── AndroidManifest.xml
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── jniLibs
│ │ │ ├── arm64-v8a
│ │ │ │ └── librust_ffi.so
│ │ │ ├── armeabi-v7a
│ │ │ │ └── librust_ffi.so
│ │ │ ├── x86
│ │ │ │ └── librust_ffi.so
│ │ │ └── x86_64
│ │ │ │ └── librust_ffi.so
│ │ ├── kotlin
│ │ │ └── com
│ │ │ │ └── xdd
│ │ │ │ └── rust_bridge
│ │ │ │ └── MainActivity.kt
│ │ └── res
│ │ │ ├── drawable-v21
│ │ │ └── launch_background.xml
│ │ │ ├── drawable
│ │ │ └── launch_background.xml
│ │ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── values-night
│ │ │ └── styles.xml
│ │ │ └── values
│ │ │ └── styles.xml
│ │ └── profile
│ │ └── AndroidManifest.xml
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ └── gradle-wrapper.properties
└── settings.gradle
├── ios
├── .gitignore
├── Flutter
│ ├── AppFrameworkInfo.plist
│ ├── Debug.xcconfig
│ └── Release.xcconfig
├── Runner.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ ├── IDEWorkspaceChecks.plist
│ │ │ └── WorkspaceSettings.xcsettings
│ └── xcshareddata
│ │ └── xcschemes
│ │ └── Runner.xcscheme
├── Runner.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ ├── IDEWorkspaceChecks.plist
│ │ └── WorkspaceSettings.xcsettings
└── Runner
│ ├── AppDelegate.swift
│ ├── Assets.xcassets
│ ├── AppIcon.appiconset
│ │ ├── Contents.json
│ │ ├── Icon-App-1024x1024@1x.png
│ │ ├── Icon-App-20x20@1x.png
│ │ ├── Icon-App-20x20@2x.png
│ │ ├── Icon-App-20x20@3x.png
│ │ ├── Icon-App-29x29@1x.png
│ │ ├── Icon-App-29x29@2x.png
│ │ ├── Icon-App-29x29@3x.png
│ │ ├── Icon-App-40x40@1x.png
│ │ ├── Icon-App-40x40@2x.png
│ │ ├── Icon-App-40x40@3x.png
│ │ ├── Icon-App-60x60@2x.png
│ │ ├── Icon-App-60x60@3x.png
│ │ ├── Icon-App-76x76@1x.png
│ │ ├── Icon-App-76x76@2x.png
│ │ └── Icon-App-83.5x83.5@2x.png
│ └── LaunchImage.imageset
│ │ ├── Contents.json
│ │ ├── LaunchImage.png
│ │ ├── LaunchImage@2x.png
│ │ ├── LaunchImage@3x.png
│ │ └── README.md
│ ├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
│ ├── Info.plist
│ ├── Runner-Bridging-Header.h
│ └── bridge_generated.h
├── lib
├── ffi
│ ├── native_ffi.dart
│ ├── native_fun.dart
│ └── rust_ffi
│ │ └── rust_ffi.dart
└── main.dart
├── linux
├── .gitignore
├── CMakeLists.txt
├── flutter
│ ├── CMakeLists.txt
│ ├── generated_plugin_registrant.cc
│ ├── generated_plugin_registrant.h
│ └── generated_plugins.cmake
├── main.cc
├── my_application.cc
├── my_application.h
└── rust.cmake
├── macos
├── .gitignore
├── Flutter
│ ├── Flutter-Debug.xcconfig
│ ├── Flutter-Release.xcconfig
│ └── GeneratedPluginRegistrant.swift
├── Runner.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ └── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ └── xcshareddata
│ │ └── xcschemes
│ │ └── Runner.xcscheme
├── Runner.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
└── Runner
│ ├── AppDelegate.swift
│ ├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ ├── Contents.json
│ │ ├── app_icon_1024.png
│ │ ├── app_icon_128.png
│ │ ├── app_icon_16.png
│ │ ├── app_icon_256.png
│ │ ├── app_icon_32.png
│ │ ├── app_icon_512.png
│ │ └── app_icon_64.png
│ ├── Base.lproj
│ └── MainMenu.xib
│ ├── Configs
│ ├── AppInfo.xcconfig
│ ├── Debug.xcconfig
│ ├── Release.xcconfig
│ └── Warnings.xcconfig
│ ├── DebugProfile.entitlements
│ ├── Info.plist
│ ├── MainFlutterWindow.swift
│ ├── Release.entitlements
│ └── bridge_generated.h
├── pubspec.yaml
├── rust
├── Cargo.lock
├── Cargo.toml
├── rust_ffi.xcodeproj
│ ├── project.pbxproj
│ └── xcuserdata
│ │ ├── xdd.xcuserdatad
│ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ │ └── xdd666.xcuserdatad
│ │ └── xcschemes
│ │ └── xcschememanagement.plist
└── src
│ ├── api.rs
│ ├── bridge_generated.io.rs
│ ├── bridge_generated.rs
│ └── lib.rs
├── rust_gen.sh
├── test
└── widget_test.dart
├── web
├── favicon.png
├── icons
│ ├── Icon-192.png
│ ├── Icon-512.png
│ ├── Icon-maskable-192.png
│ └── Icon-maskable-512.png
├── index.html
└── manifest.json
└── windows
├── .gitignore
├── CMakeLists.txt
├── flutter
├── CMakeLists.txt
├── generated_plugin_registrant.cc
├── generated_plugin_registrant.h
└── generated_plugins.cmake
├── runner
├── CMakeLists.txt
├── Runner.rc
├── flutter_window.cpp
├── flutter_window.h
├── main.cpp
├── resource.h
├── resources
│ └── app_icon.ico
├── runner.exe.manifest
├── utils.cpp
├── utils.h
├── win32_window.cpp
└── win32_window.h
└── rust.cmake
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 小呆呆666
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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # flutter_ffi
2 |
3 | - 该库配置说明:https://juejin.cn/post/7176077601746714681
4 |
5 | - 安装 rust:https://www.rust-lang.org/zh-CN/tools/install
6 |
7 | ```
8 | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
9 | ```
10 |
11 | # Windows
12 |
13 | - 在windows上安装编译生成库,需要安装指定版本
14 |
15 | ```bash
16 | # 指定版本
17 | cargo install flutter_rust_bridge_codegen --version 1.51.0 --force
18 | ```
19 |
20 | - 然后重新执行生成命令
21 |
22 | ```
23 | flutter_rust_bridge_codegen -r rust/src/api.rs -d lib/ffi/rust_ffi/rust_ffi.dart -c ios/Runner/bridge_generated.h -c macos/Runner/bridge_generated.h
24 | ```
25 |
26 | # iOS
27 |
28 | - 编译iOS,按需执行下述命令
29 |
30 | ```bash
31 | # 64 bit targets (真机 & 模拟器):
32 | rustup target add aarch64-apple-ios x86_64-apple-ios
33 | # New simulator target for Xcode 12 and later
34 | rustup target add aarch64-apple-ios-sim
35 | ```
36 |
--------------------------------------------------------------------------------
/ffi_normal/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 | migrate_working_dir/
12 |
13 | # IntelliJ related
14 | *.iml
15 | *.ipr
16 | *.iws
17 | .idea/
18 |
19 | # The .vscode folder contains launch configuration and tasks you configure in
20 | # VS Code which you may wish to be included in version control, so this line
21 | # is commented out by default.
22 | #.vscode/
23 |
24 | # Flutter/Dart/Pub related
25 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
26 | /pubspec.lock
27 | **/doc/api/
28 | .dart_tool/
29 | .packages
30 | build/
31 | pubspec.lock
--------------------------------------------------------------------------------
/ffi_normal/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled.
5 |
6 | version:
7 | revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
8 | channel: stable
9 |
10 | project_type: plugin
11 |
12 | # Tracks metadata for the flutter migrate command
13 | migration:
14 | platforms:
15 | - platform: root
16 | create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
17 | base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
18 | - platform: android
19 | create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
20 | base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
21 | - platform: ios
22 | create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
23 | base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
24 | - platform: linux
25 | create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
26 | base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
27 | - platform: macos
28 | create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
29 | base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
30 | - platform: web
31 | create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
32 | base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
33 | - platform: windows
34 | create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
35 | base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
36 |
37 | # User provided section
38 |
39 | # List of Local paths (relative to this file) that should be
40 | # ignored by the migrate tool.
41 | #
42 | # Files that are not part of the templates will be ignored by default.
43 | unmanaged_files:
44 | - 'lib/main.dart'
45 | - 'ios/Runner.xcodeproj/project.pbxproj'
46 |
--------------------------------------------------------------------------------
/ffi_normal/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## 0.0.1
2 |
3 | * TODO: Describe initial release.
4 |
--------------------------------------------------------------------------------
/ffi_normal/LICENSE:
--------------------------------------------------------------------------------
1 | TODO: Add your license here.
2 |
--------------------------------------------------------------------------------
/ffi_normal/README.md:
--------------------------------------------------------------------------------
1 | # ffi_normal
2 |
3 | flutter ffi demo
4 |
5 | ## Getting Started
6 |
7 | This project is a starting point for a Flutter
8 | [plug-in package](https://flutter.dev/developing-packages/),
9 | a specialized package that includes platform-specific implementation code for
10 | Android and/or iOS.
11 |
12 | For help getting started with Flutter development, view the
13 | [online documentation](https://flutter.dev/docs), which offers tutorials,
14 | samples, guidance on mobile development, and a full API reference.
15 |
16 |
--------------------------------------------------------------------------------
/ffi_normal/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | include: package:flutter_lints/flutter.yaml
2 |
3 | # Additional information about this file can be found at
4 | # https://dart.dev/guides/language/analysis-options
5 |
--------------------------------------------------------------------------------
/ffi_normal/android/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .cxx
10 |
--------------------------------------------------------------------------------
/ffi_normal/android/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # cmake_minimum_required 表示支持的 cmake 最小版本
2 | cmake_minimum_required(VERSION 3.4.1)
3 |
4 | # 项目名称
5 | set(PROJECT_NAME "native_fun")
6 |
7 | # 批量添加cpp文件
8 | # add_library 关键字表示构建链接库,参数1是链接包名称; 参数2'SHARED'表示构建动态链接库; 参数2是源文件列表
9 | file(GLOB_RECURSE native_batch ../ios/Classes/native/*)
10 | add_library(${PROJECT_NAME} SHARED ${native_batch})
--------------------------------------------------------------------------------
/ffi_normal/android/build.gradle:
--------------------------------------------------------------------------------
1 | group 'com.xdd.ffi_normal'
2 | version '1.0-SNAPSHOT'
3 |
4 | buildscript {
5 | ext.kotlin_version = '1.6.10'
6 | repositories {
7 | google()
8 | mavenCentral()
9 | }
10 |
11 | dependencies {
12 | classpath 'com.android.tools.build:gradle:7.1.2'
13 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | google()
20 | mavenCentral()
21 | }
22 | }
23 |
24 | apply plugin: 'com.android.library'
25 | apply plugin: 'kotlin-android'
26 |
27 | android {
28 | compileSdkVersion 31
29 |
30 | compileOptions {
31 | sourceCompatibility JavaVersion.VERSION_1_8
32 | targetCompatibility JavaVersion.VERSION_1_8
33 | }
34 |
35 | kotlinOptions {
36 | jvmTarget = '1.8'
37 | }
38 |
39 | sourceSets {
40 | main.java.srcDirs += 'src/main/kotlin'
41 | }
42 |
43 | defaultConfig {
44 | minSdkVersion 16
45 | }
46 |
47 |
48 | //配置CMakeList路径
49 | externalNativeBuild {
50 | cmake {
51 | path "CMakeLists.txt"
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/ffi_normal/android/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'ffi_normal'
2 |
--------------------------------------------------------------------------------
/ffi_normal/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/ffi_normal/android/src/main/kotlin/com/xdd/ffi_normal/FfiNormalPlugin.kt:
--------------------------------------------------------------------------------
1 | package com.xdd.ffi_normal
2 |
3 | import androidx.annotation.NonNull
4 |
5 | import io.flutter.embedding.engine.plugins.FlutterPlugin
6 | import io.flutter.plugin.common.MethodCall
7 | import io.flutter.plugin.common.MethodChannel
8 | import io.flutter.plugin.common.MethodChannel.MethodCallHandler
9 | import io.flutter.plugin.common.MethodChannel.Result
10 |
11 | /** FfiNormalPlugin */
12 | class FfiNormalPlugin: FlutterPlugin, MethodCallHandler {
13 | /// The MethodChannel that will the communication between Flutter and native Android
14 | ///
15 | /// This local reference serves to register the plugin with the Flutter Engine and unregister it
16 | /// when the Flutter Engine is detached from the Activity
17 | private lateinit var channel : MethodChannel
18 |
19 | override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
20 | channel = MethodChannel(flutterPluginBinding.binaryMessenger, "ffi_normal")
21 | channel.setMethodCallHandler(this)
22 | }
23 |
24 | override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) {
25 | if (call.method == "getPlatformVersion") {
26 | result.success("Android ${android.os.Build.VERSION.RELEASE}")
27 | } else {
28 | result.notImplemented()
29 | }
30 | }
31 |
32 | override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
33 | channel.setMethodCallHandler(null)
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/ffi_normal/example/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 | migrate_working_dir/
12 |
13 | # IntelliJ related
14 | *.iml
15 | *.ipr
16 | *.iws
17 | .idea/
18 |
19 | # The .vscode folder contains launch configuration and tasks you configure in
20 | # VS Code which you may wish to be included in version control, so this line
21 | # is commented out by default.
22 | #.vscode/
23 |
24 | # Flutter/Dart/Pub related
25 | **/doc/api/
26 | **/ios/Flutter/.last_build_id
27 | .dart_tool/
28 | .flutter-plugins
29 | .flutter-plugins-dependencies
30 | .packages
31 | .pub-cache/
32 | .pub/
33 | /build/
34 |
35 | # Symbolication related
36 | app.*.symbols
37 |
38 | # Obfuscation related
39 | app.*.map.json
40 |
41 | # Android Studio will place build artifacts here
42 | /android/app/debug
43 | /android/app/profile
44 | /android/app/release
45 |
--------------------------------------------------------------------------------
/ffi_normal/example/README.md:
--------------------------------------------------------------------------------
1 | # ffi_normal_example
2 |
3 | Demonstrates how to use the ffi_normal plugin.
4 |
5 | ## Getting Started
6 |
7 | This project is a starting point for a Flutter application.
8 |
9 | A few resources to get you started if this is your first Flutter project:
10 |
11 | - [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
12 | - [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
13 |
14 | For help getting started with Flutter development, view the
15 | [online documentation](https://docs.flutter.dev/), which offers tutorials,
16 | samples, guidance on mobile development, and a full API reference.
17 |
--------------------------------------------------------------------------------
/ffi_normal/example/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | # This file configures the analyzer, which statically analyzes Dart code to
2 | # check for errors, warnings, and lints.
3 | #
4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6 | # invoked from the command line by running `flutter analyze`.
7 |
8 | # The following line activates a set of recommended lints for Flutter apps,
9 | # packages, and plugins designed to encourage good coding practices.
10 | include: package:flutter_lints/flutter.yaml
11 |
12 | linter:
13 | # The lint rules applied to this project can be customized in the
14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml`
15 | # included above or to enable additional rules. A list of all available lints
16 | # and their documentation is published at
17 | # https://dart-lang.github.io/linter/lints/index.html.
18 | #
19 | # Instead of disabling a lint rule for the entire project in the
20 | # section below, it can also be suppressed for a single line of code
21 | # or a specific dart file by using the `// ignore: name_of_lint` and
22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file
23 | # producing the lint.
24 | rules:
25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule
26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
27 |
28 | # Additional information about this file can be found at
29 | # https://dart.dev/guides/language/analysis-options
30 |
--------------------------------------------------------------------------------
/ffi_normal/example/android/.gitignore:
--------------------------------------------------------------------------------
1 | gradle-wrapper.jar
2 | /.gradle
3 | /captures/
4 | /gradlew
5 | /gradlew.bat
6 | /local.properties
7 | GeneratedPluginRegistrant.java
8 |
9 | # Remember to never publicly share your keystore.
10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
11 | key.properties
12 | **/*.keystore
13 | **/*.jks
14 |
--------------------------------------------------------------------------------
/ffi_normal/example/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | def localProperties = new Properties()
2 | def localPropertiesFile = rootProject.file('local.properties')
3 | if (localPropertiesFile.exists()) {
4 | localPropertiesFile.withReader('UTF-8') { reader ->
5 | localProperties.load(reader)
6 | }
7 | }
8 |
9 | def flutterRoot = localProperties.getProperty('flutter.sdk')
10 | if (flutterRoot == null) {
11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12 | }
13 |
14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15 | if (flutterVersionCode == null) {
16 | flutterVersionCode = '1'
17 | }
18 |
19 | def flutterVersionName = localProperties.getProperty('flutter.versionName')
20 | if (flutterVersionName == null) {
21 | flutterVersionName = '1.0'
22 | }
23 |
24 | apply plugin: 'com.android.application'
25 | apply plugin: 'kotlin-android'
26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27 |
28 | android {
29 | compileSdkVersion flutter.compileSdkVersion
30 | ndkVersion flutter.ndkVersion
31 |
32 | compileOptions {
33 | sourceCompatibility JavaVersion.VERSION_1_8
34 | targetCompatibility JavaVersion.VERSION_1_8
35 | }
36 |
37 | kotlinOptions {
38 | jvmTarget = '1.8'
39 | }
40 |
41 | sourceSets {
42 | main.java.srcDirs += 'src/main/kotlin'
43 | }
44 |
45 | defaultConfig {
46 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
47 | applicationId "com.xdd.ffi_normal_example"
48 | // You can update the following values to match your application needs.
49 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
50 | minSdkVersion flutter.minSdkVersion
51 | targetSdkVersion flutter.targetSdkVersion
52 | versionCode flutterVersionCode.toInteger()
53 | versionName flutterVersionName
54 | }
55 |
56 | buildTypes {
57 | release {
58 | // TODO: Add your own signing config for the release build.
59 | // Signing with the debug keys for now, so `flutter run --release` works.
60 | signingConfig signingConfigs.debug
61 | }
62 | }
63 | }
64 |
65 | flutter {
66 | source '../..'
67 | }
68 |
69 | dependencies {
70 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
71 | }
72 |
--------------------------------------------------------------------------------
/ffi_normal/example/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ffi_normal/example/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
7 |
15 |
19 |
23 |
24 |
25 |
26 |
27 |
28 |
30 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/ffi_normal/example/android/app/src/main/kotlin/com/xdd/ffi_normal_example/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.xdd.ffi_normal_example
2 |
3 | import io.flutter.embedding.android.FlutterActivity
4 |
5 | class MainActivity: FlutterActivity() {
6 | }
7 |
--------------------------------------------------------------------------------
/ffi_normal/example/android/app/src/main/res/drawable-v21/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/ffi_normal/example/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/ffi_normal/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ffi_normal/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ffi_normal/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ffi_normal/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ffi_normal/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/ffi_normal/example/android/app/src/main/res/values-night/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/ffi_normal/example/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/ffi_normal/example/android/app/src/profile/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ffi_normal/example/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext.kotlin_version = '1.6.10'
3 | repositories {
4 | google()
5 | mavenCentral()
6 | }
7 |
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:7.1.2'
10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11 | }
12 | }
13 |
14 | allprojects {
15 | repositories {
16 | google()
17 | mavenCentral()
18 | }
19 | }
20 |
21 | rootProject.buildDir = '../build'
22 | subprojects {
23 | project.buildDir = "${rootProject.buildDir}/${project.name}"
24 | }
25 | subprojects {
26 | project.evaluationDependsOn(':app')
27 | }
28 |
29 | task clean(type: Delete) {
30 | delete rootProject.buildDir
31 | }
32 |
--------------------------------------------------------------------------------
/ffi_normal/example/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.useAndroidX=true
3 | android.enableJetifier=true
4 |
--------------------------------------------------------------------------------
/ffi_normal/example/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.4-all.zip
6 |
--------------------------------------------------------------------------------
/ffi_normal/example/android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
4 | def properties = new Properties()
5 |
6 | assert localPropertiesFile.exists()
7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
8 |
9 | def flutterSdkPath = properties.getProperty("flutter.sdk")
10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
12 |
--------------------------------------------------------------------------------
/ffi_normal/example/ios/.gitignore:
--------------------------------------------------------------------------------
1 | **/dgph
2 | *.mode1v3
3 | *.mode2v3
4 | *.moved-aside
5 | *.pbxuser
6 | *.perspectivev3
7 | **/*sync/
8 | .sconsign.dblite
9 | .tags*
10 | **/.vagrant/
11 | **/DerivedData/
12 | Icon?
13 | **/Pods/
14 | **/.symlinks/
15 | profile
16 | xcuserdata
17 | **/.generated/
18 | Flutter/App.framework
19 | Flutter/Flutter.framework
20 | Flutter/Flutter.podspec
21 | Flutter/Generated.xcconfig
22 | Flutter/ephemeral/
23 | Flutter/app.flx
24 | Flutter/app.zip
25 | Flutter/flutter_assets/
26 | Flutter/flutter_export_environment.sh
27 | ServiceDefinitions.json
28 | Runner/GeneratedPluginRegistrant.*
29 |
30 | # Exceptions to above rules.
31 | !default.mode1v3
32 | !default.mode2v3
33 | !default.pbxuser
34 | !default.perspectivev3
35 |
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | App
9 | CFBundleIdentifier
10 | io.flutter.flutter.app
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | App
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | MinimumOSVersion
24 | 11.0
25 |
26 |
27 |
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 | import Flutter
3 |
4 | @UIApplicationMain
5 | @objc class AppDelegate: FlutterAppDelegate {
6 | override func application(
7 | _ application: UIApplication,
8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
9 | ) -> Bool {
10 | GeneratedPluginRegistrant.register(with: self)
11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "20x20",
5 | "idiom" : "iphone",
6 | "filename" : "Icon-App-20x20@2x.png",
7 | "scale" : "2x"
8 | },
9 | {
10 | "size" : "20x20",
11 | "idiom" : "iphone",
12 | "filename" : "Icon-App-20x20@3x.png",
13 | "scale" : "3x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "Icon-App-29x29@1x.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "29x29",
23 | "idiom" : "iphone",
24 | "filename" : "Icon-App-29x29@2x.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "29x29",
29 | "idiom" : "iphone",
30 | "filename" : "Icon-App-29x29@3x.png",
31 | "scale" : "3x"
32 | },
33 | {
34 | "size" : "40x40",
35 | "idiom" : "iphone",
36 | "filename" : "Icon-App-40x40@2x.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "40x40",
41 | "idiom" : "iphone",
42 | "filename" : "Icon-App-40x40@3x.png",
43 | "scale" : "3x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "Icon-App-60x60@2x.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "60x60",
53 | "idiom" : "iphone",
54 | "filename" : "Icon-App-60x60@3x.png",
55 | "scale" : "3x"
56 | },
57 | {
58 | "size" : "20x20",
59 | "idiom" : "ipad",
60 | "filename" : "Icon-App-20x20@1x.png",
61 | "scale" : "1x"
62 | },
63 | {
64 | "size" : "20x20",
65 | "idiom" : "ipad",
66 | "filename" : "Icon-App-20x20@2x.png",
67 | "scale" : "2x"
68 | },
69 | {
70 | "size" : "29x29",
71 | "idiom" : "ipad",
72 | "filename" : "Icon-App-29x29@1x.png",
73 | "scale" : "1x"
74 | },
75 | {
76 | "size" : "29x29",
77 | "idiom" : "ipad",
78 | "filename" : "Icon-App-29x29@2x.png",
79 | "scale" : "2x"
80 | },
81 | {
82 | "size" : "40x40",
83 | "idiom" : "ipad",
84 | "filename" : "Icon-App-40x40@1x.png",
85 | "scale" : "1x"
86 | },
87 | {
88 | "size" : "40x40",
89 | "idiom" : "ipad",
90 | "filename" : "Icon-App-40x40@2x.png",
91 | "scale" : "2x"
92 | },
93 | {
94 | "size" : "76x76",
95 | "idiom" : "ipad",
96 | "filename" : "Icon-App-76x76@1x.png",
97 | "scale" : "1x"
98 | },
99 | {
100 | "size" : "76x76",
101 | "idiom" : "ipad",
102 | "filename" : "Icon-App-76x76@2x.png",
103 | "scale" : "2x"
104 | },
105 | {
106 | "size" : "83.5x83.5",
107 | "idiom" : "ipad",
108 | "filename" : "Icon-App-83.5x83.5@2x.png",
109 | "scale" : "2x"
110 | },
111 | {
112 | "size" : "1024x1024",
113 | "idiom" : "ios-marketing",
114 | "filename" : "Icon-App-1024x1024@1x.png",
115 | "scale" : "1x"
116 | }
117 | ],
118 | "info" : {
119 | "version" : 1,
120 | "author" : "xcode"
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchImage.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchImage@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "LaunchImage@3x.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md:
--------------------------------------------------------------------------------
1 | # Launch Screen Assets
2 |
3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory.
4 |
5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleDisplayName
8 | Ffi Normal
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | ffi_normal_example
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | $(FLUTTER_BUILD_NAME)
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | $(FLUTTER_BUILD_NUMBER)
25 | LSRequiresIPhoneOS
26 |
27 | UILaunchStoryboardName
28 | LaunchScreen
29 | UIMainStoryboardFile
30 | Main
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 | UIViewControllerBasedStatusBarAppearance
45 |
46 | CADisableMinimumFrameDurationOnPhone
47 |
48 | UIApplicationSupportsIndirectInputEvents
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/ffi_normal/example/ios/Runner/Runner-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | #import "GeneratedPluginRegistrant.h"
2 |
--------------------------------------------------------------------------------
/ffi_normal/example/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'package:ffi_normal/ffi_normal.dart';
2 | import 'package:flutter/material.dart';
3 |
4 | void main() {
5 | runApp(const MyApp());
6 | }
7 |
8 | class MyApp extends StatefulWidget {
9 | const MyApp({Key? key}) : super(key: key);
10 |
11 | @override
12 | State createState() => _MyAppState();
13 | }
14 |
15 | class _MyAppState extends State {
16 | int _count = 0;
17 | int _countMSg = 9;
18 |
19 | @override
20 | Widget build(BuildContext context) {
21 | return MaterialApp(
22 | home: Scaffold(
23 | appBar: AppBar(title: const Text('Plugin example app')),
24 | body: Center(
25 | child: Wrap(spacing: 10, children: [
26 | // 同步调用
27 | ElevatedButton(
28 | onPressed: () {
29 | _count = NativeInvoke.addSyncInvokeGen(_count, 1);
30 | setState(() {});
31 | },
32 | child: Text('Count: $_count'),
33 | ),
34 |
35 | // 同步调用回调
36 | const ElevatedButton(
37 | onPressed: NativeInvoke.printSyncCallback,
38 | child: Text('syncCallback'),
39 | ),
40 |
41 | // 异步消息
42 | ElevatedButton(
43 | onPressed: () {
44 | _countMSg++;
45 | NativeInvoke.asyncMsg(_countMSg);
46 | setState(() {});
47 | },
48 | child: Text('asyncMsg: $_countMSg'),
49 | ),
50 | ]),
51 | ),
52 | ),
53 | );
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/ffi_normal/example/linux/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/ephemeral
2 |
--------------------------------------------------------------------------------
/ffi_normal/example/linux/flutter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # This file controls Flutter-level build steps. It should not be edited.
2 | cmake_minimum_required(VERSION 3.10)
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 |
12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...),
13 | # which isn't available in 3.10.
14 | function(list_prepend LIST_NAME PREFIX)
15 | set(NEW_LIST "")
16 | foreach(element ${${LIST_NAME}})
17 | list(APPEND NEW_LIST "${PREFIX}${element}")
18 | endforeach(element)
19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE)
20 | endfunction()
21 |
22 | # === Flutter Library ===
23 | # System-level dependencies.
24 | find_package(PkgConfig REQUIRED)
25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
28 |
29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
30 |
31 | # Published to parent scope for install step.
32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE)
36 |
37 | list(APPEND FLUTTER_LIBRARY_HEADERS
38 | "fl_basic_message_channel.h"
39 | "fl_binary_codec.h"
40 | "fl_binary_messenger.h"
41 | "fl_dart_project.h"
42 | "fl_engine.h"
43 | "fl_json_message_codec.h"
44 | "fl_json_method_codec.h"
45 | "fl_message_codec.h"
46 | "fl_method_call.h"
47 | "fl_method_channel.h"
48 | "fl_method_codec.h"
49 | "fl_method_response.h"
50 | "fl_plugin_registrar.h"
51 | "fl_plugin_registry.h"
52 | "fl_standard_message_codec.h"
53 | "fl_standard_method_codec.h"
54 | "fl_string_codec.h"
55 | "fl_value.h"
56 | "fl_view.h"
57 | "flutter_linux.h"
58 | )
59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/")
60 | add_library(flutter INTERFACE)
61 | target_include_directories(flutter INTERFACE
62 | "${EPHEMERAL_DIR}"
63 | )
64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
65 | target_link_libraries(flutter INTERFACE
66 | PkgConfig::GTK
67 | PkgConfig::GLIB
68 | PkgConfig::GIO
69 | )
70 | add_dependencies(flutter flutter_assemble)
71 |
72 | # === Flutter tool backend ===
73 | # _phony_ is a non-existent file to force this command to run every time,
74 | # since currently there's no way to get a full input/output list from the
75 | # flutter tool.
76 | add_custom_command(
77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_
79 | COMMAND ${CMAKE_COMMAND} -E env
80 | ${FLUTTER_TOOL_ENVIRONMENT}
81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
83 | VERBATIM
84 | )
85 | add_custom_target(flutter_assemble DEPENDS
86 | "${FLUTTER_LIBRARY}"
87 | ${FLUTTER_LIBRARY_HEADERS}
88 | )
89 |
--------------------------------------------------------------------------------
/ffi_normal/example/linux/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 |
11 | void fl_register_plugins(FlPluginRegistry* registry) {
12 | g_autoptr(FlPluginRegistrar) ffi_normal_registrar =
13 | fl_plugin_registry_get_registrar_for_plugin(registry, "FfiNormalPlugin");
14 | ffi_normal_plugin_register_with_registrar(ffi_normal_registrar);
15 | }
16 |
--------------------------------------------------------------------------------
/ffi_normal/example/linux/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 fl_register_plugins(FlPluginRegistry* registry);
14 |
15 | #endif // GENERATED_PLUGIN_REGISTRANT_
16 |
--------------------------------------------------------------------------------
/ffi_normal/example/linux/flutter/generated_plugins.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Generated file, do not edit.
3 | #
4 |
5 | list(APPEND FLUTTER_PLUGIN_LIST
6 | ffi_normal
7 | )
8 |
9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST
10 | )
11 |
12 | set(PLUGIN_BUNDLED_LIBRARIES)
13 |
14 | foreach(plugin ${FLUTTER_PLUGIN_LIST})
15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $)
18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
19 | endforeach(plugin)
20 |
21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
24 | endforeach(ffi_plugin)
25 |
--------------------------------------------------------------------------------
/ffi_normal/example/linux/main.cc:
--------------------------------------------------------------------------------
1 | #include "my_application.h"
2 |
3 | int main(int argc, char** argv) {
4 | g_autoptr(MyApplication) app = my_application_new();
5 | return g_application_run(G_APPLICATION(app), argc, argv);
6 | }
7 |
--------------------------------------------------------------------------------
/ffi_normal/example/linux/my_application.h:
--------------------------------------------------------------------------------
1 | #ifndef FLUTTER_MY_APPLICATION_H_
2 | #define FLUTTER_MY_APPLICATION_H_
3 |
4 | #include
5 |
6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION,
7 | GtkApplication)
8 |
9 | /**
10 | * my_application_new:
11 | *
12 | * Creates a new Flutter-based application.
13 | *
14 | * Returns: a new #MyApplication.
15 | */
16 | MyApplication* my_application_new();
17 |
18 | #endif // FLUTTER_MY_APPLICATION_H_
19 |
--------------------------------------------------------------------------------
/ffi_normal/example/macos/.gitignore:
--------------------------------------------------------------------------------
1 | # Flutter-related
2 | **/Flutter/ephemeral/
3 | **/Pods/
4 |
5 | # Xcode-related
6 | **/dgph
7 | **/xcuserdata/
8 |
--------------------------------------------------------------------------------
/ffi_normal/example/macos/Flutter/Flutter-Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "ephemeral/Flutter-Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/ffi_normal/example/macos/Flutter/Flutter-Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "ephemeral/Flutter-Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/ffi_normal/example/macos/Flutter/GeneratedPluginRegistrant.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | import FlutterMacOS
6 | import Foundation
7 |
8 | import ffi_normal
9 |
10 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
11 | FfiNormalPlugin.register(with: registry.registrar(forPlugin: "FfiNormalPlugin"))
12 | }
13 |
--------------------------------------------------------------------------------
/ffi_normal/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ffi_normal/example/macos/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ffi_normal/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ffi_normal/example/macos/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import FlutterMacOS
3 |
4 | @NSApplicationMain
5 | class AppDelegate: FlutterAppDelegate {
6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
7 | return true
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/ffi_normal/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "16x16",
5 | "idiom" : "mac",
6 | "filename" : "app_icon_16.png",
7 | "scale" : "1x"
8 | },
9 | {
10 | "size" : "16x16",
11 | "idiom" : "mac",
12 | "filename" : "app_icon_32.png",
13 | "scale" : "2x"
14 | },
15 | {
16 | "size" : "32x32",
17 | "idiom" : "mac",
18 | "filename" : "app_icon_32.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "32x32",
23 | "idiom" : "mac",
24 | "filename" : "app_icon_64.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "128x128",
29 | "idiom" : "mac",
30 | "filename" : "app_icon_128.png",
31 | "scale" : "1x"
32 | },
33 | {
34 | "size" : "128x128",
35 | "idiom" : "mac",
36 | "filename" : "app_icon_256.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "256x256",
41 | "idiom" : "mac",
42 | "filename" : "app_icon_256.png",
43 | "scale" : "1x"
44 | },
45 | {
46 | "size" : "256x256",
47 | "idiom" : "mac",
48 | "filename" : "app_icon_512.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "512x512",
53 | "idiom" : "mac",
54 | "filename" : "app_icon_512.png",
55 | "scale" : "1x"
56 | },
57 | {
58 | "size" : "512x512",
59 | "idiom" : "mac",
60 | "filename" : "app_icon_1024.png",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/ffi_normal/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png
--------------------------------------------------------------------------------
/ffi_normal/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png
--------------------------------------------------------------------------------
/ffi_normal/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png
--------------------------------------------------------------------------------
/ffi_normal/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png
--------------------------------------------------------------------------------
/ffi_normal/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png
--------------------------------------------------------------------------------
/ffi_normal/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png
--------------------------------------------------------------------------------
/ffi_normal/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png
--------------------------------------------------------------------------------
/ffi_normal/example/macos/Runner/Configs/AppInfo.xcconfig:
--------------------------------------------------------------------------------
1 | // Application-level settings for the Runner target.
2 | //
3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the
4 | // future. If not, the values below would default to using the project name when this becomes a
5 | // 'flutter create' template.
6 |
7 | // The application's name. By default this is also the title of the Flutter window.
8 | PRODUCT_NAME = ffi_normal_example
9 |
10 | // The application's bundle identifier
11 | PRODUCT_BUNDLE_IDENTIFIER = com.xdd.ffiNormalExample
12 |
13 | // The copyright displayed in application information
14 | PRODUCT_COPYRIGHT = Copyright © 2022 com.xdd. All rights reserved.
15 |
--------------------------------------------------------------------------------
/ffi_normal/example/macos/Runner/Configs/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "../../Flutter/Flutter-Debug.xcconfig"
2 | #include "Warnings.xcconfig"
3 |
--------------------------------------------------------------------------------
/ffi_normal/example/macos/Runner/Configs/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "../../Flutter/Flutter-Release.xcconfig"
2 | #include "Warnings.xcconfig"
3 |
--------------------------------------------------------------------------------
/ffi_normal/example/macos/Runner/Configs/Warnings.xcconfig:
--------------------------------------------------------------------------------
1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings
2 | GCC_WARN_UNDECLARED_SELECTOR = YES
3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES
4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE
5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES
6 | CLANG_WARN_PRAGMA_PACK = YES
7 | CLANG_WARN_STRICT_PROTOTYPES = YES
8 | CLANG_WARN_COMMA = YES
9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES
10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
12 | GCC_WARN_SHADOW = YES
13 | CLANG_WARN_UNREACHABLE_CODE = YES
14 |
--------------------------------------------------------------------------------
/ffi_normal/example/macos/Runner/DebugProfile.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 | com.apple.security.cs.allow-jit
8 |
9 | com.apple.security.network.server
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/ffi_normal/example/macos/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | $(FLUTTER_BUILD_NAME)
21 | CFBundleVersion
22 | $(FLUTTER_BUILD_NUMBER)
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | $(PRODUCT_COPYRIGHT)
27 | NSMainNibFile
28 | MainMenu
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/ffi_normal/example/macos/Runner/MainFlutterWindow.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import FlutterMacOS
3 |
4 | class MainFlutterWindow: NSWindow {
5 | override func awakeFromNib() {
6 | let flutterViewController = FlutterViewController.init()
7 | let windowFrame = self.frame
8 | self.contentViewController = flutterViewController
9 | self.setFrame(windowFrame, display: true)
10 |
11 | RegisterGeneratedPlugins(registry: flutterViewController)
12 |
13 | super.awakeFromNib()
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/ffi_normal/example/macos/Runner/Release.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ffi_normal/example/test/widget_test.dart:
--------------------------------------------------------------------------------
1 | // This is a basic Flutter widget test.
2 | //
3 | // To perform an interaction with a widget in your test, use the WidgetTester
4 | // utility in the flutter_test package. For example, you can send tap and scroll
5 | // gestures. You can also use WidgetTester to find child widgets in the widget
6 | // tree, read text, and verify that the values of widget properties are correct.
7 |
8 | import 'package:flutter/material.dart';
9 | import 'package:flutter_test/flutter_test.dart';
10 |
11 | import 'package:ffi_normal_example/main.dart';
12 |
13 | void main() {
14 | testWidgets('Verify Platform version', (WidgetTester tester) async {
15 | // Build our app and trigger a frame.
16 | await tester.pumpWidget(const MyApp());
17 |
18 | // Verify that platform version is retrieved.
19 | expect(
20 | find.byWidgetPredicate(
21 | (Widget widget) => widget is Text &&
22 | widget.data!.startsWith('Running on:'),
23 | ),
24 | findsOneWidget,
25 | );
26 | });
27 | }
28 |
--------------------------------------------------------------------------------
/ffi_normal/example/web/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/web/favicon.png
--------------------------------------------------------------------------------
/ffi_normal/example/web/icons/Icon-192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/web/icons/Icon-192.png
--------------------------------------------------------------------------------
/ffi_normal/example/web/icons/Icon-512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/web/icons/Icon-512.png
--------------------------------------------------------------------------------
/ffi_normal/example/web/icons/Icon-maskable-192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/web/icons/Icon-maskable-192.png
--------------------------------------------------------------------------------
/ffi_normal/example/web/icons/Icon-maskable-512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/web/icons/Icon-maskable-512.png
--------------------------------------------------------------------------------
/ffi_normal/example/web/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | ffi_normal_example
33 |
34 |
35 |
39 |
40 |
41 |
42 |
43 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/ffi_normal/example/web/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ffi_normal_example",
3 | "short_name": "ffi_normal_example",
4 | "start_url": ".",
5 | "display": "standalone",
6 | "background_color": "#0175C2",
7 | "theme_color": "#0175C2",
8 | "description": "Demonstrates how to use the ffi_normal plugin.",
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 |
--------------------------------------------------------------------------------
/ffi_normal/example/windows/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/ephemeral/
2 |
3 | # Visual Studio user-specific files.
4 | *.suo
5 | *.user
6 | *.userosscache
7 | *.sln.docstates
8 |
9 | # Visual Studio build-related files.
10 | x64/
11 | x86/
12 |
13 | # Visual Studio cache files
14 | # files ending in .cache can be ignored
15 | *.[Cc]ache
16 | # but keep track of directories ending in .cache
17 | !*.[Cc]ache/
18 |
--------------------------------------------------------------------------------
/ffi_normal/example/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 |
11 | void RegisterPlugins(flutter::PluginRegistry* registry) {
12 | FfiNormalPluginCApiRegisterWithRegistrar(
13 | registry->GetRegistrarForPlugin("FfiNormalPluginCApi"));
14 | }
15 |
--------------------------------------------------------------------------------
/ffi_normal/example/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 |
--------------------------------------------------------------------------------
/ffi_normal/example/windows/flutter/generated_plugins.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Generated file, do not edit.
3 | #
4 |
5 | list(APPEND FLUTTER_PLUGIN_LIST
6 | ffi_normal
7 | )
8 |
9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST
10 | )
11 |
12 | set(PLUGIN_BUNDLED_LIBRARIES)
13 |
14 | foreach(plugin ${FLUTTER_PLUGIN_LIST})
15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin})
16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $)
18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
19 | endforeach(plugin)
20 |
21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
24 | endforeach(ffi_plugin)
25 |
--------------------------------------------------------------------------------
/ffi_normal/example/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 | # 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_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
37 |
38 | # Run the Flutter tool portions of the build. This must not be removed.
39 | add_dependencies(${BINARY_NAME} flutter_assemble)
40 |
--------------------------------------------------------------------------------
/ffi_normal/example/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 | return true;
30 | }
31 |
32 | void FlutterWindow::OnDestroy() {
33 | if (flutter_controller_) {
34 | flutter_controller_ = nullptr;
35 | }
36 |
37 | Win32Window::OnDestroy();
38 | }
39 |
40 | LRESULT
41 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message,
42 | WPARAM const wparam,
43 | LPARAM const lparam) noexcept {
44 | // Give Flutter, including plugins, an opportunity to handle window messages.
45 | if (flutter_controller_) {
46 | std::optional result =
47 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam,
48 | lparam);
49 | if (result) {
50 | return *result;
51 | }
52 | }
53 |
54 | switch (message) {
55 | case WM_FONTCHANGE:
56 | flutter_controller_->engine()->ReloadSystemFonts();
57 | break;
58 | }
59 |
60 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam);
61 | }
62 |
--------------------------------------------------------------------------------
/ffi_normal/example/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 |
--------------------------------------------------------------------------------
/ffi_normal/example/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 | Win32Window::Size size(1280, 720);
30 | if (!window.CreateAndShow(L"ffi_normal_example", 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 |
--------------------------------------------------------------------------------
/ffi_normal/example/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 |
--------------------------------------------------------------------------------
/ffi_normal/example/windows/runner/resources/app_icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/example/windows/runner/resources/app_icon.ico
--------------------------------------------------------------------------------
/ffi_normal/example/windows/runner/runner.exe.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PerMonitorV2
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/ffi_normal/example/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 | int target_length = ::WideCharToMultiByte(
49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
50 | -1, nullptr, 0, nullptr, nullptr);
51 | std::string utf8_string;
52 | if (target_length == 0 || target_length > utf8_string.max_size()) {
53 | return utf8_string;
54 | }
55 | utf8_string.resize(target_length);
56 | int converted_length = ::WideCharToMultiByte(
57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
58 | -1, utf8_string.data(),
59 | target_length, nullptr, nullptr);
60 | if (converted_length == 0) {
61 | return std::string();
62 | }
63 | return utf8_string;
64 | }
65 |
--------------------------------------------------------------------------------
/ffi_normal/example/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 |
--------------------------------------------------------------------------------
/ffi_normal/ios/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | .vagrant/
3 | .sconsign.dblite
4 | .svn/
5 |
6 | .DS_Store
7 | *.swp
8 | profile
9 |
10 | DerivedData/
11 | build/
12 | GeneratedPluginRegistrant.h
13 | GeneratedPluginRegistrant.m
14 |
15 | .generated/
16 |
17 | *.pbxuser
18 | *.mode1v3
19 | *.mode2v3
20 | *.perspectivev3
21 |
22 | !default.pbxuser
23 | !default.mode1v3
24 | !default.mode2v3
25 | !default.perspectivev3
26 |
27 | xcuserdata
28 |
29 | *.moved-aside
30 |
31 | *.pyc
32 | *sync/
33 | Icon?
34 | .tags*
35 |
36 | /Flutter/Generated.xcconfig
37 | /Flutter/ephemeral/
38 | /Flutter/flutter_export_environment.sh
--------------------------------------------------------------------------------
/ffi_normal/ios/Assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/ffi_normal/ios/Assets/.gitkeep
--------------------------------------------------------------------------------
/ffi_normal/ios/Classes/FfiNormalPlugin.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | @interface FfiNormalPlugin : NSObject
4 | @end
5 |
--------------------------------------------------------------------------------
/ffi_normal/ios/Classes/FfiNormalPlugin.m:
--------------------------------------------------------------------------------
1 | #import "FfiNormalPlugin.h"
2 | #if __has_include()
3 | #import
4 | #else
5 | // Support project import fallback if the generated compatibility header
6 | // is not copied when this plugin is created as a library.
7 | // https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816
8 | #import "ffi_normal-Swift.h"
9 | #endif
10 |
11 | @implementation FfiNormalPlugin
12 | + (void)registerWithRegistrar:(NSObject*)registrar {
13 | [SwiftFfiNormalPlugin registerWithRegistrar:registrar];
14 | }
15 | @end
16 |
--------------------------------------------------------------------------------
/ffi_normal/ios/Classes/SwiftFfiNormalPlugin.swift:
--------------------------------------------------------------------------------
1 | import Flutter
2 | import UIKit
3 |
4 | public class SwiftFfiNormalPlugin: NSObject, FlutterPlugin {
5 | public static func register(with registrar: FlutterPluginRegistrar) {
6 | let channel = FlutterMethodChannel(name: "ffi_normal", binaryMessenger: registrar.messenger())
7 | let instance = SwiftFfiNormalPlugin()
8 | registrar.addMethodCallDelegate(instance, channel: channel)
9 | }
10 |
11 | public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
12 | result("iOS " + UIDevice.current.systemVersion)
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ffi_normal/ios/Classes/native/dart_api/dart_api_dl.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
3 | * for details. All rights reserved. Use of this source code is governed by a
4 | * BSD-style license that can be found in the LICENSE file.
5 | */
6 |
7 | #include "dart_api_dl.h" /* NOLINT */
8 | #include "dart_version.h" /* NOLINT */
9 | #include "internal/dart_api_dl_impl.h" /* NOLINT */
10 |
11 | #include
12 |
13 | #define DART_API_DL_DEFINITIONS(name, R, A) name##_Type name##_DL = NULL;
14 |
15 | DART_API_ALL_DL_SYMBOLS(DART_API_DL_DEFINITIONS)
16 |
17 | #undef DART_API_DL_DEFINITIONS
18 |
19 | typedef void* DartApiEntry_function;
20 |
21 | DartApiEntry_function FindFunctionPointer(const DartApiEntry* entries,
22 | const char* name) {
23 | while (entries->name != NULL) {
24 | if (strcmp(entries->name, name) == 0) return entries->function;
25 | entries++;
26 | }
27 | return NULL;
28 | }
29 |
30 | intptr_t Dart_InitializeApiDL(void* data) {
31 | DartApi* dart_api_data = (DartApi*)data;
32 |
33 | if (dart_api_data->major != DART_API_DL_MAJOR_VERSION) {
34 | // If the DartVM we're running on does not have the same version as this
35 | // file was compiled against, refuse to initialize. The symbols are not
36 | // compatible.
37 | return -1;
38 | }
39 | // Minor versions are allowed to be different.
40 | // If the DartVM has a higher minor version, it will provide more symbols
41 | // than we initialize here.
42 | // If the DartVM has a lower minor version, it will not provide all symbols.
43 | // In that case, we leave the missing symbols un-initialized. Those symbols
44 | // should not be used by the Dart and native code. The client is responsible
45 | // for checking the minor version number himself based on which symbols it
46 | // is using.
47 | // (If we would error out on this case, recompiling native code against a
48 | // newer SDK would break all uses on older SDKs, which is too strict.)
49 |
50 | const DartApiEntry* dart_api_function_pointers = dart_api_data->functions;
51 |
52 | #define DART_API_DL_INIT(name, R, A) \
53 | name##_DL = \
54 | (name##_Type)(FindFunctionPointer(dart_api_function_pointers, #name));
55 | DART_API_ALL_DL_SYMBOLS(DART_API_DL_INIT)
56 | #undef DART_API_DL_INIT
57 |
58 | return 0;
59 | }
--------------------------------------------------------------------------------
/ffi_normal/ios/Classes/native/dart_api/dart_version.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
3 | * for details. All rights reserved. Use of this source code is governed by a
4 | * BSD-style license that can be found in the LICENSE file.
5 | */
6 |
7 | #ifndef RUNTIME_INCLUDE_DART_VERSION_H_
8 | #define RUNTIME_INCLUDE_DART_VERSION_H_
9 |
10 | // On breaking changes the major version is increased.
11 | // On backwards compatible changes the minor version is increased.
12 | // The versioning covers the symbols exposed in dart_api_dl.h
13 | #define DART_API_DL_MAJOR_VERSION 2
14 | #define DART_API_DL_MINOR_VERSION 0
15 |
16 | #endif /* RUNTIME_INCLUDE_DART_VERSION_H_ */ /* NOLINT */
--------------------------------------------------------------------------------
/ffi_normal/ios/Classes/native/dart_api/internal/dart_api_dl_impl.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
3 | * for details. All rights reserved. Use of this source code is governed by a
4 | * BSD-style license that can be found in the LICENSE file.
5 | */
6 |
7 | #ifndef RUNTIME_INCLUDE_INTERNAL_DART_API_DL_IMPL_H_
8 | #define RUNTIME_INCLUDE_INTERNAL_DART_API_DL_IMPL_H_
9 |
10 | typedef struct {
11 | const char* name;
12 | void (*function)();
13 | } DartApiEntry;
14 |
15 | typedef struct {
16 | const int major;
17 | const int minor;
18 | const DartApiEntry* const functions;
19 | } DartApi;
20 |
21 | #endif /* RUNTIME_INCLUDE_INTERNAL_DART_API_DL_IMPL_H_ */ /* NOLINT */
--------------------------------------------------------------------------------
/ffi_normal/ios/Classes/native/ffigen/add.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #ifdef WIN32
4 | #define DART_API extern "C" __declspec(dllexport)
5 | #else
6 | #define DART_API extern "C" __attribute__((visibility("default"))) __attribute__((used))
7 | #endif
8 |
9 | // DART_API int32_t twoNumAddGen(int32_t x, int32_t y){
10 | // return x + y;
11 | // }
12 |
13 | int32_t twoNumAddGen(int32_t x, int32_t y){
14 | return x + y;
15 | }
--------------------------------------------------------------------------------
/ffi_normal/ios/Classes/native/message_interaction.cpp:
--------------------------------------------------------------------------------
1 | // C
2 | #include
3 |
4 | // Unix
5 | #include
6 | #include
7 |
8 | #include "dart_api/dart_api.h"
9 | #include "dart_api/dart_native_api.h"
10 |
11 | #include "dart_api/dart_api_dl.h"
12 |
13 | // Initialize `dart_api_dl.h`
14 | DART_EXPORT intptr_t InitDartApiDL(void* data) {
15 | return Dart_InitializeApiDL(data);
16 | }
17 |
18 | Dart_Port send_port_;
19 |
20 | DART_EXPORT void RegisterSendPort(Dart_Port send_port) {
21 | send_port_ = send_port;
22 | }
23 |
24 | void *thread_func(void *args) {
25 | printf("thread_func Running on (%p)\n", pthread_self());
26 | sleep(2 /* seconds */); // doing something
27 |
28 | Dart_CObject dart_object;
29 | dart_object.type = Dart_CObject_kInt64;
30 | dart_object.value.as_int64 = reinterpret_cast(args);
31 | Dart_PostCObject_DL(send_port_, &dart_object);
32 |
33 | pthread_exit(args);
34 | }
35 |
36 | DART_EXPORT void NativeAsyncMessage(int32_t x) {
37 | printf("NativeAsyncCallback Running on (%p)\n", pthread_self());
38 |
39 | pthread_t message_thread;
40 | pthread_create(&message_thread, NULL, thread_func, (void *)&x);
41 | }
--------------------------------------------------------------------------------
/ffi_normal/ios/Classes/native/sync_callback.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #ifdef WIN32
5 | #define DART_API extern "C" __declspec(dllexport)
6 | #else
7 | #define DART_API extern "C" __attribute__((visibility("default"))) __attribute__((used))
8 | #endif
9 |
10 | using namespace std;
11 |
12 | // 定义传递的回调类型
13 | typedef int32_t (*NativeCallback)(int32_t n);
14 |
15 | DART_API void nativeSyncCallback(NativeCallback callback) {
16 | // 打印
17 | std::cout << "native log callback(666) = " << callback(666) << std::endl;
18 | }
--------------------------------------------------------------------------------
/ffi_normal/ios/Classes/native/sync_invoke.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #ifdef WIN32
4 | #define DART_API extern "C" __declspec(dllexport)
5 | #else
6 | #define DART_API extern "C" __attribute__((visibility("default"))) __attribute__((used))
7 | #endif
8 |
9 | DART_API int32_t twoNumAdd(int32_t x, int32_t y){
10 | return x + y;
11 | }
--------------------------------------------------------------------------------
/ffi_normal/ios/ffi_normal.podspec:
--------------------------------------------------------------------------------
1 | #
2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
3 | # Run `pod lib lint ffi_normal.podspec` to validate before publishing.
4 | #
5 | Pod::Spec.new do |s|
6 | s.name = 'ffi_normal'
7 | s.version = '0.0.1'
8 | s.summary = 'flutter ffi demo'
9 | s.description = <<-DESC
10 | flutter ffi demo
11 | DESC
12 | s.homepage = 'http://example.com'
13 | s.license = { :file => '../LICENSE' }
14 | s.author = { 'Your Company' => 'email@example.com' }
15 | s.source = { :path => '.' }
16 | s.source_files = 'Classes/**/*'
17 | s.dependency 'Flutter'
18 | s.platform = :ios, '9.0'
19 |
20 | # Flutter.framework does not contain a i386 slice.
21 | s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
22 | s.swift_version = '5.0'
23 | end
24 |
--------------------------------------------------------------------------------
/ffi_normal/lib/ffi_normal.dart:
--------------------------------------------------------------------------------
1 | library ffi_normal;
2 |
3 | export 'src/native_ffi.dart';
4 | export 'src/native_invoke.dart';
--------------------------------------------------------------------------------
/ffi_normal/lib/native/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # cmake_minimum_required 表示支持的 cmake 最小版本
2 | cmake_minimum_required(VERSION 3.4.1)
3 |
4 | # 项目名称
5 | if (WIN32)
6 | set(PROJECT_NAME "libnative_fun")
7 | else()
8 | set(PROJECT_NAME "native_fun")
9 | endif()
10 |
11 | # 批量添加cpp文件
12 | # add_library 关键字表示构建链接库,参数1是链接包名称; 参数2'SHARED'表示构建动态链接库; 参数2是源文件列表
13 | file(GLOB_RECURSE native_batch ../../macos/Classes/native/*)
14 | add_library(${PROJECT_NAME} SHARED ${native_batch})
15 |
16 | # Windows 需要把dll拷贝到bin目录
17 | if (WIN32)
18 | # 动态库的输出目录
19 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$<$:Debug>$<$:Release>")
20 | # 安装动态库的目标目录
21 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}")
22 | # 安装动态库,到执行目录
23 | install(FILES "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${PROJECT_NAME}.dll" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime)
24 | endif()
--------------------------------------------------------------------------------
/ffi_normal/lib/src/ffigen/two_num_add.dart:
--------------------------------------------------------------------------------
1 | // AUTO GENERATED FILE, DO NOT EDIT.
2 | //
3 | // Generated by `package:ffigen`.
4 | import 'dart:ffi' as ffi;
5 |
6 | class NativeLibrary {
7 | /// Holds the symbol lookup function.
8 | final ffi.Pointer Function(String symbolName)
9 | _lookup;
10 |
11 | /// The symbols are looked up in [dynamicLibrary].
12 | NativeLibrary(ffi.DynamicLibrary dynamicLibrary)
13 | : _lookup = dynamicLibrary.lookup;
14 |
15 | /// The symbols are looked up with [lookup].
16 | NativeLibrary.fromLookup(
17 | ffi.Pointer Function(String symbolName)
18 | lookup)
19 | : _lookup = lookup;
20 |
21 | int twoNumAddGen(
22 | int x,
23 | int y,
24 | ) {
25 | return _twoNumAddGen(
26 | x,
27 | y,
28 | );
29 | }
30 |
31 | late final _twoNumAddGenPtr =
32 | _lookup>(
33 | 'twoNumAddGen');
34 | late final _twoNumAddGen =
35 | _twoNumAddGenPtr.asFunction();
36 | }
37 |
--------------------------------------------------------------------------------
/ffi_normal/lib/src/native_ffi.dart:
--------------------------------------------------------------------------------
1 | import 'dart:ffi';
2 | import 'dart:io';
3 |
4 | class NativeFFI {
5 | NativeFFI._();
6 |
7 | static DynamicLibrary? _dyLib;
8 |
9 | static DynamicLibrary get dyLib {
10 | if (_dyLib != null) return _dyLib!;
11 |
12 | if (Platform.isMacOS || Platform.isIOS) {
13 | _dyLib = DynamicLibrary.process();
14 | } else if (Platform.isAndroid) {
15 | _dyLib = DynamicLibrary.open('libnative_fun.so');
16 | } else if (Platform.isWindows) {
17 | _dyLib = DynamicLibrary.open('libnative_fun.dll');
18 | } else {
19 | throw Exception('DynamicLibrary初始化失败');
20 | }
21 |
22 | return _dyLib!;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ffi_normal/lib/src/native_invoke.dart:
--------------------------------------------------------------------------------
1 | import '../ffi_normal.dart';
2 | import 'ffigen/two_num_add.dart';
3 | import 'native_use/message_interaction.dart';
4 | import 'native_use/sync_callback.dart';
5 | import 'native_use/sync_invoke.dart';
6 |
7 | class NativeInvoke {
8 | /// 同步触发
9 | static int addSyncInvoke(int a, int b) => ffiAddSyncInvoke(a, b);
10 |
11 | static int addSyncInvokeGen(int a, int b) => NativeLibrary(NativeFFI.dyLib).twoNumAddGen(a, b);
12 |
13 | /// 在native层打印回调传入的值
14 | static void printSyncCallback() => ffiPrintSyncCallback();
15 |
16 | static void asyncMsg(int a) => ffiAsyncMsg(a);
17 | }
18 |
--------------------------------------------------------------------------------
/ffi_normal/lib/src/native_use/message_interaction.dart:
--------------------------------------------------------------------------------
1 | import 'dart:async';
2 | import 'dart:ffi';
3 | import 'dart:isolate';
4 |
5 | import 'package:flutter/material.dart';
6 |
7 | import '../../ffi_normal.dart';
8 |
9 | ReceivePort? _receivePort;
10 | StreamSubscription? _subscription;
11 |
12 | void _ensureNativeInitialized() {
13 | if (_receivePort == null) {
14 | WidgetsFlutterBinding.ensureInitialized();
15 | final initializeApi = NativeFFI.dyLib.lookupFunction<
16 | IntPtr Function(Pointer),
17 | int Function(Pointer)>("InitDartApiDL");
18 | if (initializeApi(NativeApi.initializeApiDLData) != 0) {
19 | throw "Failed to initialize Dart API";
20 | }
21 |
22 | _receivePort = ReceivePort();
23 | _subscription = _receivePort!.listen(_handleNativeMessage);
24 | final registerSendPort = NativeFFI.dyLib.lookupFunction<
25 | Void Function(Int64 sendPort),
26 | void Function(int sendPort)>('RegisterSendPort');
27 | registerSendPort(_receivePort!.sendPort.nativePort);
28 | }
29 | }
30 |
31 | void _handleNativeMessage(dynamic address) {
32 | print('---------native端通信,地址: $address');
33 | Pointer point = Pointer.fromAddress(address);
34 | print('---------native端通信,指针: $point');
35 | dynamic data = point.cast();
36 | print('---------native端通信,cast: $data');
37 | }
38 |
39 | void ffiAsyncMsg(int a) {
40 | _ensureNativeInitialized();
41 | final void Function(int x) asyncMessage = NativeFFI.dyLib
42 | .lookup>("NativeAsyncMessage")
43 | .asFunction();
44 |
45 | asyncMessage(a);
46 | }
47 |
48 | void dispose() {
49 | // TODO _unregisterReceivePort(_receivePort.sendPort.nativePort);
50 | _subscription?.cancel();
51 | _receivePort?.close();
52 | }
53 |
--------------------------------------------------------------------------------
/ffi_normal/lib/src/native_use/sync_callback.dart:
--------------------------------------------------------------------------------
1 | import 'dart:ffi';
2 |
3 | import '../native_ffi.dart';
4 |
5 | /// 传递的回调
6 | typedef _NativeCallback = Int32 Function(Int32 num);
7 |
8 | /// Native方法
9 | typedef _NativeSyncCallback = Void Function(
10 | Pointer> callback,
11 | );
12 |
13 | /// Dart结束回调: Void和void不同,所以要区分开
14 | typedef _DartSyncCallback = void Function(
15 | Pointer> callback,
16 | );
17 |
18 | /// 必须使用顶层方法或者静态方法
19 | /// macos端可以打印出native层日志, 移动端只能打印dart日志
20 | int _syncCallback(int num) {
21 | print('--------');
22 | return num;
23 | }
24 |
25 | /// 在native层打印回调传入的值
26 | void ffiPrintSyncCallback() {
27 | final _DartSyncCallback dartSyncCallback = NativeFFI.dyLib
28 | .lookup>("nativeSyncCallback")
29 | .asFunction();
30 |
31 | // 包装传递的回调
32 | var syncFun = Pointer.fromFunction<_NativeCallback>(_syncCallback, 0);
33 | dartSyncCallback(syncFun);
34 | }
--------------------------------------------------------------------------------
/ffi_normal/lib/src/native_use/sync_invoke.dart:
--------------------------------------------------------------------------------
1 | import 'dart:ffi';
2 |
3 | import '../native_ffi.dart';
4 |
5 |
6 | /// 俩数相加
7 | int ffiAddSyncInvoke(int a, int b) {
8 | final int Function(int x, int y) nativeAdd = NativeFFI.dyLib
9 | .lookup>("twoNumAdd")
10 | .asFunction();
11 |
12 | return nativeAdd(a, b);
13 | }
14 |
--------------------------------------------------------------------------------
/ffi_normal/linux/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # The Flutter tooling requires that developers have CMake 3.10 or later
2 | # installed. You should not increase this version, as doing so will cause
3 | # the plugin to fail to compile for some customers of the plugin.
4 | cmake_minimum_required(VERSION 3.10)
5 |
6 | # Project-level configuration.
7 | set(PROJECT_NAME "ffi_normal")
8 | project(${PROJECT_NAME} LANGUAGES CXX)
9 |
10 | # This value is used when generating builds using this plugin, so it must
11 | # not be changed.
12 | set(PLUGIN_NAME "ffi_normal_plugin")
13 |
14 | # Define the plugin library target. Its name must not be changed (see comment
15 | # on PLUGIN_NAME above).
16 | #
17 | # Any new source files that you add to the plugin should be added here.
18 | add_library(${PLUGIN_NAME} SHARED
19 | "ffi_normal_plugin.cc"
20 | )
21 |
22 | # Apply a standard set of build settings that are configured in the
23 | # application-level CMakeLists.txt. This can be removed for plugins that want
24 | # full control over build settings.
25 | apply_standard_settings(${PLUGIN_NAME})
26 |
27 | # Symbols are hidden by default to reduce the chance of accidental conflicts
28 | # between plugins. This should not be removed; any symbols that should be
29 | # exported should be explicitly exported with the FLUTTER_PLUGIN_EXPORT macro.
30 | set_target_properties(${PLUGIN_NAME} PROPERTIES
31 | CXX_VISIBILITY_PRESET hidden)
32 | target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
33 |
34 | # Source include directories and library dependencies. Add any plugin-specific
35 | # dependencies here.
36 | target_include_directories(${PLUGIN_NAME} INTERFACE
37 | "${CMAKE_CURRENT_SOURCE_DIR}/include")
38 | target_link_libraries(${PLUGIN_NAME} PRIVATE flutter)
39 | target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK)
40 |
41 | # List of absolute paths to libraries that should be bundled with the plugin.
42 | # This list could contain prebuilt libraries, or libraries created by an
43 | # external build triggered from this build file.
44 | set(ffi_normal_bundled_libraries
45 | ""
46 | PARENT_SCOPE
47 | )
48 |
49 | # -------------------------统一CMakeList.txt文件-------------------------
50 | add_subdirectory("../lib/native" native)
--------------------------------------------------------------------------------
/ffi_normal/linux/ffi_normal_plugin.cc:
--------------------------------------------------------------------------------
1 | #include "include/ffi_normal/ffi_normal_plugin.h"
2 |
3 | #include
4 | #include
5 | #include
6 |
7 | #include
8 |
9 | #define FFI_NORMAL_PLUGIN(obj) \
10 | (G_TYPE_CHECK_INSTANCE_CAST((obj), ffi_normal_plugin_get_type(), \
11 | FfiNormalPlugin))
12 |
13 | struct _FfiNormalPlugin {
14 | GObject parent_instance;
15 | };
16 |
17 | G_DEFINE_TYPE(FfiNormalPlugin, ffi_normal_plugin, g_object_get_type())
18 |
19 | // Called when a method call is received from Flutter.
20 | static void ffi_normal_plugin_handle_method_call(
21 | FfiNormalPlugin* self,
22 | FlMethodCall* method_call) {
23 | g_autoptr(FlMethodResponse) response = nullptr;
24 |
25 | const gchar* method = fl_method_call_get_name(method_call);
26 |
27 | if (strcmp(method, "getPlatformVersion") == 0) {
28 | struct utsname uname_data = {};
29 | uname(&uname_data);
30 | g_autofree gchar *version = g_strdup_printf("Linux %s", uname_data.version);
31 | g_autoptr(FlValue) result = fl_value_new_string(version);
32 | response = FL_METHOD_RESPONSE(fl_method_success_response_new(result));
33 | } else {
34 | response = FL_METHOD_RESPONSE(fl_method_not_implemented_response_new());
35 | }
36 |
37 | fl_method_call_respond(method_call, response, nullptr);
38 | }
39 |
40 | static void ffi_normal_plugin_dispose(GObject* object) {
41 | G_OBJECT_CLASS(ffi_normal_plugin_parent_class)->dispose(object);
42 | }
43 |
44 | static void ffi_normal_plugin_class_init(FfiNormalPluginClass* klass) {
45 | G_OBJECT_CLASS(klass)->dispose = ffi_normal_plugin_dispose;
46 | }
47 |
48 | static void ffi_normal_plugin_init(FfiNormalPlugin* self) {}
49 |
50 | static void method_call_cb(FlMethodChannel* channel, FlMethodCall* method_call,
51 | gpointer user_data) {
52 | FfiNormalPlugin* plugin = FFI_NORMAL_PLUGIN(user_data);
53 | ffi_normal_plugin_handle_method_call(plugin, method_call);
54 | }
55 |
56 | void ffi_normal_plugin_register_with_registrar(FlPluginRegistrar* registrar) {
57 | FfiNormalPlugin* plugin = FFI_NORMAL_PLUGIN(
58 | g_object_new(ffi_normal_plugin_get_type(), nullptr));
59 |
60 | g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
61 | g_autoptr(FlMethodChannel) channel =
62 | fl_method_channel_new(fl_plugin_registrar_get_messenger(registrar),
63 | "ffi_normal",
64 | FL_METHOD_CODEC(codec));
65 | fl_method_channel_set_method_call_handler(channel, method_call_cb,
66 | g_object_ref(plugin),
67 | g_object_unref);
68 |
69 | g_object_unref(plugin);
70 | }
71 |
--------------------------------------------------------------------------------
/ffi_normal/linux/include/ffi_normal/ffi_normal_plugin.h:
--------------------------------------------------------------------------------
1 | #ifndef FLUTTER_PLUGIN_FFI_NORMAL_PLUGIN_H_
2 | #define FLUTTER_PLUGIN_FFI_NORMAL_PLUGIN_H_
3 |
4 | #include
5 |
6 | G_BEGIN_DECLS
7 |
8 | #ifdef FLUTTER_PLUGIN_IMPL
9 | #define FLUTTER_PLUGIN_EXPORT __attribute__((visibility("default")))
10 | #else
11 | #define FLUTTER_PLUGIN_EXPORT
12 | #endif
13 |
14 | typedef struct _FfiNormalPlugin FfiNormalPlugin;
15 | typedef struct {
16 | GObjectClass parent_class;
17 | } FfiNormalPluginClass;
18 |
19 | FLUTTER_PLUGIN_EXPORT GType ffi_normal_plugin_get_type();
20 |
21 | FLUTTER_PLUGIN_EXPORT void ffi_normal_plugin_register_with_registrar(
22 | FlPluginRegistrar* registrar);
23 |
24 | G_END_DECLS
25 |
26 | #endif // FLUTTER_PLUGIN_FFI_NORMAL_PLUGIN_H_
27 |
--------------------------------------------------------------------------------
/ffi_normal/macos/Classes/FfiNormalPlugin.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import FlutterMacOS
3 |
4 | public class FfiNormalPlugin: NSObject, FlutterPlugin {
5 | public static func register(with registrar: FlutterPluginRegistrar) {
6 | let channel = FlutterMethodChannel(name: "ffi_normal", binaryMessenger: registrar.messenger)
7 | let instance = FfiNormalPlugin()
8 | registrar.addMethodCallDelegate(instance, channel: channel)
9 | }
10 |
11 | public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
12 | switch call.method {
13 | case "getPlatformVersion":
14 | result("macOS " + ProcessInfo.processInfo.operatingSystemVersionString)
15 | default:
16 | result(FlutterMethodNotImplemented)
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ffi_normal/macos/Classes/native/ffigen/add.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #ifdef WIN32
4 | #define DART_API extern "C" __declspec(dllexport)
5 | #else
6 | #define DART_API extern "C" __attribute__((visibility("default"))) __attribute__((used))
7 | #endif
8 |
9 | // DART_API int32_t twoNumAddGen(int32_t x, int32_t y){
10 | // return x + y;
11 | // }
12 |
13 | int32_t twoNumAddGen(int32_t x, int32_t y){
14 | return x + y;
15 | }
--------------------------------------------------------------------------------
/ffi_normal/macos/Classes/native/sync_callback.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #ifdef WIN32
5 | #define DART_API extern "C" __declspec(dllexport)
6 | #else
7 | #define DART_API extern "C" __attribute__((visibility("default"))) __attribute__((used))
8 | #endif
9 |
10 | using namespace std;
11 |
12 | // 定义传递的回调类型
13 | typedef int32_t (*NativeCallback)(int32_t n);
14 |
15 | DART_API void nativeSyncCallback(NativeCallback callback) {
16 | // 打印
17 | std::cout << "native log callback(666) = " << callback(666) << std::endl;
18 | }
--------------------------------------------------------------------------------
/ffi_normal/macos/Classes/native/sync_invoke.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #ifdef WIN32
4 | #define DART_API extern "C" __declspec(dllexport)
5 | #else
6 | #define DART_API extern "C" __attribute__((visibility("default"))) __attribute__((used))
7 | #endif
8 |
9 | DART_API int32_t twoNumAdd(int32_t x, int32_t y){
10 | return x + y;
11 | }
--------------------------------------------------------------------------------
/ffi_normal/macos/ffi_normal.podspec:
--------------------------------------------------------------------------------
1 | #
2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
3 | # Run `pod lib lint ffi_normal.podspec` to validate before publishing.
4 | #
5 | Pod::Spec.new do |s|
6 | s.name = 'ffi_normal'
7 | s.version = '0.0.1'
8 | s.summary = 'flutter ffi demo'
9 | s.description = <<-DESC
10 | flutter ffi demo
11 | DESC
12 | s.homepage = 'http://example.com'
13 | s.license = { :file => '../LICENSE' }
14 | s.author = { 'Your Company' => 'email@example.com' }
15 |
16 | s.source = { :path => '.' }
17 | s.source_files = 'Classes/**/*'
18 | s.dependency 'FlutterMacOS'
19 |
20 | s.platform = :osx, '10.11'
21 | s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
22 | s.swift_version = '5.0'
23 | end
24 |
--------------------------------------------------------------------------------
/ffi_normal/windows/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/
2 |
3 | # Visual Studio user-specific files.
4 | *.suo
5 | *.user
6 | *.userosscache
7 | *.sln.docstates
8 |
9 | # Visual Studio build-related files.
10 | x64/
11 | x86/
12 |
13 | # Visual Studio cache files
14 | # files ending in .cache can be ignored
15 | *.[Cc]ache
16 | # but keep track of directories ending in .cache
17 | !*.[Cc]ache/
18 |
--------------------------------------------------------------------------------
/ffi_normal/windows/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # The Flutter tooling requires that developers have a version of Visual Studio
2 | # installed that includes CMake 3.14 or later. You should not increase this
3 | # version, as doing so will cause the plugin to fail to compile for some
4 | # customers of the plugin.
5 | cmake_minimum_required(VERSION 3.14)
6 |
7 | # Project-level configuration.
8 | set(PROJECT_NAME "ffi_normal")
9 | project(${PROJECT_NAME} LANGUAGES CXX)
10 |
11 | # This value is used when generating builds using this plugin, so it must
12 | # not be changed
13 | set(PLUGIN_NAME "ffi_normal_plugin")
14 |
15 | # Any new source files that you add to the plugin should be added here.
16 | list(APPEND PLUGIN_SOURCES
17 | "ffi_normal_plugin.cpp"
18 | "ffi_normal_plugin.h"
19 | )
20 |
21 | # Define the plugin library target. Its name must not be changed (see comment
22 | # on PLUGIN_NAME above).
23 | add_library(${PLUGIN_NAME} SHARED
24 | "include/ffi_normal/ffi_normal_plugin_c_api.h"
25 | "ffi_normal_plugin_c_api.cpp"
26 | ${PLUGIN_SOURCES}
27 | )
28 |
29 | # Apply a standard set of build settings that are configured in the
30 | # application-level CMakeLists.txt. This can be removed for plugins that want
31 | # full control over build settings.
32 | apply_standard_settings(${PLUGIN_NAME})
33 |
34 | # Symbols are hidden by default to reduce the chance of accidental conflicts
35 | # between plugins. This should not be removed; any symbols that should be
36 | # exported should be explicitly exported with the FLUTTER_PLUGIN_EXPORT macro.
37 | set_target_properties(${PLUGIN_NAME} PROPERTIES
38 | CXX_VISIBILITY_PRESET hidden)
39 | target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
40 |
41 | # Source include directories and library dependencies. Add any plugin-specific
42 | # dependencies here.
43 | target_include_directories(${PLUGIN_NAME} INTERFACE
44 | "${CMAKE_CURRENT_SOURCE_DIR}/include")
45 | target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin)
46 |
47 | # List of absolute paths to libraries that should be bundled with the plugin.
48 | # This list could contain prebuilt libraries, or libraries created by an
49 | # external build triggered from this build file.
50 | set(ffi_normal_bundled_libraries
51 | ""
52 | PARENT_SCOPE
53 | )
54 |
55 | # -------------------------统一CMakeList.txt文件-------------------------
56 | add_subdirectory("../lib/native" native)
57 |
58 |
--------------------------------------------------------------------------------
/ffi_normal/windows/ffi_normal_plugin.cpp:
--------------------------------------------------------------------------------
1 | #include "ffi_normal_plugin.h"
2 |
3 | // This must be included before many other Windows headers.
4 | #include
5 |
6 | // For getPlatformVersion; remove unless needed for your plugin implementation.
7 | #include
8 |
9 | #include
10 | #include
11 | #include
12 |
13 | #include
14 | #include
15 |
16 | namespace ffi_normal {
17 |
18 | // static
19 | void FfiNormalPlugin::RegisterWithRegistrar(
20 | flutter::PluginRegistrarWindows *registrar) {
21 | auto channel =
22 | std::make_unique>(
23 | registrar->messenger(), "ffi_normal",
24 | &flutter::StandardMethodCodec::GetInstance());
25 |
26 | auto plugin = std::make_unique();
27 |
28 | channel->SetMethodCallHandler(
29 | [plugin_pointer = plugin.get()](const auto &call, auto result) {
30 | plugin_pointer->HandleMethodCall(call, std::move(result));
31 | });
32 |
33 | registrar->AddPlugin(std::move(plugin));
34 | }
35 |
36 | FfiNormalPlugin::FfiNormalPlugin() {}
37 |
38 | FfiNormalPlugin::~FfiNormalPlugin() {}
39 |
40 | void FfiNormalPlugin::HandleMethodCall(
41 | const flutter::MethodCall &method_call,
42 | std::unique_ptr> result) {
43 | if (method_call.method_name().compare("getPlatformVersion") == 0) {
44 | std::ostringstream version_stream;
45 | version_stream << "Windows ";
46 | if (IsWindows10OrGreater()) {
47 | version_stream << "10+";
48 | } else if (IsWindows8OrGreater()) {
49 | version_stream << "8";
50 | } else if (IsWindows7OrGreater()) {
51 | version_stream << "7";
52 | }
53 | result->Success(flutter::EncodableValue(version_stream.str()));
54 | } else {
55 | result->NotImplemented();
56 | }
57 | }
58 |
59 | } // namespace ffi_normal
60 |
--------------------------------------------------------------------------------
/ffi_normal/windows/ffi_normal_plugin.h:
--------------------------------------------------------------------------------
1 | #ifndef FLUTTER_PLUGIN_FFI_NORMAL_PLUGIN_H_
2 | #define FLUTTER_PLUGIN_FFI_NORMAL_PLUGIN_H_
3 |
4 | #include
5 | #include
6 |
7 | #include
8 |
9 | namespace ffi_normal {
10 |
11 | class FfiNormalPlugin : public flutter::Plugin {
12 | public:
13 | static void RegisterWithRegistrar(flutter::PluginRegistrarWindows *registrar);
14 |
15 | FfiNormalPlugin();
16 |
17 | virtual ~FfiNormalPlugin();
18 |
19 | // Disallow copy and assign.
20 | FfiNormalPlugin(const FfiNormalPlugin&) = delete;
21 | FfiNormalPlugin& operator=(const FfiNormalPlugin&) = delete;
22 |
23 | private:
24 | // Called when a method is called on this plugin's channel from Dart.
25 | void HandleMethodCall(
26 | const flutter::MethodCall &method_call,
27 | std::unique_ptr> result);
28 | };
29 |
30 | } // namespace ffi_normal
31 |
32 | #endif // FLUTTER_PLUGIN_FFI_NORMAL_PLUGIN_H_
33 |
--------------------------------------------------------------------------------
/ffi_normal/windows/ffi_normal_plugin_c_api.cpp:
--------------------------------------------------------------------------------
1 | #include "include/ffi_normal/ffi_normal_plugin_c_api.h"
2 |
3 | #include
4 |
5 | #include "ffi_normal_plugin.h"
6 |
7 | void FfiNormalPluginCApiRegisterWithRegistrar(
8 | FlutterDesktopPluginRegistrarRef registrar) {
9 | ffi_normal::FfiNormalPlugin::RegisterWithRegistrar(
10 | flutter::PluginRegistrarManager::GetInstance()
11 | ->GetRegistrar(registrar));
12 | }
13 |
--------------------------------------------------------------------------------
/ffi_normal/windows/include/ffi_normal/ffi_normal_plugin_c_api.h:
--------------------------------------------------------------------------------
1 | #ifndef FLUTTER_PLUGIN_FFI_NORMAL_PLUGIN_C_API_H_
2 | #define FLUTTER_PLUGIN_FFI_NORMAL_PLUGIN_C_API_H_
3 |
4 | #include
5 |
6 | #ifdef FLUTTER_PLUGIN_IMPL
7 | #define FLUTTER_PLUGIN_EXPORT __declspec(dllexport)
8 | #else
9 | #define FLUTTER_PLUGIN_EXPORT __declspec(dllimport)
10 | #endif
11 |
12 | #if defined(__cplusplus)
13 | extern "C" {
14 | #endif
15 |
16 | FLUTTER_PLUGIN_EXPORT void FfiNormalPluginCApiRegisterWithRegistrar(
17 | FlutterDesktopPluginRegistrarRef registrar);
18 |
19 | #if defined(__cplusplus)
20 | } // extern "C"
21 | #endif
22 |
23 | #endif // FLUTTER_PLUGIN_FFI_NORMAL_PLUGIN_C_API_H_
24 |
--------------------------------------------------------------------------------
/rust_bridge/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 | migrate_working_dir/
12 |
13 | # IntelliJ related
14 | *.iml
15 | *.ipr
16 | *.iws
17 | .idea/
18 |
19 | # The .vscode folder contains launch configuration and tasks you configure in
20 | # VS Code which you may wish to be included in version control, so this line
21 | # is commented out by default.
22 | #.vscode/
23 |
24 | # Flutter/Dart/Pub related
25 | **/doc/api/
26 | **/ios/Flutter/.last_build_id
27 | .dart_tool/
28 | .flutter-plugins
29 | .flutter-plugins-dependencies
30 | .packages
31 | .pub-cache/
32 | .pub/
33 | /build/
34 |
35 | # Symbolication related
36 | app.*.symbols
37 |
38 | # Obfuscation related
39 | app.*.map.json
40 |
41 | # Android Studio will place build artifacts here
42 | /android/app/debug
43 | /android/app/profile
44 | /android/app/release
45 | pubspec.lock
46 | rust/target/
--------------------------------------------------------------------------------
/rust_bridge/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled.
5 |
6 | version:
7 | revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
8 | channel: stable
9 |
10 | project_type: app
11 |
12 | # Tracks metadata for the flutter migrate command
13 | migration:
14 | platforms:
15 | - platform: root
16 | create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
17 | base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
18 | - platform: android
19 | create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
20 | base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
21 | - platform: ios
22 | create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
23 | base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
24 | - platform: linux
25 | create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
26 | base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
27 | - platform: macos
28 | create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
29 | base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
30 | - platform: web
31 | create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
32 | base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
33 | - platform: windows
34 | create_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
35 | base_revision: b8f7f1f9869bb2d116aa6a70dbeac61000b52849
36 |
37 | # User provided section
38 |
39 | # List of Local paths (relative to this file) that should be
40 | # ignored by the migrate tool.
41 | #
42 | # Files that are not part of the templates will be ignored by default.
43 | unmanaged_files:
44 | - 'lib/main.dart'
45 | - 'ios/Runner.xcodeproj/project.pbxproj'
46 |
--------------------------------------------------------------------------------
/rust_bridge/README.md:
--------------------------------------------------------------------------------
1 | # rust_bridge
2 |
3 | flutter_rust_bridge demo
4 |
5 | ## Getting Started
6 |
7 | This project is a starting point for a Flutter application.
8 |
9 | A few resources to get you started if this is your first Flutter project:
10 |
11 | - [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
12 | - [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
13 |
14 | For help getting started with Flutter development, view the
15 | [online documentation](https://docs.flutter.dev/), which offers tutorials,
16 | samples, guidance on mobile development, and a full API reference.
17 |
--------------------------------------------------------------------------------
/rust_bridge/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | # This file configures the analyzer, which statically analyzes Dart code to
2 | # check for errors, warnings, and lints.
3 | #
4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6 | # invoked from the command line by running `flutter analyze`.
7 |
8 | # The following line activates a set of recommended lints for Flutter apps,
9 | # packages, and plugins designed to encourage good coding practices.
10 | include: package:flutter_lints/flutter.yaml
11 |
12 | linter:
13 | # The lint rules applied to this project can be customized in the
14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml`
15 | # included above or to enable additional rules. A list of all available lints
16 | # and their documentation is published at
17 | # https://dart-lang.github.io/linter/lints/index.html.
18 | #
19 | # Instead of disabling a lint rule for the entire project in the
20 | # section below, it can also be suppressed for a single line of code
21 | # or a specific dart file by using the `// ignore: name_of_lint` and
22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file
23 | # producing the lint.
24 | rules:
25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule
26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
27 |
28 | # Additional information about this file can be found at
29 | # https://dart.dev/guides/language/analysis-options
30 |
--------------------------------------------------------------------------------
/rust_bridge/android/.gitignore:
--------------------------------------------------------------------------------
1 | gradle-wrapper.jar
2 | /.gradle
3 | /captures/
4 | /gradlew
5 | /gradlew.bat
6 | /local.properties
7 | GeneratedPluginRegistrant.java
8 |
9 | # Remember to never publicly share your keystore.
10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
11 | key.properties
12 | **/*.keystore
13 | **/*.jks
14 |
--------------------------------------------------------------------------------
/rust_bridge/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/rust_bridge/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
7 |
15 |
19 |
23 |
24 |
25 |
26 |
27 |
28 |
30 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/rust_bridge/android/app/src/main/jniLibs/arm64-v8a/librust_ffi.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/android/app/src/main/jniLibs/arm64-v8a/librust_ffi.so
--------------------------------------------------------------------------------
/rust_bridge/android/app/src/main/jniLibs/armeabi-v7a/librust_ffi.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/android/app/src/main/jniLibs/armeabi-v7a/librust_ffi.so
--------------------------------------------------------------------------------
/rust_bridge/android/app/src/main/jniLibs/x86/librust_ffi.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/android/app/src/main/jniLibs/x86/librust_ffi.so
--------------------------------------------------------------------------------
/rust_bridge/android/app/src/main/jniLibs/x86_64/librust_ffi.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/android/app/src/main/jniLibs/x86_64/librust_ffi.so
--------------------------------------------------------------------------------
/rust_bridge/android/app/src/main/kotlin/com/xdd/rust_bridge/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.xdd.rust_bridge
2 |
3 | import io.flutter.embedding.android.FlutterActivity
4 |
5 | class MainActivity: FlutterActivity() {
6 | }
7 |
--------------------------------------------------------------------------------
/rust_bridge/android/app/src/main/res/drawable-v21/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/rust_bridge/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/rust_bridge/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/rust_bridge/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/rust_bridge/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/rust_bridge/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/rust_bridge/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/rust_bridge/android/app/src/main/res/values-night/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/rust_bridge/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/rust_bridge/android/app/src/profile/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/rust_bridge/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext.kotlin_version = '1.6.10'
3 | repositories {
4 | google()
5 | mavenCentral()
6 | }
7 |
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:7.1.2'
10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11 | }
12 | }
13 |
14 | allprojects {
15 | repositories {
16 | google()
17 | mavenCentral()
18 | }
19 | }
20 |
21 | rootProject.buildDir = '../build'
22 | subprojects {
23 | project.buildDir = "${rootProject.buildDir}/${project.name}"
24 | }
25 | subprojects {
26 | project.evaluationDependsOn(':app')
27 | }
28 |
29 | task clean(type: Delete) {
30 | delete rootProject.buildDir
31 | }
--------------------------------------------------------------------------------
/rust_bridge/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.useAndroidX=true
3 | android.enableJetifier=true
4 | #ANDROID_NDK=F:\\SDK\\AndroidSDK\\ndk\\21.3.6528147
5 | ANDROID_NDK=/Users/xdd666/Develop/SDK/android_sdk/ndk/21.3.6528147
--------------------------------------------------------------------------------
/rust_bridge/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.4-all.zip
6 |
--------------------------------------------------------------------------------
/rust_bridge/android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
4 | def properties = new Properties()
5 |
6 | assert localPropertiesFile.exists()
7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
8 |
9 | def flutterSdkPath = properties.getProperty("flutter.sdk")
10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
12 |
--------------------------------------------------------------------------------
/rust_bridge/ios/.gitignore:
--------------------------------------------------------------------------------
1 | **/dgph
2 | *.mode1v3
3 | *.mode2v3
4 | *.moved-aside
5 | *.pbxuser
6 | *.perspectivev3
7 | **/*sync/
8 | .sconsign.dblite
9 | .tags*
10 | **/.vagrant/
11 | **/DerivedData/
12 | Icon?
13 | **/Pods/
14 | **/.symlinks/
15 | profile
16 | xcuserdata
17 | **/.generated/
18 | Flutter/App.framework
19 | Flutter/Flutter.framework
20 | Flutter/Flutter.podspec
21 | Flutter/Generated.xcconfig
22 | Flutter/ephemeral/
23 | Flutter/app.flx
24 | Flutter/app.zip
25 | Flutter/flutter_assets/
26 | Flutter/flutter_export_environment.sh
27 | ServiceDefinitions.json
28 | Runner/GeneratedPluginRegistrant.*
29 |
30 | # Exceptions to above rules.
31 | !default.mode1v3
32 | !default.mode2v3
33 | !default.pbxuser
34 | !default.perspectivev3
35 |
--------------------------------------------------------------------------------
/rust_bridge/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | App
9 | CFBundleIdentifier
10 | io.flutter.flutter.app
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | App
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | MinimumOSVersion
24 | 11.0
25 |
26 |
27 |
--------------------------------------------------------------------------------
/rust_bridge/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/rust_bridge/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 | import Flutter
3 |
4 | @UIApplicationMain
5 | @objc class AppDelegate: FlutterAppDelegate {
6 | override func application(
7 | _ application: UIApplication,
8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
9 | ) -> Bool {
10 | let dummy = dummy_method_to_enforce_bundling()
11 | print(dummy)
12 | GeneratedPluginRegistrant.register(with: self)
13 | return super.application(application, didFinishLaunchingWithOptions: launchOptions)
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "20x20",
5 | "idiom" : "iphone",
6 | "filename" : "Icon-App-20x20@2x.png",
7 | "scale" : "2x"
8 | },
9 | {
10 | "size" : "20x20",
11 | "idiom" : "iphone",
12 | "filename" : "Icon-App-20x20@3x.png",
13 | "scale" : "3x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "Icon-App-29x29@1x.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "29x29",
23 | "idiom" : "iphone",
24 | "filename" : "Icon-App-29x29@2x.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "29x29",
29 | "idiom" : "iphone",
30 | "filename" : "Icon-App-29x29@3x.png",
31 | "scale" : "3x"
32 | },
33 | {
34 | "size" : "40x40",
35 | "idiom" : "iphone",
36 | "filename" : "Icon-App-40x40@2x.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "40x40",
41 | "idiom" : "iphone",
42 | "filename" : "Icon-App-40x40@3x.png",
43 | "scale" : "3x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "Icon-App-60x60@2x.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "60x60",
53 | "idiom" : "iphone",
54 | "filename" : "Icon-App-60x60@3x.png",
55 | "scale" : "3x"
56 | },
57 | {
58 | "size" : "20x20",
59 | "idiom" : "ipad",
60 | "filename" : "Icon-App-20x20@1x.png",
61 | "scale" : "1x"
62 | },
63 | {
64 | "size" : "20x20",
65 | "idiom" : "ipad",
66 | "filename" : "Icon-App-20x20@2x.png",
67 | "scale" : "2x"
68 | },
69 | {
70 | "size" : "29x29",
71 | "idiom" : "ipad",
72 | "filename" : "Icon-App-29x29@1x.png",
73 | "scale" : "1x"
74 | },
75 | {
76 | "size" : "29x29",
77 | "idiom" : "ipad",
78 | "filename" : "Icon-App-29x29@2x.png",
79 | "scale" : "2x"
80 | },
81 | {
82 | "size" : "40x40",
83 | "idiom" : "ipad",
84 | "filename" : "Icon-App-40x40@1x.png",
85 | "scale" : "1x"
86 | },
87 | {
88 | "size" : "40x40",
89 | "idiom" : "ipad",
90 | "filename" : "Icon-App-40x40@2x.png",
91 | "scale" : "2x"
92 | },
93 | {
94 | "size" : "76x76",
95 | "idiom" : "ipad",
96 | "filename" : "Icon-App-76x76@1x.png",
97 | "scale" : "1x"
98 | },
99 | {
100 | "size" : "76x76",
101 | "idiom" : "ipad",
102 | "filename" : "Icon-App-76x76@2x.png",
103 | "scale" : "2x"
104 | },
105 | {
106 | "size" : "83.5x83.5",
107 | "idiom" : "ipad",
108 | "filename" : "Icon-App-83.5x83.5@2x.png",
109 | "scale" : "2x"
110 | },
111 | {
112 | "size" : "1024x1024",
113 | "idiom" : "ios-marketing",
114 | "filename" : "Icon-App-1024x1024@1x.png",
115 | "scale" : "1x"
116 | }
117 | ],
118 | "info" : {
119 | "version" : 1,
120 | "author" : "xcode"
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchImage.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchImage@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "LaunchImage@3x.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md:
--------------------------------------------------------------------------------
1 | # Launch Screen Assets
2 |
3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory.
4 |
5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleDisplayName
8 | Rust Bridge
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | rust_bridge
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | $(FLUTTER_BUILD_NAME)
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | $(FLUTTER_BUILD_NUMBER)
25 | LSRequiresIPhoneOS
26 |
27 | UILaunchStoryboardName
28 | LaunchScreen
29 | UIMainStoryboardFile
30 | Main
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 | UIViewControllerBasedStatusBarAppearance
45 |
46 | CADisableMinimumFrameDurationOnPhone
47 |
48 | UIApplicationSupportsIndirectInputEvents
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner/Runner-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | #import "GeneratedPluginRegistrant.h"
2 | #import "bridge_generated.h"
--------------------------------------------------------------------------------
/rust_bridge/ios/Runner/bridge_generated.h:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | typedef int64_t DartPort;
6 |
7 | typedef bool (*DartPostCObjectFnType)(DartPort port_id, void *message);
8 |
9 | typedef struct WireSyncReturnStruct {
10 | uint8_t *ptr;
11 | int32_t len;
12 | bool success;
13 | } WireSyncReturnStruct;
14 |
15 | void store_dart_post_cobject(DartPostCObjectFnType ptr);
16 |
17 | void wire_add(int64_t port_, uintptr_t left, uintptr_t right);
18 |
19 | void free_WireSyncReturnStruct(struct WireSyncReturnStruct val);
20 |
21 | static int64_t dummy_method_to_enforce_bundling(void) {
22 | int64_t dummy_var = 0;
23 | dummy_var ^= ((int64_t) (void*) wire_add);
24 | dummy_var ^= ((int64_t) (void*) free_WireSyncReturnStruct);
25 | dummy_var ^= ((int64_t) (void*) store_dart_post_cobject);
26 | return dummy_var;
27 | }
--------------------------------------------------------------------------------
/rust_bridge/lib/ffi/native_ffi.dart:
--------------------------------------------------------------------------------
1 | import 'dart:ffi';
2 | import 'dart:io';
3 |
4 | class NativeFFI {
5 | NativeFFI._();
6 |
7 | static DynamicLibrary? _dyLib;
8 |
9 | static DynamicLibrary get dyLib {
10 | if (_dyLib != null) return _dyLib!;
11 |
12 | const base = 'rust_ffi';
13 | if (Platform.isIOS) {
14 | _dyLib = DynamicLibrary.process();
15 | } else if (Platform.isMacOS) {
16 | _dyLib = DynamicLibrary.executable();
17 | } else if (Platform.isAndroid) {
18 | _dyLib = DynamicLibrary.open('lib$base.so');
19 | } else if (Platform.isWindows) {
20 | _dyLib = DynamicLibrary.open('$base.dll');
21 | } else {
22 | throw Exception('DynamicLibrary初始化失败');
23 | }
24 |
25 | return _dyLib!;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/rust_bridge/lib/ffi/native_fun.dart:
--------------------------------------------------------------------------------
1 | import 'package:rust_bridge/ffi/native_ffi.dart';
2 | import 'package:rust_bridge/ffi/rust_ffi/rust_ffi.dart';
3 |
4 | class NativeFun {
5 | static final _ffi = RustFfiImpl(NativeFFI.dyLib);
6 |
7 | static Future add(int left, int right) async {
8 | int sum = await _ffi.add(left: left, right: right);
9 | return sum;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/rust_bridge/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:rust_bridge/ffi/native_fun.dart';
3 |
4 | void main() {
5 | runApp(const MyApp());
6 | }
7 |
8 | class MyApp extends StatelessWidget {
9 | const MyApp({super.key});
10 |
11 | @override
12 | Widget build(BuildContext context) {
13 | return const MaterialApp(title: 'Flutter Demo', home: MyHomePage());
14 | }
15 | }
16 |
17 | class MyHomePage extends StatefulWidget {
18 | const MyHomePage({super.key});
19 |
20 | @override
21 | State createState() => _MyHomePageState();
22 | }
23 |
24 | class _MyHomePageState extends State {
25 | int _counter = 0;
26 |
27 | void _incrementCounter() async {
28 | _counter = await NativeFun.add(_counter, 2);
29 | setState(() {});
30 | }
31 |
32 | @override
33 | Widget build(BuildContext context) {
34 | return Scaffold(
35 | appBar: AppBar(title: const Text('Rust_Bridge Demo')),
36 | body: Center(
37 | child: Text(
38 | 'Count: $_counter',
39 | style: Theme.of(context).textTheme.headline4,
40 | ),
41 | ),
42 | floatingActionButton: FloatingActionButton(
43 | onPressed: _incrementCounter,
44 | tooltip: 'Increment',
45 | child: const Icon(Icons.add),
46 | ),
47 | );
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/rust_bridge/linux/.gitignore:
--------------------------------------------------------------------------------
1 | flutter/ephemeral
2 |
--------------------------------------------------------------------------------
/rust_bridge/linux/flutter/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # This file controls Flutter-level build steps. It should not be edited.
2 | cmake_minimum_required(VERSION 3.10)
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 |
12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...),
13 | # which isn't available in 3.10.
14 | function(list_prepend LIST_NAME PREFIX)
15 | set(NEW_LIST "")
16 | foreach(element ${${LIST_NAME}})
17 | list(APPEND NEW_LIST "${PREFIX}${element}")
18 | endforeach(element)
19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE)
20 | endfunction()
21 |
22 | # === Flutter Library ===
23 | # System-level dependencies.
24 | find_package(PkgConfig REQUIRED)
25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
28 |
29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
30 |
31 | # Published to parent scope for install step.
32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE)
36 |
37 | list(APPEND FLUTTER_LIBRARY_HEADERS
38 | "fl_basic_message_channel.h"
39 | "fl_binary_codec.h"
40 | "fl_binary_messenger.h"
41 | "fl_dart_project.h"
42 | "fl_engine.h"
43 | "fl_json_message_codec.h"
44 | "fl_json_method_codec.h"
45 | "fl_message_codec.h"
46 | "fl_method_call.h"
47 | "fl_method_channel.h"
48 | "fl_method_codec.h"
49 | "fl_method_response.h"
50 | "fl_plugin_registrar.h"
51 | "fl_plugin_registry.h"
52 | "fl_standard_message_codec.h"
53 | "fl_standard_method_codec.h"
54 | "fl_string_codec.h"
55 | "fl_value.h"
56 | "fl_view.h"
57 | "flutter_linux.h"
58 | )
59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/")
60 | add_library(flutter INTERFACE)
61 | target_include_directories(flutter INTERFACE
62 | "${EPHEMERAL_DIR}"
63 | )
64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}")
65 | target_link_libraries(flutter INTERFACE
66 | PkgConfig::GTK
67 | PkgConfig::GLIB
68 | PkgConfig::GIO
69 | )
70 | add_dependencies(flutter flutter_assemble)
71 |
72 | # === Flutter tool backend ===
73 | # _phony_ is a non-existent file to force this command to run every time,
74 | # since currently there's no way to get a full input/output list from the
75 | # flutter tool.
76 | add_custom_command(
77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_
79 | COMMAND ${CMAKE_COMMAND} -E env
80 | ${FLUTTER_TOOL_ENVIRONMENT}
81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
83 | VERBATIM
84 | )
85 | add_custom_target(flutter_assemble DEPENDS
86 | "${FLUTTER_LIBRARY}"
87 | ${FLUTTER_LIBRARY_HEADERS}
88 | )
89 |
--------------------------------------------------------------------------------
/rust_bridge/linux/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 |
10 | void fl_register_plugins(FlPluginRegistry* registry) {
11 | }
12 |
--------------------------------------------------------------------------------
/rust_bridge/linux/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 fl_register_plugins(FlPluginRegistry* registry);
14 |
15 | #endif // GENERATED_PLUGIN_REGISTRANT_
16 |
--------------------------------------------------------------------------------
/rust_bridge/linux/flutter/generated_plugins.cmake:
--------------------------------------------------------------------------------
1 | #
2 | # Generated file, do not edit.
3 | #
4 |
5 | list(APPEND FLUTTER_PLUGIN_LIST
6 | )
7 |
8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST
9 | )
10 |
11 | set(PLUGIN_BUNDLED_LIBRARIES)
12 |
13 | foreach(plugin ${FLUTTER_PLUGIN_LIST})
14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin})
15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $)
17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
18 | endforeach(plugin)
19 |
20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
23 | endforeach(ffi_plugin)
24 |
--------------------------------------------------------------------------------
/rust_bridge/linux/main.cc:
--------------------------------------------------------------------------------
1 | #include "my_application.h"
2 |
3 | int main(int argc, char** argv) {
4 | g_autoptr(MyApplication) app = my_application_new();
5 | return g_application_run(G_APPLICATION(app), argc, argv);
6 | }
7 |
--------------------------------------------------------------------------------
/rust_bridge/linux/my_application.h:
--------------------------------------------------------------------------------
1 | #ifndef FLUTTER_MY_APPLICATION_H_
2 | #define FLUTTER_MY_APPLICATION_H_
3 |
4 | #include
5 |
6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION,
7 | GtkApplication)
8 |
9 | /**
10 | * my_application_new:
11 | *
12 | * Creates a new Flutter-based application.
13 | *
14 | * Returns: a new #MyApplication.
15 | */
16 | MyApplication* my_application_new();
17 |
18 | #endif // FLUTTER_MY_APPLICATION_H_
19 |
--------------------------------------------------------------------------------
/rust_bridge/linux/rust.cmake:
--------------------------------------------------------------------------------
1 | # We include Corrosion inline here, but ideally in a project with
2 | # many dependencies we would need to install Corrosion on the system.
3 | # See instructions on https://github.com/AndrewGaspar/corrosion#cmake-install
4 | # Once done, uncomment this line:
5 | # find_package(Corrosion REQUIRED)
6 |
7 | include(FetchContent)
8 |
9 | FetchContent_Declare(
10 | Corrosion
11 | GIT_REPOSITORY https://github.com/AndrewGaspar/corrosion.git
12 | GIT_TAG origin/master # Optionally specify a version tag or branch here
13 | )
14 |
15 | FetchContent_MakeAvailable(Corrosion)
16 |
17 | corrosion_import_crate(MANIFEST_PATH ../rust/Cargo.toml CRATES rust_ffi)
18 |
19 | # Flutter-specific
20 |
21 | set(CRATE_NAME "rust_ffi")
22 |
23 | target_link_libraries(${BINARY_NAME} PRIVATE ${CRATE_NAME})
24 |
25 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $)
26 |
--------------------------------------------------------------------------------
/rust_bridge/macos/.gitignore:
--------------------------------------------------------------------------------
1 | # Flutter-related
2 | **/Flutter/ephemeral/
3 | **/Pods/
4 |
5 | # Xcode-related
6 | **/dgph
7 | **/xcuserdata/
8 |
--------------------------------------------------------------------------------
/rust_bridge/macos/Flutter/Flutter-Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "ephemeral/Flutter-Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/rust_bridge/macos/Flutter/Flutter-Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "ephemeral/Flutter-Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/rust_bridge/macos/Flutter/GeneratedPluginRegistrant.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | import FlutterMacOS
6 | import Foundation
7 |
8 |
9 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
10 | }
11 |
--------------------------------------------------------------------------------
/rust_bridge/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/rust_bridge/macos/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/rust_bridge/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/rust_bridge/macos/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import FlutterMacOS
3 |
4 | @NSApplicationMain
5 | class AppDelegate: FlutterAppDelegate {
6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
7 | dummy_method_to_enforce_bundling()
8 | return true
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/rust_bridge/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "16x16",
5 | "idiom" : "mac",
6 | "filename" : "app_icon_16.png",
7 | "scale" : "1x"
8 | },
9 | {
10 | "size" : "16x16",
11 | "idiom" : "mac",
12 | "filename" : "app_icon_32.png",
13 | "scale" : "2x"
14 | },
15 | {
16 | "size" : "32x32",
17 | "idiom" : "mac",
18 | "filename" : "app_icon_32.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "32x32",
23 | "idiom" : "mac",
24 | "filename" : "app_icon_64.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "128x128",
29 | "idiom" : "mac",
30 | "filename" : "app_icon_128.png",
31 | "scale" : "1x"
32 | },
33 | {
34 | "size" : "128x128",
35 | "idiom" : "mac",
36 | "filename" : "app_icon_256.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "256x256",
41 | "idiom" : "mac",
42 | "filename" : "app_icon_256.png",
43 | "scale" : "1x"
44 | },
45 | {
46 | "size" : "256x256",
47 | "idiom" : "mac",
48 | "filename" : "app_icon_512.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "512x512",
53 | "idiom" : "mac",
54 | "filename" : "app_icon_512.png",
55 | "scale" : "1x"
56 | },
57 | {
58 | "size" : "512x512",
59 | "idiom" : "mac",
60 | "filename" : "app_icon_1024.png",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/rust_bridge/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png
--------------------------------------------------------------------------------
/rust_bridge/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png
--------------------------------------------------------------------------------
/rust_bridge/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png
--------------------------------------------------------------------------------
/rust_bridge/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png
--------------------------------------------------------------------------------
/rust_bridge/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png
--------------------------------------------------------------------------------
/rust_bridge/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png
--------------------------------------------------------------------------------
/rust_bridge/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xdd666t/flutter_ffi/75016a60ce5c97e841a4d5e58ffbf497a19621ca/rust_bridge/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png
--------------------------------------------------------------------------------
/rust_bridge/macos/Runner/Configs/AppInfo.xcconfig:
--------------------------------------------------------------------------------
1 | // Application-level settings for the Runner target.
2 | //
3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the
4 | // future. If not, the values below would default to using the project name when this becomes a
5 | // 'flutter create' template.
6 |
7 | // The application's name. By default this is also the title of the Flutter window.
8 | PRODUCT_NAME = rust_bridge
9 |
10 | // The application's bundle identifier
11 | PRODUCT_BUNDLE_IDENTIFIER = com.xdd.rustBridge
12 |
13 | // The copyright displayed in application information
14 | PRODUCT_COPYRIGHT = Copyright © 2022 com.xdd. All rights reserved.
15 |
--------------------------------------------------------------------------------
/rust_bridge/macos/Runner/Configs/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "../../Flutter/Flutter-Debug.xcconfig"
2 | #include "Warnings.xcconfig"
3 |
--------------------------------------------------------------------------------
/rust_bridge/macos/Runner/Configs/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "../../Flutter/Flutter-Release.xcconfig"
2 | #include "Warnings.xcconfig"
3 |
--------------------------------------------------------------------------------
/rust_bridge/macos/Runner/Configs/Warnings.xcconfig:
--------------------------------------------------------------------------------
1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings
2 | GCC_WARN_UNDECLARED_SELECTOR = YES
3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES
4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE
5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES
6 | CLANG_WARN_PRAGMA_PACK = YES
7 | CLANG_WARN_STRICT_PROTOTYPES = YES
8 | CLANG_WARN_COMMA = YES
9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES
10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
12 | GCC_WARN_SHADOW = YES
13 | CLANG_WARN_UNREACHABLE_CODE = YES
14 |
--------------------------------------------------------------------------------
/rust_bridge/macos/Runner/DebugProfile.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 | com.apple.security.cs.allow-jit
8 |
9 | com.apple.security.network.server
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/rust_bridge/macos/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | $(FLUTTER_BUILD_NAME)
21 | CFBundleVersion
22 | $(FLUTTER_BUILD_NUMBER)
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSHumanReadableCopyright
26 | $(PRODUCT_COPYRIGHT)
27 | NSMainNibFile
28 | MainMenu
29 | NSPrincipalClass
30 | NSApplication
31 |
32 |
33 |
--------------------------------------------------------------------------------
/rust_bridge/macos/Runner/MainFlutterWindow.swift:
--------------------------------------------------------------------------------
1 | import Cocoa
2 | import FlutterMacOS
3 |
4 | class MainFlutterWindow: NSWindow {
5 | override func awakeFromNib() {
6 | let flutterViewController = FlutterViewController.init()
7 | let windowFrame = self.frame
8 | self.contentViewController = flutterViewController
9 | self.setFrame(windowFrame, display: true)
10 |
11 | RegisterGeneratedPlugins(registry: flutterViewController)
12 |
13 | super.awakeFromNib()
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/rust_bridge/macos/Runner/Release.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/rust_bridge/macos/Runner/bridge_generated.h:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | typedef int64_t DartPort;
6 |
7 | typedef bool (*DartPostCObjectFnType)(DartPort port_id, void *message);
8 |
9 | typedef struct WireSyncReturnStruct {
10 | uint8_t *ptr;
11 | int32_t len;
12 | bool success;
13 | } WireSyncReturnStruct;
14 |
15 | void store_dart_post_cobject(DartPostCObjectFnType ptr);
16 |
17 | void wire_add(int64_t port_, uintptr_t left, uintptr_t right);
18 |
19 | void free_WireSyncReturnStruct(struct WireSyncReturnStruct val);
20 |
21 | static int64_t dummy_method_to_enforce_bundling(void) {
22 | int64_t dummy_var = 0;
23 | dummy_var ^= ((int64_t) (void*) wire_add);
24 | dummy_var ^= ((int64_t) (void*) free_WireSyncReturnStruct);
25 | dummy_var ^= ((int64_t) (void*) store_dart_post_cobject);
26 | return dummy_var;
27 | }
--------------------------------------------------------------------------------
/rust_bridge/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: rust_bridge
2 | description: flutter_rust_bridge demo
3 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev
4 | version: 1.0.0+1
5 | environment:
6 | sdk: '>=2.18.5 <3.0.0'
7 |
8 | dependencies:
9 | flutter:
10 | sdk: flutter
11 | cupertino_icons: ^1.0.2
12 | # https://pub.dev/packages/flutter_rust_bridge
13 | flutter_rust_bridge: 1.51.0
14 | ffi: ^2.0.1
15 |
16 | dev_dependencies:
17 | flutter_test:
18 | sdk: flutter
19 | flutter_lints: ^2.0.0
20 | ffigen: ^7.0.0
21 |
22 | flutter:
23 | uses-material-design: true
--------------------------------------------------------------------------------
/rust_bridge/rust/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "rust_ffi"
3 | version = "0.1.0"
4 | edition = "2021"
5 |
6 | [lib]
7 | name = "rust_ffi"
8 | crate-type = ["staticlib", "cdylib"]
9 |
10 | [build-dependencies]
11 | flutter_rust_bridge_codegen = "=1.51.0"
12 |
13 | [dependencies]
14 | flutter_rust_bridge = "=1.51.0"
15 | flutter_rust_bridge_macros = "=1.51.0"
--------------------------------------------------------------------------------
/rust_bridge/rust/rust_ffi.xcodeproj/xcuserdata/xdd.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | rust_ffi-cdylib.xcscheme_^#shared#^_
8 |
9 | orderHint
10 | 2
11 |
12 | rust_ffi-staticlib.xcscheme_^#shared#^_
13 |
14 | orderHint
15 | 1
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/rust_bridge/rust/rust_ffi.xcodeproj/xcuserdata/xdd666.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | rust_ffi-cdylib.xcscheme_^#shared#^_
8 |
9 | orderHint
10 | 1
11 |
12 | rust_ffi-staticlib.xcscheme_^#shared#^_
13 |
14 | orderHint
15 | 2
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/rust_bridge/rust/src/api.rs:
--------------------------------------------------------------------------------
1 | pub fn add(left: usize, right: usize) -> usize {
2 | left + right
3 | }
4 |
5 | #[cfg(test)]
6 | mod tests {
7 | use super::*;
8 |
9 | #[test]
10 | fn it_works() {
11 | let result = add(2, 2);
12 | assert_eq!(result, 4);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/rust_bridge/rust/src/bridge_generated.io.rs:
--------------------------------------------------------------------------------
1 | use super::*;
2 | // Section: wire functions
3 |
4 | #[no_mangle]
5 | pub extern "C" fn wire_add(port_: i64, left: usize, right: usize) {
6 | wire_add_impl(port_, left, right)
7 | }
8 |
9 | // Section: allocate functions
10 |
11 | // Section: related functions
12 |
13 | // Section: impl Wire2Api
14 |
15 | // Section: wire structs
16 |
17 | // Section: impl NewWithNullPtr
18 |
19 | pub trait NewWithNullPtr {
20 | fn new_with_null_ptr() -> Self;
21 | }
22 |
23 | impl NewWithNullPtr for *mut T {
24 | fn new_with_null_ptr() -> Self {
25 | std::ptr::null_mut()
26 | }
27 | }
28 |
29 | // Section: sync execution mode utility
30 |
31 | #[no_mangle]
32 | pub extern "C" fn free_WireSyncReturnStruct(val: support::WireSyncReturnStruct) {
33 | unsafe {
34 | let _ = support::vec_from_leak_ptr(val.ptr, val.len);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/rust_bridge/rust/src/bridge_generated.rs:
--------------------------------------------------------------------------------
1 | #![allow(
2 | non_camel_case_types,
3 | unused,
4 | clippy::redundant_closure,
5 | clippy::useless_conversion,
6 | clippy::unit_arg,
7 | clippy::double_parens,
8 | non_snake_case,
9 | clippy::too_many_arguments
10 | )]
11 | // AUTO GENERATED FILE, DO NOT EDIT.
12 | // Generated by `flutter_rust_bridge`@ 1.51.0.
13 |
14 | use crate::api::*;
15 | use core::panic::UnwindSafe;
16 | use flutter_rust_bridge::*;
17 | use std::ffi::c_void;
18 | use std::sync::Arc;
19 |
20 | // Section: imports
21 |
22 | // Section: wire functions
23 |
24 | fn wire_add_impl(
25 | port_: MessagePort,
26 | left: impl Wire2Api + UnwindSafe,
27 | right: impl Wire2Api + UnwindSafe,
28 | ) {
29 | FLUTTER_RUST_BRIDGE_HANDLER.wrap(
30 | WrapInfo {
31 | debug_name: "add",
32 | port: Some(port_),
33 | mode: FfiCallMode::Normal,
34 | },
35 | move || {
36 | let api_left = left.wire2api();
37 | let api_right = right.wire2api();
38 | move |task_callback| Ok(add(api_left, api_right))
39 | },
40 | )
41 | }
42 | // Section: wrapper structs
43 |
44 | // Section: static checks
45 |
46 | // Section: allocate functions
47 |
48 | // Section: related functions
49 |
50 | // Section: impl Wire2Api
51 |
52 | pub trait Wire2Api {
53 | fn wire2api(self) -> T;
54 | }
55 |
56 | impl Wire2Api