├── .github ├── ISSUE_TEMPLATE │ ├── ---.md │ ├── bug-report.md │ └── feature_request.md └── workflows │ └── CI.yml ├── .gitignore ├── .metadata ├── CHANGELOG.md ├── LICENSE ├── README.md ├── analysis_options.yaml ├── android ├── .gitignore ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── settings.gradle └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── me │ │ └── yohom │ │ └── foundation_fluttify │ │ └── core │ │ └── FluttifyMessageCodec.java │ └── kotlin │ └── me │ └── yohom │ └── foundation_fluttify │ ├── FoundationFluttifyPlugin.kt │ ├── android │ ├── app │ │ ├── ActivityHandler.kt │ │ ├── ApplicationHandler.kt │ │ ├── NotificationHandler.kt │ │ └── PendingIntentHandler.kt │ ├── content │ │ ├── BroadcastReceiverHandler.kt │ │ ├── ContextHandler.kt │ │ ├── IntentFilterHandler.kt │ │ └── IntentHandler.kt │ ├── graphics │ │ ├── BitmapHandler.kt │ │ └── PointHandler.kt │ ├── location │ │ └── LocationHandler.kt │ ├── os │ │ └── BundleHandler.kt │ ├── util │ │ └── PairHandler.kt │ ├── view │ │ ├── SurfaceHolderHandler.kt │ │ ├── SurfaceViewHandler.kt │ │ ├── ViewGroupHandler.kt │ │ └── ViewHandler.kt │ └── widget │ │ └── ImageViewHandler.kt │ ├── core │ ├── AnyX.kt │ └── PlatformService.kt │ ├── java │ └── io │ │ └── FileHandler.kt │ └── platform_view │ ├── android_opengl_GLSurfaceViewFactory.kt │ ├── android_view_SurfaceViewFactory.kt │ └── android_widget_FrameLayoutFactory.kt ├── example ├── .flutter-plugins-dependencies ├── .gitignore ├── .metadata ├── README.md ├── android │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── kotlin │ │ │ │ └── me │ │ │ │ │ └── yohom │ │ │ │ │ └── foundation_fluttify_example │ │ │ │ │ └── MainActivity.kt │ │ │ └── res │ │ │ │ ├── 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 │ │ │ │ └── styles.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle ├── ios │ ├── Flutter │ │ ├── .last_build_id │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ └── Release.xcconfig │ ├── Podfile │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ └── contents.xcworkspacedata │ └── Runner │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── 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 │ │ └── main.m ├── lib │ └── main.dart ├── pubspec.lock ├── pubspec.yaml └── test │ └── widget_test.dart ├── ios ├── .gitignore ├── Assets │ └── .gitkeep ├── Classes │ ├── CGPointHandler.h │ ├── CGPointHandler.m │ ├── CGRectHandler.h │ ├── CGRectHandler.m │ ├── CGSizeHandler.h │ ├── CGSizeHandler.m │ ├── FluttifyMessageCodec.h │ ├── FluttifyMessageCodec.m │ ├── FoundationFluttifyPlugin.h │ ├── FoundationFluttifyPlugin.m │ ├── NSDataHandler.h │ ├── NSDataHandler.m │ ├── NSDateHandler.h │ ├── NSDateHandler.m │ ├── NSErrorHandler.h │ ├── NSErrorHandler.m │ ├── NSObjectHandler.h │ ├── NSObjectHandler.m │ ├── PlatformService.h │ ├── PlatformService.m │ ├── UIColorHandler.h │ ├── UIColorHandler.m │ ├── UIEdgeInsetsHandler.h │ ├── UIEdgeInsetsHandler.m │ ├── UIImageHandler.h │ ├── UIImageHandler.m │ ├── UIImageViewHandler.h │ ├── UIImageViewHandler.m │ ├── UIViewControllerHandler.h │ ├── UIViewControllerHandler.m │ ├── UIViewHandler.h │ ├── UIViewHandler.m │ └── platform_view │ │ ├── UIViewFactory.h │ │ └── UIViewFactory.m └── foundation_fluttify.podspec ├── lib ├── foundation_fluttify.dart └── src │ ├── extension │ └── image_provider.x.dart │ ├── function │ └── functions.dart │ ├── object │ └── obejcts.dart │ └── type │ ├── core │ ├── array.dart │ ├── broadcast_event_channel.dart │ ├── fluttify_message_codec.dart │ ├── ref.dart │ ├── stack.dart │ └── typedefs.dart │ ├── platform │ ├── android_type │ │ ├── android │ │ │ ├── app │ │ │ │ ├── activity.dart │ │ │ │ ├── application.dart │ │ │ │ ├── notification.dart │ │ │ │ └── pending_intent.dart │ │ │ ├── content │ │ │ │ ├── broadcast_receiver.dart │ │ │ │ ├── content_provider.dart │ │ │ │ ├── context.dart │ │ │ │ ├── intent.dart │ │ │ │ └── intent_filter.dart │ │ │ ├── graphics │ │ │ │ ├── bitmap.dart │ │ │ │ ├── drawable │ │ │ │ │ └── drawable.dart │ │ │ │ ├── point.dart │ │ │ │ └── point_f.dart │ │ │ ├── location │ │ │ │ └── location.dart │ │ │ ├── opengl │ │ │ │ └── gl_surface_view.dart │ │ │ ├── os │ │ │ │ ├── binder.dart │ │ │ │ ├── bundle.dart │ │ │ │ └── parcelable.dart │ │ │ ├── util │ │ │ │ └── pair.dart │ │ │ ├── view │ │ │ │ ├── motion_event.dart │ │ │ │ ├── surface_holder.dart │ │ │ │ ├── surface_view.dart │ │ │ │ ├── view.dart │ │ │ │ └── view_group.dart │ │ │ └── widget │ │ │ │ ├── frame_layout.dart │ │ │ │ ├── image_view.dart │ │ │ │ ├── linear_layout.dart │ │ │ │ ├── relative_layout.dart │ │ │ │ └── text_view.dart │ │ ├── java │ │ │ ├── io │ │ │ │ ├── closeable.dart │ │ │ │ ├── file.dart │ │ │ │ └── serializable.dart │ │ │ └── lang │ │ │ │ ├── object.dart │ │ │ │ └── throwable.dart │ │ └── org │ │ │ └── json │ │ │ └── json_object.dart │ └── ios_type │ │ ├── av_audio_session_category_options.dart │ │ ├── ca_action.dart │ │ ├── ca_animation.dart │ │ ├── ca_basic_animation.dart │ │ ├── ca_media_timing.dart │ │ ├── ca_property_animation.dart │ │ ├── cg_point.dart │ │ ├── cg_rect.dart │ │ ├── cg_size.dart │ │ ├── ns_coding.dart │ │ ├── ns_copying.dart │ │ ├── ns_data.dart │ │ ├── ns_date.dart │ │ ├── ns_error.dart │ │ ├── ns_mutable_copying.dart │ │ ├── ns_object.dart │ │ ├── ns_operation.dart │ │ ├── ns_url.dart │ │ ├── ns_user_activity.dart │ │ ├── ns_value.dart │ │ ├── ui_application.dart │ │ ├── ui_application_shortcut_item.dart │ │ ├── ui_bar_style.dart │ │ ├── ui_color.dart │ │ ├── ui_control.dart │ │ ├── ui_edge_insets.dart │ │ ├── ui_image.dart │ │ ├── ui_image_view.dart │ │ ├── ui_status_bar_style.dart │ │ ├── ui_user_notification_settings.dart │ │ ├── ui_view.dart │ │ └── ui_view_controller.dart │ └── widget │ ├── android_opengl_GLSurfaceView.widget.dart │ ├── android_view_SurfaceView.widget.dart │ ├── android_widget_FrameLayout.widget.dart │ ├── scoped_release_pool.widget.dart │ └── ui_view.widget.dart ├── pubspec.lock ├── pubspec.yaml └── test └── foundation_fluttify_test.dart /.github/ISSUE_TEMPLATE/---.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 新功能 3 | about: 添加功能 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **功能描述** 11 | 12 | **Native端对应字段/方法** 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: 遇到了bug. 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **插件版本** 11 | 12 | **描述bug** 13 | 14 | **复现步骤** 15 | 16 | **期望行为** 17 | 18 | **截图** 19 | 20 | **flutter doctor** 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: 添加功能 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **功能描述** 11 | 12 | **Native端对应字段/方法** 13 | -------------------------------------------------------------------------------- /.github/workflows/CI.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: [push] 3 | jobs: 4 | build: 5 | runs-on: macos-latest 6 | steps: 7 | - uses: actions/checkout@v1 8 | - uses: actions/setup-java@v1 9 | with: 10 | java-version: '12.x' 11 | - uses: subosito/flutter-action@v1 12 | with: 13 | channel: 'stable' 14 | - run: flutter pub get 15 | - run: cd example; flutter build apk; flutter build ios --no-codesign; 16 | 17 | 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .dart_tool/ 3 | 4 | .packages 5 | .pub/ 6 | .idea/ 7 | 8 | build/ 9 | 10 | *.iml 11 | !/example/.flutter-plugins-dependencies 12 | -------------------------------------------------------------------------------- /.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 and should not be manually edited. 5 | 6 | version: 7 | revision: 1aedbb1835bd6eb44550293d57d4d124f19901f0 8 | channel: stable 9 | 10 | project_type: plugin 11 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.8.11 2 | - feat: 增加PlatformService::getAssetPath方法 3 | - enhance: CGSize增加创建方法 4 | - enhance: 新增FluttifyBroadcastEventChannel, 一律返回Intent 5 | - enhance: Intent增加获取bundle 6 | 7 | ## 0.8.10 8 | - feat: 增加UIImageView的创建 9 | - enhance: UIView增加setAnchorPoint 10 | - enhance: CGRect增加属性获取方法 11 | 12 | ## 0.8.9 13 | - fix: objc application的回调不再传输NSDictionary类型的参数, 防止崩溃 14 | 15 | ## 0.8.8 16 | - enhance: CGSize增加width和height 17 | 18 | ## 0.8.7 19 | - enhance: 增加ImageProviderX 20 | 21 | ## 0.8.6 22 | - enhance: 增加java_lang_Throwable 23 | 24 | ## 0.8.5 25 | - enhance: 接口类增加sbInstance方法 26 | 27 | ## 0.8.4 28 | - enhance: 增加android_view_SurfaceHolder_Callback 29 | 30 | ## 0.8.3 31 | - enhance: 增加android_view_SurfaceView 32 | 33 | ## 0.8.2 34 | - feat: android_location_Location增加setter 35 | 36 | ## 0.8.1 37 | - feat: 增加startActivityForResult方法 38 | - feat: 增加uri2ImageData 39 | - feat: UIViewController::get 40 | - feat: android_location_Location增加创建方法 41 | 42 | ## 0.8.0 43 | - fix: UIImage scale问题处理 44 | 45 | ## 0.7.3 46 | - feat: 增加java.io.File 47 | 48 | ## 0.7.2 49 | - feat: 增加java_io_Closeable 50 | 51 | ## 0.7.1 52 | - feat: Bundle增加getString和putString 53 | - enhance: ios使用static_framework 54 | - enhance: 适配1.17 55 | 56 | ## 0.7.0 57 | - enhance: [breaking change] 去除CoreLocation相关逻辑, 计划分离到core_location_fluttiy插件中去 58 | - feat: 增加android_view_View_OnTouchListener类; 增加ui_view.widget 59 | - feat: 增加av_audio_session_category_options 60 | - feat: CGRect增加create方法 61 | - feat: android.graphics.Bitmap和UIImage各自增加从原生素材创建Image的方法 62 | 63 | ## 0.6.1 64 | - enhance: android: *Handler的args参数使用Any类型, 内部再做转换 65 | - feat: 增加批处理方法 66 | 67 | ## 0.6.0 68 | - enhance: [breaking change] Ref类内的方法和属性都加上__后缀, 防止和子类冲突 69 | 70 | ## 0.5.1 71 | - feat: NSError增加获取code和description的方法 72 | 73 | ## 0.5.0 74 | - enhance: [breaking change] tag -> tag__ 75 | 76 | ## 0.4.18 77 | - feat: 增加UIViewController 78 | 79 | ## 0.4.17 80 | - feat: 使用System.identityHashCode代替hashCode方法 81 | - feat: 增加android.view.View.OnClickListener类 82 | - feat: 增加startActivity/presentViewController方法 83 | 84 | ## 0.4.16 85 | - feat: 增加NSValue类 86 | 87 | ## 0.4.15 88 | - enhance: 简化platform方法 89 | - enhance: 补上漏掉的log开关 90 | - enhance: 迁移创建方法到对应类的handler里去 91 | - feat: 增加android.app.Notification类 92 | 93 | ## 0.4.14 94 | - enhance: CLLocationCoordinate2D增加批量创建方法 95 | 96 | ## 0.4.13 97 | - enhance: 优化批量释放日志 98 | - feat: UIView增加hidden和setHidden 99 | 100 | ## 0.4.12 101 | - enhance: 优化platform方法里的释放逻辑 102 | 103 | ## 0.4.11 104 | - enhance: Ref增加批处理释放对象方法 105 | 106 | ## 0.4.10 107 | - feat: 增加org_json_JSONObject类 108 | 109 | ## 0.4.9 110 | - feat: 增加android_view_View_OnApplyWindowInsetsListener类 111 | 112 | ## 0.4.8 113 | - feat: Bitmap增加批量创建方法 114 | 115 | ## 0.4.7 116 | - refactor: PlatformFactory统一为PlatformService 117 | - feat: 增加ns_operation类 118 | 119 | ## 0.4.6 120 | - feat: 增加一些通用的typedef 121 | 122 | ## 0.4.5+1 123 | - fix: onAttachedToEngine中的Plugin对象应该使用this 124 | 125 | ## 0.4.5 126 | - fix: PlatformFactory的activity是可选类型; 127 | - enhance: android_util_Pair获取first和second都返回Object 128 | 129 | ## 0.4.4 130 | - enhance: 适配新版embedding 131 | - refactor: method channel放到objects文件里 132 | 133 | ## 0.4.3 134 | - feat: 增加为对象动态添加属性的方法(目前仅限ios端, android理论上可以再加全局Map实现,但是目前没有碰到此类需求) 135 | 136 | ## 0.4.2 137 | - feat: 增加java_io_Serializable 138 | 139 | ## 0.4.1 140 | - feat: 增加android_os_Binder 141 | 142 | ## 0.4.0 143 | - refactor: 可以放进类的静态方法替换全局函数 144 | 145 | ## 0.3.0 146 | - refactor: 函数代替类 147 | - chore: 提升gradle相关版本 148 | 149 | ## 0.2.7 150 | - feat: 增加pending_intent类 151 | 152 | ## 0.2.6 153 | - feat: android端增加BroadcastReceiver统一接收广播 154 | 155 | ## 0.2.5 156 | - feat: CLHeading实现magneticHeading,trueHeading,headingAccuracy 157 | 158 | ## 0.2.4 159 | - feat: android_location_Location增加bearing, altitude, accuracy, speed 160 | 161 | ## 0.2.3 162 | - feat: 增加android_content_ContentProvider 163 | 164 | ## 0.2.2 165 | - feat: 实现UIEdgeInsets的属性 166 | 167 | ## 0.2.1 168 | - fix: [objc] 每个.h文件都import 169 | 170 | ## 0.2.0 171 | - [breaking change] 整理工厂方法 172 | 173 | ## 0.1.5 174 | - feat: 增加cgpoint的创建支持,获取x和y 175 | 176 | ## 0.1.4 177 | - feat: 增加android_graphics_Point的创建, getX, getY的支持 178 | 179 | ## 0.1.3 180 | feat: 增加NSData 181 | 182 | ## 0.1.2 183 | - 新增android.app.Activity#getIntent() 184 | - feat: android端的Intent处理容器 185 | 186 | ## 0.1.1 187 | - 增加android.content.Intent 188 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 yohom 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # `Fluttify`基础设施 2 | 3 | 所有基于`Fluttify`的插件公共的部分, 当然不基于`Fluttify`的插件理论上也可以使用. 4 | 5 | 主要实现一些基础设施和系统类的实现. -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:pedantic/analysis_options.yaml 2 | 3 | linter: 4 | rules: 5 | camel_case_types: false 6 | camel_case_extensions: false 7 | omit_local_variable_types: false -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | group 'me.yohom.foundation_fluttify' 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 | rootProject.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 | sourceSets { 31 | main.java.srcDirs += 'src/main/kotlin' 32 | } 33 | defaultConfig { 34 | minSdkVersion 16 35 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 36 | } 37 | lintOptions { 38 | disable 'InvalidPackage' 39 | } 40 | } 41 | 42 | dependencies { 43 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 44 | } 45 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.enableR8=true 3 | android.useAndroidX=true 4 | android.enableJetifier=true 5 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'foundation_fluttify' 2 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/src/main/java/me/yohom/foundation_fluttify/core/FluttifyMessageCodec.java: -------------------------------------------------------------------------------- 1 | package me.yohom.foundation_fluttify.core; 2 | 3 | import androidx.annotation.NonNull; 4 | import androidx.annotation.Nullable; 5 | import io.flutter.plugin.common.StandardMessageCodec; 6 | import me.yohom.foundation_fluttify.FoundationFluttifyPluginKt; 7 | 8 | import java.io.ByteArrayOutputStream; 9 | import java.nio.ByteBuffer; 10 | import java.nio.charset.Charset; 11 | import java.util.*; 12 | 13 | public class FluttifyMessageCodec extends StandardMessageCodec { 14 | private static final Charset UTF8 = Charset.forName("UTF8"); 15 | 16 | // 总体逻辑, 先尝试使用标准编解码进行处理, 如果发生异常再使用自定义的编解码处理, 再不行就只能抛异常了 17 | private static final byte ARRAY = 125; 18 | private static final byte ENUM = 126; 19 | private static final byte REF = 127; 20 | 21 | @Override 22 | protected void writeValue(@NonNull ByteArrayOutputStream stream, @NonNull Object value) { 23 | try { 24 | super.writeValue(stream, value); 25 | } catch (IllegalArgumentException e) { 26 | // 对象数组转换 27 | if (value instanceof Object[]) { 28 | stream.write(ARRAY); 29 | Object[] array = (Object[]) value; 30 | writeSize(stream, array.length); 31 | for (Object item : array) { 32 | writeValue(stream, item); 33 | } 34 | } 35 | // 枚举值传索引 36 | else if (value instanceof Enum) { 37 | stream.write(ENUM); 38 | writeInt(stream, ((Enum) value).ordinal()); 39 | } else { 40 | final String refId = value.getClass().getName() + ":" + System.identityHashCode(value); 41 | // 放入HEAP 42 | FoundationFluttifyPluginKt.getHEAP().put(refId, value); 43 | 44 | stream.write(REF); 45 | writeBytes(stream, refId.getBytes(UTF8)); 46 | } 47 | } 48 | } 49 | 50 | @Nullable 51 | protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { 52 | Object result; 53 | try { 54 | result = super.readValueOfType(type, buffer); 55 | } catch (IllegalArgumentException e) { 56 | switch (type) { 57 | case ARRAY: 58 | final int size = readSize(buffer); 59 | final List list = new ArrayList<>(size); 60 | int i = 0; 61 | while (i < size) { 62 | list.add(readValue(buffer)); 63 | i++; 64 | } 65 | result = list.toArray(); 66 | break; 67 | case ENUM: 68 | result = buffer.getInt(); 69 | break; 70 | case REF: 71 | final byte[] bytes = readBytes(buffer); 72 | result = FoundationFluttifyPluginKt.getHEAP().get(new String(bytes, UTF8)); 73 | break; 74 | default: 75 | result = null; 76 | } 77 | } 78 | 79 | return result; 80 | 81 | } 82 | } -------------------------------------------------------------------------------- /android/src/main/kotlin/me/yohom/foundation_fluttify/android/app/ActivityHandler.kt: -------------------------------------------------------------------------------- 1 | package me.yohom.foundation_fluttify.android.app 2 | 3 | import android.app.Activity 4 | import io.flutter.plugin.common.MethodChannel 5 | import me.yohom.foundation_fluttify.core.__this__ 6 | 7 | fun ActivityHandler(method: String, args: Any, methodResult: MethodChannel.Result, context: Activity?) { 8 | when (method) { 9 | "android.app.Activity::getIntent" -> { 10 | methodResult.success(args.__this__().intent) 11 | } 12 | "android.app.Activity::get" -> { 13 | methodResult.success(context) 14 | } 15 | else -> methodResult.notImplemented() 16 | } 17 | } -------------------------------------------------------------------------------- /android/src/main/kotlin/me/yohom/foundation_fluttify/android/app/ApplicationHandler.kt: -------------------------------------------------------------------------------- 1 | package me.yohom.foundation_fluttify.android.app 2 | 3 | import android.content.Context 4 | import io.flutter.plugin.common.MethodChannel 5 | 6 | fun ApplicationHandler(method: String, args: Any, methodResult: MethodChannel.Result, context: Context?) { 7 | when (method) { 8 | "android.app.Application::get" -> { 9 | methodResult.success(context) 10 | } 11 | else -> methodResult.notImplemented() 12 | } 13 | } -------------------------------------------------------------------------------- /android/src/main/kotlin/me/yohom/foundation_fluttify/android/app/NotificationHandler.kt: -------------------------------------------------------------------------------- 1 | package me.yohom.foundation_fluttify.android.app 2 | 3 | import android.app.Activity 4 | import android.app.Notification 5 | import android.app.NotificationChannel 6 | import android.app.NotificationManager 7 | import android.content.Context 8 | import android.graphics.Color 9 | import android.os.Build 10 | import io.flutter.plugin.common.MethodChannel 11 | import me.yohom.foundation_fluttify.HEAP 12 | import me.yohom.foundation_fluttify.enableLog 13 | 14 | fun NotificationHandler(method: String, rawArgs: Any, methodResult: MethodChannel.Result, activity: Activity?) { 15 | when (method) { 16 | "android.app.Notification::create" -> { 17 | val args = rawArgs as Map 18 | if (activity == null) { 19 | methodResult.error("activity cannot be null", "activity cannot be null", "activity cannot be null") 20 | } else { 21 | val contentTitle = args["contentTitle"] as String 22 | val contentText = args["contentText"] as String 23 | val `when` = args["when"] as Long 24 | val channelId = args["channelId"] as String 25 | val channelName = args["channelName"] as String 26 | val enableLights = args["enableLights"] as Boolean 27 | val showBadge = args["showBadge"] as Boolean 28 | 29 | if (enableLog) { 30 | android.util.Log.d("Notification create: ", "contentTitle: $contentTitle, contentText: $contentText, when: $`when`, channelId: $channelId, channelName: $channelName, enableLights: $enableLights, showBadge: $showBadge") 31 | } 32 | 33 | val notificationManager: NotificationManager = activity.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager 34 | 35 | // Android O上对Notification进行了修改,如果设置的targetSDKVersion>=26建议使用此种方式创建通知栏 36 | val builder: Notification.Builder = if (Build.VERSION.SDK_INT >= 26) { 37 | val notificationChannel = NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_DEFAULT) 38 | .apply { 39 | enableLights(enableLights) //是否在桌面icon右上角展示小圆点 40 | lightColor = Color.BLUE //小圆点颜色 41 | setShowBadge(showBadge) //是否在久按桌面图标时显示此渠道的通知 42 | } 43 | 44 | notificationManager.createNotificationChannel(notificationChannel) 45 | 46 | Notification.Builder(activity.applicationContext, channelId) 47 | } else { 48 | Notification.Builder(activity.applicationContext) 49 | } 50 | 51 | // TODO: 从flutter传icon数据过来? 52 | val iconId = activity.resources.getIdentifier("ic_launcher", "mipmap", activity.packageName) 53 | 54 | builder.setSmallIcon(iconId) 55 | .setContentTitle(contentTitle) 56 | .setContentText(contentText) 57 | .setWhen(`when`) 58 | val notification = builder.build() 59 | 60 | methodResult.success(notification) 61 | } 62 | } 63 | else -> methodResult.notImplemented() 64 | } 65 | } -------------------------------------------------------------------------------- /android/src/main/kotlin/me/yohom/foundation_fluttify/android/app/PendingIntentHandler.kt: -------------------------------------------------------------------------------- 1 | package me.yohom.foundation_fluttify.android.app 2 | 3 | import io.flutter.plugin.common.MethodChannel 4 | 5 | fun PendingIntentHandler(method: String, args: Any, methodResult: MethodChannel.Result) { 6 | when (method) { 7 | else -> methodResult.notImplemented() 8 | } 9 | } -------------------------------------------------------------------------------- /android/src/main/kotlin/me/yohom/foundation_fluttify/android/content/BroadcastReceiverHandler.kt: -------------------------------------------------------------------------------- 1 | package me.yohom.foundation_fluttify.android.content 2 | 3 | import android.content.BroadcastReceiver 4 | import android.content.Context 5 | import android.content.Intent 6 | import io.flutter.plugin.common.BinaryMessenger 7 | import io.flutter.plugin.common.MethodChannel 8 | import me.yohom.foundation_fluttify.HEAP 9 | 10 | fun BroadcastReceiverHandler(method: String, rawArgs: Any, binaryMessenger: BinaryMessenger?, methodResult: MethodChannel.Result) { 11 | when (method) { 12 | "android.content.BroadcastReceiver::create" -> { 13 | val receiver = object : BroadcastReceiver() { 14 | override fun onReceive(context: Context?, intent: Intent?) { 15 | if (binaryMessenger != null) { 16 | MethodChannel(binaryMessenger, "android.content.BroadcastReceiver::create::Callback") 17 | .invokeMethod( 18 | "Callback::android.content.BroadcastReceiver::onReceive", 19 | mapOf("intent" to intent) 20 | ) 21 | } 22 | } 23 | } 24 | 25 | methodResult.success(receiver) 26 | } 27 | else -> methodResult.notImplemented() 28 | } 29 | } -------------------------------------------------------------------------------- /android/src/main/kotlin/me/yohom/foundation_fluttify/android/content/ContextHandler.kt: -------------------------------------------------------------------------------- 1 | package me.yohom.foundation_fluttify.android.content 2 | 3 | import android.content.BroadcastReceiver 4 | import android.content.Context 5 | import android.content.IntentFilter 6 | import io.flutter.plugin.common.MethodChannel 7 | import me.yohom.foundation_fluttify.core.__this__ 8 | import me.yohom.foundation_fluttify.core.get 9 | 10 | fun ContextHandler(method: String, rawArgs: Any, methodResult: MethodChannel.Result) { 11 | when (method) { 12 | "android.content.Context::registerReceiver" -> { 13 | val broadcastReceiver = rawArgs["broadcastReceiver"] as BroadcastReceiver 14 | val intentFilter = rawArgs["intentFilter"] as IntentFilter 15 | 16 | val context: Context = rawArgs.__this__() 17 | 18 | val intent = context.registerReceiver(broadcastReceiver, intentFilter) 19 | 20 | methodResult.success(intent) 21 | } 22 | else -> methodResult.notImplemented() 23 | } 24 | } -------------------------------------------------------------------------------- /android/src/main/kotlin/me/yohom/foundation_fluttify/android/content/IntentFilterHandler.kt: -------------------------------------------------------------------------------- 1 | package me.yohom.foundation_fluttify.android.content 2 | 3 | import android.content.IntentFilter 4 | import io.flutter.plugin.common.MethodChannel 5 | import me.yohom.foundation_fluttify.core.get 6 | 7 | fun IntentFilterHandler(method: String, rawArgs: Any, methodResult: MethodChannel.Result) { 8 | when (method) { 9 | "android.content.IntentFilter::create" -> { 10 | val action = rawArgs["action"] as String 11 | 12 | val intentFilter = IntentFilter(action) 13 | 14 | methodResult.success(intentFilter) 15 | } 16 | else -> methodResult.notImplemented() 17 | } 18 | } -------------------------------------------------------------------------------- /android/src/main/kotlin/me/yohom/foundation_fluttify/android/content/IntentHandler.kt: -------------------------------------------------------------------------------- 1 | package me.yohom.foundation_fluttify.android.content 2 | 3 | import android.content.Intent 4 | import android.os.Bundle 5 | import io.flutter.plugin.common.MethodChannel 6 | import me.yohom.foundation_fluttify.core.__this__ 7 | 8 | fun IntentHandler(method: String, args: Any, methodResult: MethodChannel.Result) { 9 | when (method) { 10 | "android.content.Intent::getBundle" -> { 11 | val intent: Intent = args.__this__() 12 | 13 | val bundle = intent.extras ?: Bundle.EMPTY 14 | 15 | val result: MutableMap = mutableMapOf() 16 | for (key in bundle.keySet()) { 17 | result[key] = bundle.getSerializable(key) 18 | } 19 | 20 | methodResult.success(result) 21 | } 22 | "android.content.Intent::getAction" -> { 23 | val intent: Intent = args.__this__() 24 | 25 | val action = intent.action 26 | 27 | methodResult.success(action) 28 | } 29 | else -> methodResult.notImplemented() 30 | } 31 | } -------------------------------------------------------------------------------- /android/src/main/kotlin/me/yohom/foundation_fluttify/android/graphics/BitmapHandler.kt: -------------------------------------------------------------------------------- 1 | package me.yohom.foundation_fluttify.android.graphics 2 | 3 | import android.app.Activity 4 | import android.graphics.Bitmap 5 | import android.graphics.BitmapFactory 6 | import io.flutter.plugin.common.MethodChannel 7 | import me.yohom.foundation_fluttify.core.__this__ 8 | import me.yohom.foundation_fluttify.core.get 9 | import java.io.ByteArrayOutputStream 10 | 11 | fun BitmapHandler(method: String, rawArgs: Any, methodResult: MethodChannel.Result, activity: Activity?) { 12 | when (method) { 13 | "android.graphics.Bitmap::create" -> { 14 | val bitmapBytes = rawArgs["bitmapBytes"] as ByteArray 15 | val bitmap = BitmapFactory.decodeByteArray(bitmapBytes, 0, bitmapBytes.size) 16 | 17 | methodResult.success(bitmap) 18 | } 19 | "android.graphics.Bitmap::createWithDrawable" -> { 20 | val drawableId = rawArgs["drawableId"] as Int 21 | if (activity != null) { 22 | val bitmap = BitmapFactory.decodeResource(activity.resources, drawableId) 23 | methodResult.success(bitmap) 24 | } else { 25 | methodResult.error("Activity不能为null", "Activity不能为null", "Activity不能为null") 26 | } 27 | } 28 | "android.graphics.Bitmap::create_batch" -> { 29 | val typedArgs = rawArgs as List> 30 | val bitmapBytesBatch = typedArgs.map { it["bitmapBytes"] as ByteArray } 31 | 32 | val resultBatch = bitmapBytesBatch 33 | .map { BitmapFactory.decodeByteArray(it, 0, it.size) } 34 | 35 | methodResult.success(resultBatch) 36 | } 37 | "android.graphics.Bitmap::getData" -> { 38 | val bitmap = rawArgs["__this__"] as Bitmap 39 | 40 | val outputStream = ByteArrayOutputStream() 41 | bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream) 42 | methodResult.success(outputStream.toByteArray()) 43 | } 44 | "android.graphics.Bitmap::recycle" -> { 45 | val bitmap: Bitmap = rawArgs.__this__() 46 | 47 | bitmap.recycle() 48 | methodResult.success("success") 49 | } 50 | "android.graphics.Bitmap::isRecycled" -> { 51 | val bitmap: Bitmap = rawArgs.__this__() 52 | 53 | methodResult.success(bitmap.isRecycled) 54 | } 55 | else -> methodResult.notImplemented() 56 | } 57 | } -------------------------------------------------------------------------------- /android/src/main/kotlin/me/yohom/foundation_fluttify/android/graphics/PointHandler.kt: -------------------------------------------------------------------------------- 1 | package me.yohom.foundation_fluttify.android.graphics 2 | 3 | import android.graphics.Point 4 | import io.flutter.plugin.common.MethodChannel 5 | import me.yohom.foundation_fluttify.core.__this__ 6 | import me.yohom.foundation_fluttify.core.get 7 | 8 | fun PointHandler(method: String, rawArgs: Any, methodResult: MethodChannel.Result) { 9 | when (method) { 10 | "android.graphics.Point::create" -> { 11 | val x = rawArgs["x"] as Int 12 | val y = rawArgs["y"] as Int 13 | val point = Point(x, y) 14 | 15 | methodResult.success(point) 16 | } 17 | "android.graphics.Point::getX" -> { 18 | val point: Point = rawArgs.__this__() 19 | 20 | methodResult.success(point.x) 21 | } 22 | "android.graphics.Point::getY" -> { 23 | val point: Point = rawArgs.__this__() 24 | 25 | methodResult.success(point.y) 26 | } 27 | else -> methodResult.notImplemented() 28 | } 29 | } -------------------------------------------------------------------------------- /android/src/main/kotlin/me/yohom/foundation_fluttify/android/location/LocationHandler.kt: -------------------------------------------------------------------------------- 1 | package me.yohom.foundation_fluttify.android.location 2 | 3 | import android.location.Location 4 | import io.flutter.plugin.common.MethodChannel 5 | import me.yohom.foundation_fluttify.core.__this__ 6 | import me.yohom.foundation_fluttify.core.get 7 | 8 | fun LocationHandler(method: String, rawArgs: Any, methodResult: MethodChannel.Result) { 9 | when (method) { 10 | "android.location.Location::create" -> { 11 | val provider = rawArgs["provider"] as String 12 | 13 | val location = Location(provider) 14 | 15 | methodResult.success(location) 16 | } 17 | "android.location.Location::getLatitude" -> { 18 | val location: Location = rawArgs.__this__() 19 | 20 | methodResult.success(location.latitude) 21 | } 22 | "android.location.Location::getLongitude" -> { 23 | val location: Location = rawArgs.__this__() 24 | 25 | methodResult.success(location.longitude) 26 | } 27 | "android.location.Location::getBearing" -> { 28 | val location: Location = rawArgs.__this__() 29 | 30 | methodResult.success(location.bearing) 31 | } 32 | "android.location.Location::getAltitude" -> { 33 | val location: Location = rawArgs.__this__() 34 | 35 | methodResult.success(location.altitude) 36 | } 37 | "android.location.Location::getAccuracy" -> { 38 | val location: Location = rawArgs.__this__() 39 | 40 | methodResult.success(location.accuracy) 41 | } 42 | "android.location.Location::getSpeed" -> { 43 | val location: Location = rawArgs.__this__() 44 | 45 | methodResult.success(location.speed) 46 | } 47 | "android.location.Location::setLatitude" -> { 48 | val latitude = rawArgs["latitude"] as Double 49 | 50 | val location: Location = rawArgs.__this__() 51 | location.latitude = latitude 52 | 53 | methodResult.success("success") 54 | } 55 | "android.location.Location::setLongitude" -> { 56 | val longitude = rawArgs["longitude"] as Double 57 | 58 | val location: Location = rawArgs.__this__() 59 | 60 | location.longitude = longitude 61 | 62 | methodResult.success("success") 63 | } 64 | "android.location.Location::setBearing" -> { 65 | val bearing = rawArgs["bearing"] as Double 66 | 67 | val location: Location = rawArgs.__this__() 68 | 69 | location.bearing = bearing.toFloat() 70 | 71 | methodResult.success("success") 72 | } 73 | "android.location.Location::setAltitude" -> { 74 | val altitude = rawArgs["altitude"] as Double 75 | 76 | val location: Location = rawArgs.__this__() 77 | 78 | location.altitude = altitude 79 | 80 | methodResult.success("success") 81 | } 82 | "android.location.Location::setAccuracy" -> { 83 | val accuracy = rawArgs["accuracy"] as Double 84 | 85 | val location: Location = rawArgs.__this__() 86 | 87 | location.accuracy = accuracy.toFloat() 88 | 89 | methodResult.success("success") 90 | } 91 | "android.location.Location::setSpeed" -> { 92 | val speed = rawArgs["speed"] as Double 93 | 94 | val location: Location = rawArgs.__this__() 95 | 96 | location.speed = speed.toFloat() 97 | 98 | methodResult.success("success") 99 | } 100 | else -> methodResult.notImplemented() 101 | } 102 | } -------------------------------------------------------------------------------- /android/src/main/kotlin/me/yohom/foundation_fluttify/android/os/BundleHandler.kt: -------------------------------------------------------------------------------- 1 | package me.yohom.foundation_fluttify.android.os 2 | 3 | import android.os.Bundle 4 | import io.flutter.plugin.common.MethodChannel 5 | import me.yohom.foundation_fluttify.core.__this__ 6 | import me.yohom.foundation_fluttify.core.get 7 | 8 | fun BundleHandler(method: String, rawArgs: Any, methodResult: MethodChannel.Result) { 9 | when (method) { 10 | "android.os.Bundle::create" -> { 11 | val target = Bundle() 12 | methodResult.success(target) 13 | } 14 | "android.os.Bundle::putString" -> { 15 | val key = rawArgs["key"] as String 16 | val value = rawArgs["value"] as String 17 | 18 | val bundle: Bundle = rawArgs.__this__() 19 | 20 | bundle.putString(key, value) 21 | 22 | methodResult.success("success") 23 | } 24 | "android.os.Bundle::putInt" -> { 25 | val key = rawArgs["key"] as String 26 | val value = rawArgs["value"] as Int 27 | 28 | val bundle: Bundle = rawArgs.__this__() 29 | 30 | bundle.putInt(key, value) 31 | 32 | methodResult.success("success") 33 | } 34 | "android.os.Bundle::getString" -> { 35 | val key = rawArgs["key"] as String 36 | 37 | val bundle: Bundle = rawArgs.__this__() 38 | 39 | methodResult.success(bundle.getString(key)) 40 | } 41 | "android.os.Bundle::getInt" -> { 42 | val key = rawArgs["key"] as String 43 | 44 | val bundle: Bundle = rawArgs.__this__() 45 | 46 | methodResult.success(bundle.getInt(key)) 47 | } 48 | "android.os.Bundle::getFloat" -> { 49 | val key = rawArgs["key"] as String 50 | 51 | val bundle: Bundle = rawArgs.__this__() 52 | 53 | methodResult.success(bundle.getFloat(key)) 54 | } 55 | "android.os.Bundle::getDouble" -> { 56 | val key = rawArgs["key"] as String 57 | 58 | val bundle: Bundle = rawArgs.__this__() 59 | 60 | methodResult.success(bundle.getDouble(key)) 61 | } 62 | "android.os.Bundle::getAll" -> { 63 | val bundle: Bundle = rawArgs.__this__() 64 | 65 | val result: MutableMap = mutableMapOf() 66 | 67 | for (item in bundle.keySet()) { 68 | result[item] = bundle.get(item) 69 | } 70 | 71 | methodResult.success(result) 72 | } 73 | else -> methodResult.notImplemented() 74 | } 75 | } -------------------------------------------------------------------------------- /android/src/main/kotlin/me/yohom/foundation_fluttify/android/util/PairHandler.kt: -------------------------------------------------------------------------------- 1 | package me.yohom.foundation_fluttify.android.util 2 | 3 | import android.util.Pair 4 | import io.flutter.plugin.common.MethodChannel 5 | import me.yohom.foundation_fluttify.core.__this__ 6 | 7 | fun PairHandler(method: String, rawArgs: Any, methodResult: MethodChannel.Result) { 8 | when (method) { 9 | "android.util.Pair::getFirst" -> { 10 | val pair: Pair<*, *> = rawArgs.__this__() 11 | 12 | methodResult.success(pair.first) 13 | } 14 | "android.util.Pair::getSecond" -> { 15 | val pair: Pair<*, *> = rawArgs.__this__() 16 | 17 | methodResult.success(pair.second) 18 | } 19 | else -> methodResult.notImplemented() 20 | } 21 | } -------------------------------------------------------------------------------- /android/src/main/kotlin/me/yohom/foundation_fluttify/android/view/SurfaceHolderHandler.kt: -------------------------------------------------------------------------------- 1 | package me.yohom.foundation_fluttify.android.view 2 | 3 | import android.view.SurfaceHolder 4 | import io.flutter.plugin.common.BinaryMessenger 5 | import io.flutter.plugin.common.MethodChannel 6 | import me.yohom.foundation_fluttify.core.get 7 | 8 | fun SurfaceHolderHandler( 9 | messenger: BinaryMessenger?, 10 | method: String, 11 | rawArgs: Any, 12 | methodResult: MethodChannel.Result 13 | ) { 14 | when (method) { 15 | "android.view.SurfaceHolder::addCallback" -> { 16 | val __this__ = rawArgs["__this__"] as SurfaceHolder 17 | 18 | __this__.addCallback(object : SurfaceHolder.Callback { 19 | private val channel = 20 | MethodChannel(messenger!!, "android.view.SurfaceHolder::addCallback::Callback") 21 | 22 | override fun surfaceCreated(p0: SurfaceHolder) { 23 | print("kotlin: onSurfaceCreated") 24 | channel.invokeMethod( 25 | "Callback::android.view.SurfaceHolder.Callback::surfaceCreated", 26 | mapOf("var1" to p0) 27 | ) 28 | } 29 | 30 | override fun surfaceChanged(p0: SurfaceHolder, p1: Int, p2: Int, p3: Int) { 31 | print("kotlin: surfaceChanged") 32 | channel.invokeMethod( 33 | "Callback::android.view.SurfaceHolder.Callback::surfaceChanged", 34 | mapOf("var1" to p0, "var2" to p1, "var3" to p2, "var4" to p3) 35 | ) 36 | } 37 | 38 | override fun surfaceDestroyed(p0: SurfaceHolder) { 39 | print("kotlin: surfaceDestroyed") 40 | channel.invokeMethod( 41 | "Callback::android.view.SurfaceHolder.Callback::surfaceDestroyed", 42 | mapOf("var1" to p0) 43 | ) 44 | } 45 | 46 | // override fun surfaceCreated(p0: SurfaceHolder) { 47 | // print("kotlin: onSurfaceCreated") 48 | // channel.invokeMethod( 49 | // "Callback::android.view.SurfaceHolder.Callback::surfaceCreated", 50 | // mapOf("var1" to p0) 51 | // ) 52 | // } 53 | // 54 | // override fun surfaceChanged(p0: SurfaceHolder, p1: Int, p2: Int, p3: Int) { 55 | // print("kotlin: surfaceChanged") 56 | // channel.invokeMethod( 57 | // "Callback::android.view.SurfaceHolder.Callback::surfaceChanged", 58 | // mapOf("var1" to p0, "var2" to p1, "var3" to p2, "var4" to p3) 59 | // ) 60 | // } 61 | // 62 | // override fun surfaceDestroyed(p0: SurfaceHolder) { 63 | // print("kotlin: surfaceDestroyed") 64 | // channel.invokeMethod( 65 | // "Callback::android.view.SurfaceHolder.Callback::surfaceDestroyed", 66 | // mapOf("var1" to p0) 67 | // ) 68 | // } 69 | }) 70 | 71 | methodResult.success("success") 72 | } 73 | else -> methodResult.notImplemented() 74 | } 75 | } -------------------------------------------------------------------------------- /android/src/main/kotlin/me/yohom/foundation_fluttify/android/view/SurfaceViewHandler.kt: -------------------------------------------------------------------------------- 1 | package me.yohom.foundation_fluttify.android.view 2 | 3 | import android.view.SurfaceView 4 | import io.flutter.plugin.common.MethodChannel 5 | import me.yohom.foundation_fluttify.core.get 6 | 7 | fun SurfaceViewHandler(method: String, rawArgs: Any, methodResult: MethodChannel.Result) { 8 | when (method) { 9 | "android.view.SurfaceView::getHolder" -> { 10 | val __this__ = rawArgs["__this__"] as SurfaceView 11 | methodResult.success(__this__.holder) 12 | } 13 | "android.view.SurfaceView::setZOrderOnTop" -> { 14 | val __this__ = rawArgs["__this__"] as SurfaceView 15 | __this__.setZOrderOnTop(rawArgs["onTop"] as Boolean) 16 | methodResult.success("success") 17 | } 18 | "android.view.SurfaceView::setZOrderMediaOverlay" -> { 19 | val __this__ = rawArgs["__this__"] as SurfaceView 20 | __this__.setZOrderMediaOverlay(rawArgs["isMediaOverlay"] as Boolean) 21 | methodResult.success("success") 22 | } 23 | else -> methodResult.notImplemented() 24 | } 25 | } -------------------------------------------------------------------------------- /android/src/main/kotlin/me/yohom/foundation_fluttify/android/view/ViewGroupHandler.kt: -------------------------------------------------------------------------------- 1 | package me.yohom.foundation_fluttify.android.view 2 | 3 | import android.view.View 4 | import android.view.ViewGroup 5 | import io.flutter.plugin.common.MethodChannel 6 | import me.yohom.foundation_fluttify.core.__this__ 7 | import me.yohom.foundation_fluttify.core.get 8 | 9 | fun ViewGroupHandler(method: String, rawArgs: Any, methodResult: MethodChannel.Result) { 10 | when (method) { 11 | "android.view.ViewGroup::addView" -> { 12 | val viewGroup: ViewGroup = rawArgs.__this__() 13 | val child: View = rawArgs["child"] as View 14 | 15 | viewGroup.addView(child) 16 | 17 | methodResult.success("success") 18 | } 19 | "android.view.ViewGroup::removeAllViews" -> { 20 | val viewGroup: ViewGroup = rawArgs.__this__() 21 | 22 | viewGroup.removeAllViews() 23 | 24 | methodResult.success("success") 25 | } 26 | else -> methodResult.notImplemented() 27 | } 28 | } -------------------------------------------------------------------------------- /android/src/main/kotlin/me/yohom/foundation_fluttify/android/view/ViewHandler.kt: -------------------------------------------------------------------------------- 1 | package me.yohom.foundation_fluttify.android.view 2 | 3 | import io.flutter.plugin.common.MethodChannel 4 | 5 | fun ViewHandler(method: String, rawArgs: Any, methodResult: MethodChannel.Result) { 6 | when (method) { 7 | else -> methodResult.notImplemented() 8 | } 9 | } -------------------------------------------------------------------------------- /android/src/main/kotlin/me/yohom/foundation_fluttify/android/widget/ImageViewHandler.kt: -------------------------------------------------------------------------------- 1 | package me.yohom.foundation_fluttify.android.widget 2 | 3 | import android.app.Activity 4 | import android.graphics.Bitmap 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import android.widget.ImageView 8 | import io.flutter.plugin.common.MethodChannel 9 | import me.yohom.foundation_fluttify.core.__this__ 10 | import me.yohom.foundation_fluttify.core.get 11 | 12 | fun ImageViewHandler( 13 | method: String, 14 | rawArgs: Any, 15 | methodResult: MethodChannel.Result, 16 | context: Activity? 17 | ) { 18 | when (method) { 19 | "android.widget.ImageView::createWithBitmap" -> { 20 | if (context == null) { 21 | methodResult.error("activity cannot be null", "activity cannot be null", "activity cannot be null") 22 | } else { 23 | val bitmap = rawArgs["bitmap"] as Bitmap 24 | val imageView = ImageView(context) 25 | imageView.setImageBitmap(bitmap) 26 | 27 | methodResult.success(imageView) 28 | } 29 | } 30 | else -> methodResult.notImplemented() 31 | } 32 | } -------------------------------------------------------------------------------- /android/src/main/kotlin/me/yohom/foundation_fluttify/core/AnyX.kt: -------------------------------------------------------------------------------- 1 | @file:Suppress("ObjectPropertyName", "FunctionName") 2 | 3 | package me.yohom.foundation_fluttify.core 4 | 5 | fun Any.__this__(): T { 6 | return (this as Map)["__this__"] as T 7 | } 8 | 9 | operator fun Any.get(key: String): Any? { 10 | return (this as Map)[key] 11 | } 12 | -------------------------------------------------------------------------------- /android/src/main/kotlin/me/yohom/foundation_fluttify/java/io/FileHandler.kt: -------------------------------------------------------------------------------- 1 | package me.yohom.foundation_fluttify.java.io 2 | 3 | import io.flutter.plugin.common.MethodChannel 4 | import me.yohom.foundation_fluttify.core.get 5 | import java.io.File 6 | 7 | fun FileHandler(method: String, rawArgs: Any, methodResult: MethodChannel.Result) { 8 | when (method) { 9 | "java.io.File::create" -> { 10 | val path = rawArgs["path"] as String 11 | val file = File(path) 12 | 13 | methodResult.success(file) 14 | } 15 | else -> methodResult.notImplemented() 16 | } 17 | } -------------------------------------------------------------------------------- /android/src/main/kotlin/me/yohom/foundation_fluttify/platform_view/android_opengl_GLSurfaceViewFactory.kt: -------------------------------------------------------------------------------- 1 | package me.yohom.foundation_fluttify.platform_view 2 | 3 | import android.content.Context 4 | import android.opengl.GLSurfaceView 5 | import android.view.View 6 | import io.flutter.plugin.common.StandardMessageCodec 7 | import io.flutter.plugin.platform.PlatformView 8 | import io.flutter.plugin.platform.PlatformViewFactory 9 | import me.yohom.foundation_fluttify.HEAP 10 | 11 | @Suppress("ClassName") 12 | class android_opengl_GLSurfaceViewFactory : PlatformViewFactory(StandardMessageCodec.INSTANCE) { 13 | override fun create(context: Context?, id: Int, params: Any?): PlatformView { 14 | val view = GLSurfaceView(context) 15 | 16 | // 同时存放viewId和refId的对象, 供后续viewId转refId使用 17 | HEAP[(Int.MAX_VALUE - id).toString()] = view 18 | HEAP["android.opengl.GLSurfaceView:${System.identityHashCode(view)}"] = view 19 | return object : PlatformView { 20 | override fun getView(): View { 21 | return view 22 | } 23 | 24 | override fun dispose() {} 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /android/src/main/kotlin/me/yohom/foundation_fluttify/platform_view/android_view_SurfaceViewFactory.kt: -------------------------------------------------------------------------------- 1 | package me.yohom.foundation_fluttify.platform_view 2 | 3 | import android.content.Context 4 | import android.view.SurfaceHolder 5 | import android.view.SurfaceView 6 | import android.view.View 7 | import io.flutter.plugin.common.BinaryMessenger 8 | import io.flutter.plugin.common.MethodChannel 9 | import io.flutter.plugin.common.StandardMethodCodec 10 | import io.flutter.plugin.platform.PlatformView 11 | import io.flutter.plugin.platform.PlatformViewFactory 12 | import me.yohom.foundation_fluttify.HEAP 13 | import me.yohom.foundation_fluttify.core.FluttifyMessageCodec 14 | 15 | @Suppress("ClassName") 16 | class android_view_SurfaceViewFactory(private val binaryMessenger: BinaryMessenger?) 17 | : PlatformViewFactory(FluttifyMessageCodec()) { 18 | override fun create(context: Context?, id: Int, params: Any?): PlatformView { 19 | val view = SurfaceView(context) 20 | 21 | view.holder.addCallback(object : SurfaceHolder.Callback { 22 | private val channel = MethodChannel( 23 | binaryMessenger!!, 24 | "android.view.SurfaceHolder::addCallback::Callback", 25 | StandardMethodCodec(FluttifyMessageCodec()) 26 | ) 27 | 28 | override fun surfaceCreated(holder: SurfaceHolder) { 29 | channel.invokeMethod( 30 | "Callback::android.view.SurfaceHolder.Callback::surfaceCreated", 31 | mapOf("holder" to holder) 32 | ) 33 | } 34 | 35 | override fun surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int) { 36 | channel.invokeMethod( 37 | "Callback::android.view.SurfaceHolder.Callback::surfaceChanged", 38 | mapOf("holder" to holder, "format" to format, "width" to width, "height" to height) 39 | ) 40 | } 41 | 42 | override fun surfaceDestroyed(holder: SurfaceHolder) { 43 | channel.invokeMethod( 44 | "Callback::android.view.SurfaceHolder.Callback::surfaceDestroyed", 45 | mapOf("holder" to holder) 46 | ) 47 | } 48 | }) 49 | 50 | // 同时存放viewId和refId的对象, 供后续viewId转refId使用 51 | HEAP[(Int.MAX_VALUE - id).toString()] = view 52 | HEAP["android.view.SurfaceView:${System.identityHashCode(view)}"] = view 53 | return object : PlatformView { 54 | override fun getView(): View { 55 | return view 56 | } 57 | 58 | override fun dispose() {} 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /android/src/main/kotlin/me/yohom/foundation_fluttify/platform_view/android_widget_FrameLayoutFactory.kt: -------------------------------------------------------------------------------- 1 | package me.yohom.foundation_fluttify.platform_view 2 | 3 | import android.content.Context 4 | import android.view.View 5 | import android.widget.FrameLayout 6 | import io.flutter.plugin.platform.PlatformView 7 | import io.flutter.plugin.platform.PlatformViewFactory 8 | import me.yohom.foundation_fluttify.HEAP 9 | import me.yohom.foundation_fluttify.core.FluttifyMessageCodec 10 | 11 | @Suppress("ClassName") 12 | class android_widget_FrameLayoutFactory : PlatformViewFactory(FluttifyMessageCodec()) { 13 | override fun create(context: Context?, id: Int, params: Any?): PlatformView { 14 | val view = FrameLayout(context!!) 15 | 16 | // 同时存放viewId和refId的对象, 供后续viewId转refId使用 17 | HEAP[(Int.MAX_VALUE - id).toString()] = view 18 | HEAP["android.widget.FrameLayout:${System.identityHashCode(view)}"] = view 19 | return object : PlatformView { 20 | override fun getView(): View { 21 | return view 22 | } 23 | 24 | override fun dispose() {} 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /example/.flutter-plugins-dependencies: -------------------------------------------------------------------------------- 1 | {"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"foundation_fluttify","path":"/Users/yohom/Github/Me/All/fluttify/foundation_fluttify/","native_build":true,"dependencies":[]}],"android":[{"name":"foundation_fluttify","path":"/Users/yohom/Github/Me/All/fluttify/foundation_fluttify/","native_build":true,"dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"foundation_fluttify","dependencies":[]}],"date_created":"2022-09-12 10:18:11.256066","version":"3.0.5"} -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .flutter-plugins 27 | .packages 28 | .pub-cache/ 29 | .pub/ 30 | /build/ 31 | 32 | # Android related 33 | **/android/**/gradle-wrapper.jar 34 | **/android/.gradle 35 | **/android/captures/ 36 | **/android/gradlew 37 | **/android/gradlew.bat 38 | **/android/local.properties 39 | **/android/**/GeneratedPluginRegistrant.java 40 | 41 | # iOS/XCode related 42 | **/ios/**/*.mode1v3 43 | **/ios/**/*.mode2v3 44 | **/ios/**/*.moved-aside 45 | **/ios/**/*.pbxuser 46 | **/ios/**/*.perspectivev3 47 | **/ios/**/*sync/ 48 | **/ios/**/.sconsign.dblite 49 | **/ios/**/.tags* 50 | **/ios/**/.vagrant/ 51 | **/ios/**/DerivedData/ 52 | **/ios/**/Icon? 53 | **/ios/**/Pods/ 54 | **/ios/**/.symlinks/ 55 | **/ios/**/profile 56 | **/ios/**/xcuserdata 57 | **/ios/.generated/ 58 | **/ios/Flutter/App.framework 59 | **/ios/Flutter/Flutter.framework 60 | **/ios/Flutter/Generated.xcconfig 61 | **/ios/Flutter/app.flx 62 | **/ios/Flutter/app.zip 63 | **/ios/Flutter/flutter_assets/ 64 | **/ios/Flutter/flutter_export_environment.sh 65 | **/ios/ServiceDefinitions.json 66 | **/ios/Runner/GeneratedPluginRegistrant.* 67 | 68 | # Exceptions to above rules. 69 | !**/ios/**/default.mode1v3 70 | !**/ios/**/default.mode2v3 71 | !**/ios/**/default.pbxuser 72 | !**/ios/**/default.perspectivev3 73 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 74 | !/.flutter-plugins-dependencies 75 | -------------------------------------------------------------------------------- /example/.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 and should not be manually edited. 5 | 6 | version: 7 | revision: 1aedbb1835bd6eb44550293d57d4d124f19901f0 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # foundation_fluttify_example 2 | 3 | Demonstrates how to use the foundation_fluttify 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://flutter.dev/docs/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) 13 | 14 | For help getting started with Flutter, view our 15 | [online documentation](https://flutter.dev/docs), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /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 | 31 | sourceSets { 32 | main.java.srcDirs += 'src/main/kotlin' 33 | } 34 | 35 | lintOptions { 36 | disable 'InvalidPackage' 37 | } 38 | 39 | defaultConfig { 40 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 41 | applicationId "me.yohom.foundation_fluttify_example" 42 | minSdkVersion 21 43 | targetSdkVersion flutter.targetSdkVersion 44 | versionCode flutterVersionCode.toInteger() 45 | versionName flutterVersionName 46 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 47 | } 48 | 49 | buildTypes { 50 | release { 51 | // TODO: Add your own signing config for the release build. 52 | // Signing with the debug keys for now, so `flutter run --release` works. 53 | signingConfig signingConfigs.debug 54 | } 55 | } 56 | } 57 | 58 | flutter { 59 | source '../..' 60 | } 61 | 62 | dependencies { 63 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 64 | testImplementation 'junit:junit:4.12' 65 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 66 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' 67 | } 68 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 9 | 13 | 21 | 25 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/me/yohom/foundation_fluttify_example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package me.yohom.foundation_fluttify_example 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() 6 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yohom/foundation_fluttify/1aeb8f4d90ce1bb23791ce077e48d15ef887aace/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yohom/foundation_fluttify/1aeb8f4d90ce1bb23791ce077e48d15ef887aace/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yohom/foundation_fluttify/1aeb8f4d90ce1bb23791ce077e48d15ef887aace/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yohom/foundation_fluttify/1aeb8f4d90ce1bb23791ce077e48d15ef887aace/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yohom/foundation_fluttify/1aeb8f4d90ce1bb23791ce077e48d15ef887aace/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | 3 | android.enableR8=true 4 | android.useAndroidX=true 5 | android.enableJetifier=true 6 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip 7 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() 4 | 5 | def plugins = new Properties() 6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') 7 | if (pluginsFile.exists()) { 8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } 9 | } 10 | 11 | plugins.each { name, path -> 12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() 13 | include ":$name" 14 | project(":$name").projectDir = pluginDirectory 15 | } 16 | -------------------------------------------------------------------------------- /example/ios/Flutter/.last_build_id: -------------------------------------------------------------------------------- 1 | e872b3a1aaf22f979513fee8d40f5f79 -------------------------------------------------------------------------------- /example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 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 | 9.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | platform :ios, '9.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 32 | end 33 | 34 | post_install do |installer| 35 | installer.pods_project.targets.each do |target| 36 | flutter_additional_ios_build_settings(target) 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : FlutterAppDelegate 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #include "AppDelegate.h" 2 | #include "GeneratedPluginRegistrant.h" 3 | 4 | @implementation AppDelegate 5 | 6 | - (BOOL)application:(UIApplication *)application 7 | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 8 | [GeneratedPluginRegistrant registerWithRegistry:self]; 9 | // Override point for customization after application launch. 10 | return [super application:application didFinishLaunchingWithOptions:launchOptions]; 11 | } 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yohom/foundation_fluttify/1aeb8f4d90ce1bb23791ce077e48d15ef887aace/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yohom/foundation_fluttify/1aeb8f4d90ce1bb23791ce077e48d15ef887aace/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yohom/foundation_fluttify/1aeb8f4d90ce1bb23791ce077e48d15ef887aace/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yohom/foundation_fluttify/1aeb8f4d90ce1bb23791ce077e48d15ef887aace/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yohom/foundation_fluttify/1aeb8f4d90ce1bb23791ce077e48d15ef887aace/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yohom/foundation_fluttify/1aeb8f4d90ce1bb23791ce077e48d15ef887aace/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yohom/foundation_fluttify/1aeb8f4d90ce1bb23791ce077e48d15ef887aace/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yohom/foundation_fluttify/1aeb8f4d90ce1bb23791ce077e48d15ef887aace/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yohom/foundation_fluttify/1aeb8f4d90ce1bb23791ce077e48d15ef887aace/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yohom/foundation_fluttify/1aeb8f4d90ce1bb23791ce077e48d15ef887aace/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yohom/foundation_fluttify/1aeb8f4d90ce1bb23791ce077e48d15ef887aace/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yohom/foundation_fluttify/1aeb8f4d90ce1bb23791ce077e48d15ef887aace/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yohom/foundation_fluttify/1aeb8f4d90ce1bb23791ce077e48d15ef887aace/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yohom/foundation_fluttify/1aeb8f4d90ce1bb23791ce077e48d15ef887aace/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yohom/foundation_fluttify/1aeb8f4d90ce1bb23791ce077e48d15ef887aace/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yohom/foundation_fluttify/1aeb8f4d90ce1bb23791ce077e48d15ef887aace/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yohom/foundation_fluttify/1aeb8f4d90ce1bb23791ce077e48d15ef887aace/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yohom/foundation_fluttify/1aeb8f4d90ce1bb23791ce077e48d15ef887aace/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /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. -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | foundation_fluttify_example 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(FLUTTER_BUILD_NAME) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | CADisableMinimumFrameDurationOnPhone 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /example/ios/Runner/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char* argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 3 | 4 | void main() => runApp(MyApp()); 5 | 6 | class MyApp extends StatefulWidget { 7 | @override 8 | _MyAppState createState() => _MyAppState(); 9 | } 10 | 11 | class _MyAppState extends State { 12 | @override 13 | Widget build(BuildContext context) { 14 | return MaterialApp( 15 | home: Scaffold( 16 | appBar: AppBar(title: const Text('Plugin example app')), 17 | ), 18 | ); 19 | } 20 | 21 | Future _testAddProperty() async { 22 | final target = await CGPoint.create(225, 556); 23 | final target1 = await CGPoint.create(112, 556); 24 | await target.addProperty__(1, target1); 25 | 26 | final result = await target.getProperty__(1); 27 | final target1Result = CGPoint()..refId = result.refId; 28 | debugPrint('结果: ${await target1Result.x}'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /example/pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | url: "https://pub.flutter-io.cn" 9 | source: hosted 10 | version: "2.8.2" 11 | boolean_selector: 12 | dependency: transitive 13 | description: 14 | name: boolean_selector 15 | url: "https://pub.flutter-io.cn" 16 | source: hosted 17 | version: "2.1.0" 18 | characters: 19 | dependency: transitive 20 | description: 21 | name: characters 22 | url: "https://pub.flutter-io.cn" 23 | source: hosted 24 | version: "1.2.0" 25 | charcode: 26 | dependency: transitive 27 | description: 28 | name: charcode 29 | url: "https://pub.flutter-io.cn" 30 | source: hosted 31 | version: "1.3.1" 32 | clock: 33 | dependency: transitive 34 | description: 35 | name: clock 36 | url: "https://pub.flutter-io.cn" 37 | source: hosted 38 | version: "1.1.0" 39 | collection: 40 | dependency: transitive 41 | description: 42 | name: collection 43 | url: "https://pub.flutter-io.cn" 44 | source: hosted 45 | version: "1.16.0" 46 | cupertino_icons: 47 | dependency: "direct main" 48 | description: 49 | name: cupertino_icons 50 | url: "https://pub.flutter-io.cn" 51 | source: hosted 52 | version: "0.1.3" 53 | fake_async: 54 | dependency: transitive 55 | description: 56 | name: fake_async 57 | url: "https://pub.flutter-io.cn" 58 | source: hosted 59 | version: "1.3.0" 60 | flutter: 61 | dependency: "direct main" 62 | description: flutter 63 | source: sdk 64 | version: "0.0.0" 65 | flutter_test: 66 | dependency: "direct dev" 67 | description: flutter 68 | source: sdk 69 | version: "0.0.0" 70 | foundation_fluttify: 71 | dependency: "direct dev" 72 | description: 73 | path: ".." 74 | relative: true 75 | source: path 76 | version: "0.13.0" 77 | matcher: 78 | dependency: transitive 79 | description: 80 | name: matcher 81 | url: "https://pub.flutter-io.cn" 82 | source: hosted 83 | version: "0.12.11" 84 | material_color_utilities: 85 | dependency: transitive 86 | description: 87 | name: material_color_utilities 88 | url: "https://pub.flutter-io.cn" 89 | source: hosted 90 | version: "0.1.4" 91 | meta: 92 | dependency: transitive 93 | description: 94 | name: meta 95 | url: "https://pub.flutter-io.cn" 96 | source: hosted 97 | version: "1.7.0" 98 | path: 99 | dependency: transitive 100 | description: 101 | name: path 102 | url: "https://pub.flutter-io.cn" 103 | source: hosted 104 | version: "1.8.1" 105 | sky_engine: 106 | dependency: transitive 107 | description: flutter 108 | source: sdk 109 | version: "0.0.99" 110 | source_span: 111 | dependency: transitive 112 | description: 113 | name: source_span 114 | url: "https://pub.flutter-io.cn" 115 | source: hosted 116 | version: "1.8.2" 117 | stack_trace: 118 | dependency: transitive 119 | description: 120 | name: stack_trace 121 | url: "https://pub.flutter-io.cn" 122 | source: hosted 123 | version: "1.10.0" 124 | stream_channel: 125 | dependency: transitive 126 | description: 127 | name: stream_channel 128 | url: "https://pub.flutter-io.cn" 129 | source: hosted 130 | version: "2.1.0" 131 | string_scanner: 132 | dependency: transitive 133 | description: 134 | name: string_scanner 135 | url: "https://pub.flutter-io.cn" 136 | source: hosted 137 | version: "1.1.0" 138 | term_glyph: 139 | dependency: transitive 140 | description: 141 | name: term_glyph 142 | url: "https://pub.flutter-io.cn" 143 | source: hosted 144 | version: "1.2.0" 145 | test_api: 146 | dependency: transitive 147 | description: 148 | name: test_api 149 | url: "https://pub.flutter-io.cn" 150 | source: hosted 151 | version: "0.4.9" 152 | vector_math: 153 | dependency: transitive 154 | description: 155 | name: vector_math 156 | url: "https://pub.flutter-io.cn" 157 | source: hosted 158 | version: "2.1.2" 159 | sdks: 160 | dart: ">=2.17.0-0 <3.0.0" 161 | flutter: ">=2.0.0" 162 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: foundation_fluttify_example 2 | description: Demonstrates how to use the foundation_fluttify plugin. 3 | publish_to: 'none' 4 | 5 | environment: 6 | sdk: '>=2.12.0 <3.0.0' 7 | 8 | dependencies: 9 | flutter: 10 | sdk: flutter 11 | cupertino_icons: ^0.1.3 12 | 13 | dev_dependencies: 14 | flutter_test: 15 | sdk: flutter 16 | 17 | foundation_fluttify: 18 | path: ../ 19 | 20 | flutter: 21 | uses-material-design: true -------------------------------------------------------------------------------- /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 that Flutter provides. 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:foundation_fluttify_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(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 | -------------------------------------------------------------------------------- /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/flutter_export_environment.sh -------------------------------------------------------------------------------- /ios/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yohom/foundation_fluttify/1aeb8f4d90ce1bb23791ce077e48d15ef887aace/ios/Assets/.gitkeep -------------------------------------------------------------------------------- /ios/Classes/CGPointHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Yohom Bao on 2019/11/29. 3 | // 4 | 5 | #import 6 | #import 7 | 8 | NS_ASSUME_NONNULL_BEGIN 9 | 10 | void CGPointHandler(NSString* method, id args, FlutterResult methodResult); 11 | 12 | NS_ASSUME_NONNULL_END 13 | -------------------------------------------------------------------------------- /ios/Classes/CGPointHandler.m: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Yohom Bao on 2019/11/29. 3 | // 4 | 5 | #import 6 | #import "CGPointHandler.h" 7 | 8 | extern BOOL enableLog; 9 | 10 | void CGPointHandler(NSString* method, id rawArgs, FlutterResult methodResult) { 11 | if ([@"CGPoint::getX" isEqualToString:method]) { 12 | NSDictionary* args = (NSDictionary*) rawArgs; 13 | 14 | NSValue *value = (NSValue *) args[@"__this__"]; 15 | if (value != nil && (NSNull*) value != [NSNull null]) { 16 | CGPoint cgPoint = value.CGPointValue; 17 | methodResult(@(cgPoint.x)); 18 | } else { 19 | methodResult([FlutterError errorWithCode:@"目标对象为nul" 20 | message:@"目标对象为nul" 21 | details:@"目标对象为nul"]); 22 | } 23 | } else if ([@"CGPoint::getY" isEqualToString:method]) { 24 | NSDictionary* args = (NSDictionary*) rawArgs; 25 | 26 | NSValue *value = (NSValue *) args[@"__this__"]; 27 | if (value != nil && (NSNull*) value != [NSNull null]) { 28 | CGPoint cgPoint = value.CGPointValue; 29 | methodResult(@(cgPoint.y)); 30 | } else { 31 | methodResult([FlutterError errorWithCode:@"目标对象为nul" 32 | message:@"目标对象为nul" 33 | details:@"目标对象为nul"]); 34 | } 35 | } else if ([@"CGPoint::getX_batch" isEqualToString:method]) { 36 | NSDictionary* args = (NSDictionary*) rawArgs; 37 | 38 | NSArray* value = (NSArray*) args[@"__this__"]; 39 | if (value != nil && (NSNull*) value != [NSNull null]) { 40 | NSMutableArray* result = [NSMutableArray arrayWithCapacity:value.count]; 41 | 42 | for (NSValue* pointValue in value) { 43 | [result addObject:@(pointValue.CGPointValue.x)]; 44 | } 45 | 46 | methodResult(result); 47 | } else { 48 | methodResult([FlutterError errorWithCode:@"目标对象为nul" 49 | message:@"目标对象为nul" 50 | details:@"目标对象为nul"]); 51 | } 52 | } else if ([@"CGPoint::getY_batch" isEqualToString:method]) { 53 | NSDictionary* args = (NSDictionary*) rawArgs; 54 | 55 | NSArray* value = (NSArray*) args[@"__this__"]; 56 | if (value != nil && (NSNull*) value != [NSNull null]) { 57 | NSMutableArray* result = [NSMutableArray arrayWithCapacity:value.count]; 58 | 59 | for (NSValue* pointValue in value) { 60 | [result addObject:@(pointValue.CGPointValue.y)]; 61 | } 62 | 63 | methodResult(result); 64 | } else { 65 | methodResult([FlutterError errorWithCode:@"目标对象为nul" 66 | message:@"目标对象为nul" 67 | details:@"目标对象为nul"]); 68 | } 69 | } else if ([@"CGPoint::create" isEqualToString:method]) { 70 | NSDictionary* args = (NSDictionary*) rawArgs; 71 | 72 | NSNumber *x = (NSNumber *) args[@"x"]; 73 | NSNumber *y = (NSNumber *) args[@"y"]; 74 | 75 | CGPoint cgPoint = CGPointMake([x floatValue], [y floatValue]); 76 | NSValue *valuePoint = [NSValue valueWithCGPoint:cgPoint]; 77 | 78 | methodResult(valuePoint); 79 | } else if ([@"CGPoint::create_batch" isEqualToString:method]) { 80 | NSDictionary* args = (NSDictionary*) rawArgs; 81 | 82 | NSArray* x = (NSArray*) args[@"x"]; 83 | NSArray* y = (NSArray*) args[@"y"]; 84 | 85 | NSMutableArray* result = [NSMutableArray arrayWithCapacity:x.count]; 86 | 87 | for (NSUInteger i = 0; i < x.count; i++) { 88 | CGPoint cgPoint = CGPointMake([x[i] floatValue], [y[i] floatValue]); 89 | NSValue *valuePoint = [NSValue valueWithCGPoint:cgPoint]; 90 | 91 | [result addObject:valuePoint]; 92 | } 93 | 94 | methodResult(result); 95 | } else { 96 | methodResult(FlutterMethodNotImplemented); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /ios/Classes/CGRectHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // CGRectHandler.h 3 | // foundation_fluttify 4 | // 5 | // Created by Yohom Bao on 2020/4/20. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | void CGRectHandler(NSString* method, id args, FlutterResult methodResult); 14 | 15 | NS_ASSUME_NONNULL_END 16 | -------------------------------------------------------------------------------- /ios/Classes/CGRectHandler.m: -------------------------------------------------------------------------------- 1 | // 2 | // CGRectHandler.m 3 | // foundation_fluttify 4 | // 5 | // Created by Yohom Bao on 2020/4/20. 6 | // 7 | 8 | #import "CGRectHandler.h" 9 | 10 | extern BOOL enableLog; 11 | 12 | void CGRectHandler(NSString* method, id rawArgs, FlutterResult methodResult) { 13 | if ([@"CGRect::create" isEqualToString:method]) { 14 | NSDictionary* args = (NSDictionary*) rawArgs; 15 | 16 | CGFloat x = [(NSNumber*) args[@"x"] floatValue]; 17 | CGFloat y = [(NSNumber*) args[@"y"] floatValue]; 18 | CGFloat width = [(NSNumber*) args[@"width"] floatValue]; 19 | CGFloat height = [(NSNumber*) args[@"height"] floatValue]; 20 | 21 | CGRect rect = CGRectMake(x, y, width, height); 22 | 23 | NSValue* result = [NSValue valueWithCGRect:rect]; 24 | 25 | methodResult(result); 26 | } else if ([@"CGRect::getX" isEqualToString:method]) { 27 | NSDictionary* args = (NSDictionary*) rawArgs; 28 | 29 | NSValue *value = (NSValue *) args[@"__this__"]; 30 | if (value != nil && (NSNull*) value != [NSNull null]) { 31 | CGRect cgRect = value.CGRectValue; 32 | methodResult(@(cgRect.origin.x)); 33 | } else { 34 | methodResult([FlutterError errorWithCode:@"目标对象为nul" 35 | message:@"目标对象为nul" 36 | details:@"目标对象为nul"]); 37 | } 38 | } else if ([@"CGRect::getY" isEqualToString:method]) { 39 | NSDictionary* args = (NSDictionary*) rawArgs; 40 | 41 | NSValue *value = (NSValue *) args[@"__this__"]; 42 | if (value != nil && (NSNull*) value != [NSNull null]) { 43 | CGRect cgRect = value.CGRectValue; 44 | methodResult(@(cgRect.origin.y)); 45 | } else { 46 | methodResult([FlutterError errorWithCode:@"目标对象为nul" 47 | message:@"目标对象为nul" 48 | details:@"目标对象为nul"]); 49 | } 50 | } else if ([@"CGRect::getWidth" isEqualToString:method]) { 51 | NSDictionary* args = (NSDictionary*) rawArgs; 52 | 53 | NSValue *value = (NSValue *) args[@"__this__"]; 54 | if (value != nil && (NSNull*) value != [NSNull null]) { 55 | CGRect cgRect = value.CGRectValue; 56 | methodResult(@(cgRect.size.width)); 57 | } else { 58 | methodResult([FlutterError errorWithCode:@"目标对象为nul" 59 | message:@"目标对象为nul" 60 | details:@"目标对象为nul"]); 61 | } 62 | } else if ([@"CGRect::getHeight" isEqualToString:method]) { 63 | NSDictionary* args = (NSDictionary*) rawArgs; 64 | 65 | NSValue *value = (NSValue *) args[@"__this__"]; 66 | if (value != nil && (NSNull*) value != [NSNull null]) { 67 | CGRect cgRect = value.CGRectValue; 68 | methodResult(@(cgRect.size.height)); 69 | } else { 70 | methodResult([FlutterError errorWithCode:@"目标对象为nul" 71 | message:@"目标对象为nul" 72 | details:@"目标对象为nul"]); 73 | } 74 | } else { 75 | methodResult(FlutterMethodNotImplemented); 76 | } 77 | } 78 | 79 | -------------------------------------------------------------------------------- /ios/Classes/CGSizeHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // CGSizeHandler.h 3 | // foundation_fluttify 4 | // 5 | // Created by Yohom Bao on 2020/6/22. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | void CGSizeHandler(NSString* method, id args, FlutterResult methodResult); 14 | 15 | NS_ASSUME_NONNULL_END 16 | -------------------------------------------------------------------------------- /ios/Classes/CGSizeHandler.m: -------------------------------------------------------------------------------- 1 | // 2 | // CGSizeHandler.m 3 | // foundation_fluttify 4 | // 5 | // Created by Yohom Bao on 2020/6/22. 6 | // 7 | 8 | #import "CGSizeHandler.h" 9 | 10 | extern BOOL enableLog; 11 | 12 | void CGSizeHandler(NSString* method, id rawArgs, FlutterResult methodResult) { 13 | if ([@"CGSize::create" isEqualToString:method]) { 14 | NSDictionary* args = (NSDictionary*) rawArgs; 15 | 16 | CGFloat width = [(NSNumber*) args[@"width"] floatValue]; 17 | CGFloat height = [(NSNumber*) args[@"height"] floatValue]; 18 | 19 | CGSize rect = CGSizeMake(width, height); 20 | 21 | NSValue* result = [NSValue valueWithCGSize:rect]; 22 | 23 | methodResult(result); 24 | } else if ([@"CGSize::getWidth" isEqualToString:method]) { 25 | NSDictionary* args = (NSDictionary*) rawArgs; 26 | 27 | NSValue *__this__ = (NSValue *) args[@"__this__"]; 28 | if (__this__ != nil && (NSNull*) __this__ != [NSNull null]) { 29 | CGSize cgSize = __this__.CGSizeValue; 30 | methodResult(@(cgSize.width)); 31 | } else { 32 | methodResult([FlutterError errorWithCode:@"目标对象为nul" 33 | message:@"目标对象为nul" 34 | details:@"目标对象为nul"]); 35 | } 36 | } else if ([@"CGSize::getHeight" isEqualToString:method]) { 37 | NSDictionary* args = (NSDictionary*) rawArgs; 38 | 39 | NSValue *__this__ = (NSValue *) args[@"__this__"]; 40 | if (__this__ != nil && (NSNull*) __this__ != [NSNull null]) { 41 | CGSize cgSize = __this__.CGSizeValue; 42 | methodResult(@(cgSize.height)); 43 | } else { 44 | methodResult([FlutterError errorWithCode:@"目标对象为nul" 45 | message:@"目标对象为nul" 46 | details:@"目标对象为nul"]); 47 | } 48 | } else { 49 | methodResult(FlutterMethodNotImplemented); 50 | } 51 | } 52 | 53 | -------------------------------------------------------------------------------- /ios/Classes/FluttifyMessageCodec.h: -------------------------------------------------------------------------------- 1 | // 2 | // FluttifyMessageCodec.h 3 | // FMDB 4 | // 5 | // Created by Yohom Bao on 2020/8/31. 6 | // 7 | 8 | #import 9 | 10 | NS_ASSUME_NONNULL_BEGIN 11 | 12 | @interface FluttifyReaderWriter : FlutterStandardReaderWriter 13 | 14 | @end 15 | 16 | @interface FluttifyWriter : FlutterStandardWriter 17 | 18 | @end 19 | 20 | @interface FluttifyReader : FlutterStandardReader 21 | 22 | @end 23 | 24 | NS_ASSUME_NONNULL_END 25 | -------------------------------------------------------------------------------- /ios/Classes/FoundationFluttifyPlugin.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | NS_ASSUME_NONNULL_BEGIN 4 | 5 | @interface FoundationFluttifyPlugin : NSObject 6 | - (instancetype) initWithRegistrar:(NSObject*) registrar; 7 | @end 8 | 9 | NS_ASSUME_NONNULL_END 10 | -------------------------------------------------------------------------------- /ios/Classes/NSDataHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Yohom Bao on 2019/11/25. 3 | // 4 | 5 | #import 6 | #import 7 | 8 | NS_ASSUME_NONNULL_BEGIN 9 | 10 | void NSDataHandler(NSString* method, id args, FlutterResult methodResult); 11 | 12 | NS_ASSUME_NONNULL_END 13 | -------------------------------------------------------------------------------- /ios/Classes/NSDataHandler.m: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Yohom Bao on 2019/11/25. 3 | // 4 | 5 | #import "NSDataHandler.h" 6 | 7 | extern BOOL enableLog; 8 | 9 | void NSDataHandler(NSString* method, id rawArgs, FlutterResult methodResult) { 10 | if ([@"NSData::createWithUint8List" isEqualToString:method]) { 11 | NSDictionary* args = (NSDictionary*) rawArgs; 12 | 13 | FlutterStandardTypedData *data = (FlutterStandardTypedData *) args[@"data"]; 14 | if (data != nil && (NSNull*) data != [NSNull null]) { 15 | NSData *target = data.data; 16 | methodResult(target); 17 | } else { 18 | methodResult([FlutterError errorWithCode:@"目标对象为nul" 19 | message:@"目标对象为nul" 20 | details:@"目标对象为nul"]); 21 | } 22 | } else if ([@"NSData::getData" isEqualToString:method]) { 23 | NSDictionary* args = (NSDictionary*) rawArgs; 24 | 25 | NSData *target = (NSData *) args[@"__this__"]; 26 | if (target != nil && (NSNull*) target != [NSNull null]) { 27 | methodResult([FlutterStandardTypedData typedDataWithBytes:target]); 28 | } else { 29 | methodResult([FlutterError errorWithCode:@"目标对象为nul" 30 | message:@"目标对象为nul" 31 | details:@"目标对象为nul"]); 32 | } 33 | } else { 34 | methodResult(FlutterMethodNotImplemented); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /ios/Classes/NSDateHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDateHandler.h 3 | // foundation_fluttify 4 | // 5 | // Created by Yohom Bao on 2020/11/9. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | void NSDateHandler(NSString* method, id args, FlutterResult methodResult); 14 | 15 | NS_ASSUME_NONNULL_END 16 | -------------------------------------------------------------------------------- /ios/Classes/NSDateHandler.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDateHandler.m 3 | // foundation_fluttify 4 | // 5 | // Created by Yohom Bao on 2020/11/9. 6 | // 7 | 8 | #import "NSDateHandler.h" 9 | 10 | extern BOOL enableLog; 11 | 12 | void NSDateHandler(NSString* method, id rawArgs, FlutterResult methodResult) { 13 | if ([@"NSDate::get_timeIntervalSince1970" isEqualToString:method]) { 14 | NSDictionary* args = (NSDictionary*) rawArgs; 15 | 16 | NSDate *target = (NSDate *) args[@"__this__"]; 17 | if (target != nil && (NSNull*) target != [NSNull null]) { 18 | methodResult(@(target.timeIntervalSince1970)); 19 | } else { 20 | methodResult([FlutterError errorWithCode:@"目标对象为nul" 21 | message:@"目标对象为nul" 22 | details:@"目标对象为nul"]); 23 | } 24 | } else { 25 | methodResult(FlutterMethodNotImplemented); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /ios/Classes/NSErrorHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSErrorHandler.h 3 | // foundation_fluttify 4 | // 5 | // Created by Yohom Bao on 2020/4/5. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | void NSErrorHandler(NSString* method, id args, FlutterResult methodResult); 14 | 15 | NS_ASSUME_NONNULL_END 16 | -------------------------------------------------------------------------------- /ios/Classes/NSErrorHandler.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSErrorHandler.m 3 | // foundation_fluttify 4 | // 5 | // Created by Yohom Bao on 2020/4/5. 6 | // 7 | 8 | #import "NSErrorHandler.h" 9 | 10 | extern BOOL enableLog; 11 | 12 | void NSErrorHandler(NSString* method, id rawArgs, FlutterResult methodResult) { 13 | if ([@"NSError::getCode" isEqualToString:method]) { 14 | NSDictionary* args = (NSDictionary*) rawArgs; 15 | 16 | NSError *target = (NSError *) args[@"__this__"]; 17 | if (target != nil && (NSNull*) target != [NSNull null]) { 18 | methodResult(@(target.code)); 19 | } else { 20 | methodResult([FlutterError errorWithCode:@"目标对象为nul" 21 | message:@"目标对象为nul" 22 | details:@"目标对象为nul"]); 23 | } 24 | } else if ([@"NSError::getDescription" isEqualToString:method]) { 25 | NSDictionary* args = (NSDictionary*) rawArgs; 26 | 27 | NSError *target = (NSError *) args[@"__this__"]; 28 | if (target != nil && (NSNull*) target != [NSNull null]) { 29 | methodResult(target.description); 30 | } else { 31 | methodResult([FlutterError errorWithCode:@"目标对象为nul" 32 | message:@"目标对象为nul" 33 | details:@"目标对象为nul"]); 34 | } 35 | } else { 36 | methodResult(FlutterMethodNotImplemented); 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /ios/Classes/NSObjectHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObjectHandler.h 3 | // FMDB 4 | // 5 | // Created by Yohom Bao on 2020/9/14. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | void NSObjectHandler(NSString* method, id args, FlutterResult methodResult); 14 | 15 | NS_ASSUME_NONNULL_END 16 | -------------------------------------------------------------------------------- /ios/Classes/NSObjectHandler.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSObjectHandler.m 3 | // FMDB 4 | // 5 | // Created by Yohom Bao on 2020/9/14. 6 | // 7 | 8 | #import "NSObjectHandler.h" 9 | 10 | extern BOOL enableLog; 11 | 12 | void NSObjectHandler(NSString* method, id rawArgs, FlutterResult methodResult) { 13 | if ([@"NSObject::init" isEqualToString:method]) { 14 | NSDictionary* args = (NSDictionary*) rawArgs; 15 | 16 | NSObject *__this__ = (NSObject *) args[@"__this__"]; 17 | 18 | NSObject *target = [__this__ init]; 19 | 20 | methodResult(target); 21 | } else if ([@"NSObject::init_batch" isEqualToString:method]) { 22 | NSDictionary* args = (NSDictionary*) rawArgs; 23 | 24 | NSObject *__this__ = (NSObject *) args[@"__this__"]; 25 | 26 | NSObject *target = [__this__ init]; 27 | 28 | methodResult(target); 29 | } else { 30 | methodResult(FlutterMethodNotImplemented); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ios/Classes/PlatformService.h: -------------------------------------------------------------------------------- 1 | // 2 | // PlatformFactoryHandler.h 3 | // foundation_fluttify 4 | // 5 | // Created by Yohom Bao on 2019/11/22. 6 | // 7 | 8 | #import "FoundationFluttifyPlugin.h" 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | void PlatformService(NSString* method, id args, FlutterResult methodResult, NSObject* registrar); 14 | 15 | NS_ASSUME_NONNULL_END 16 | -------------------------------------------------------------------------------- /ios/Classes/UIColorHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIColorHandler.h 3 | // foundation_fluttify 4 | // 5 | // Created by Yohom Bao on 2020/3/9. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | void UIColorHandler(NSString* method, id args, FlutterResult methodResult); 14 | 15 | NS_ASSUME_NONNULL_END 16 | -------------------------------------------------------------------------------- /ios/Classes/UIColorHandler.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIColorHandler.m 3 | // foundation_fluttify 4 | // 5 | // Created by Yohom Bao on 2020/3/9. 6 | // 7 | 8 | #import "UIColorHandler.h" 9 | 10 | extern BOOL enableLog; 11 | 12 | void UIColorHandler(NSString* method, id rawArgs, FlutterResult methodResult) { 13 | if ([@"UIColor::create" isEqualToString:method]) { 14 | NSDictionary* args = (NSDictionary*) rawArgs; 15 | 16 | NSNumber *colorValue = (NSNumber *) args[@"colorValue"]; 17 | CGFloat alpha = (0xff000000 & [colorValue integerValue]) >> 24; 18 | CGFloat red = (0x00ff0000 & [colorValue integerValue]) >> 16; 19 | CGFloat green = (0x0000ff00 & [colorValue integerValue]) >> 8; 20 | CGFloat blue = (0x000000ff & [colorValue integerValue]) >> 0; 21 | 22 | UIColor *color = [UIColor colorWithRed:red / 0xFF green:green / 0xFF blue:blue / 0xFF alpha:alpha / 0xFF]; 23 | 24 | methodResult(color); 25 | } else { 26 | methodResult(FlutterMethodNotImplemented); 27 | } 28 | } 29 | 30 | -------------------------------------------------------------------------------- /ios/Classes/UIEdgeInsetsHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Yohom Bao on 2019/12/5. 3 | // 4 | 5 | #import 6 | #import 7 | 8 | NS_ASSUME_NONNULL_BEGIN 9 | 10 | void UIEdgeInsetsHandler(NSString* method, id args, FlutterResult methodResult); 11 | 12 | NS_ASSUME_NONNULL_END 13 | -------------------------------------------------------------------------------- /ios/Classes/UIEdgeInsetsHandler.m: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Yohom Bao on 2019/12/5. 3 | // 4 | 5 | #import "UIEdgeInsetsHandler.h" 6 | 7 | extern BOOL enableLog; 8 | 9 | void UIEdgeInsetsHandler(NSString* method, id rawArgs, FlutterResult methodResult) { 10 | if ([@"UIEdgeInsets::getTop" isEqualToString:method]) { 11 | NSDictionary* args = (NSDictionary*) rawArgs; 12 | 13 | NSValue *target = (NSValue *) args[@"__this__"]; 14 | if (target != nil && (NSNull*) target != [NSNull null]) { 15 | UIEdgeInsets insets = [target UIEdgeInsetsValue]; 16 | methodResult(@(insets.top)); 17 | } else { 18 | methodResult([FlutterError errorWithCode:@"目标对象为nul" 19 | message:@"目标对象为nul" 20 | details:@"目标对象为nul"]); 21 | } 22 | } else if ([@"UIEdgeInsets::getLeft" isEqualToString:method]) { 23 | NSDictionary* args = (NSDictionary*) rawArgs; 24 | 25 | NSValue *target = (NSValue *) args[@"__this__"]; 26 | if (target != nil && (NSNull*) target != [NSNull null]) { 27 | UIEdgeInsets insets = [target UIEdgeInsetsValue]; 28 | methodResult(@(insets.left)); 29 | } else { 30 | methodResult([FlutterError errorWithCode:@"目标对象为nul" 31 | message:@"目标对象为nul" 32 | details:@"目标对象为nul"]); 33 | } 34 | } else if ([@"UIEdgeInsets::getBottom" isEqualToString:method]) { 35 | NSDictionary* args = (NSDictionary*) rawArgs; 36 | 37 | NSValue *target = (NSValue *) args[@"__this__"]; 38 | if (target != nil && (NSNull*) target != [NSNull null]) { 39 | UIEdgeInsets insets = [target UIEdgeInsetsValue]; 40 | methodResult(@(insets.bottom)); 41 | } else { 42 | methodResult([FlutterError errorWithCode:@"目标对象为nul" 43 | message:@"目标对象为nul" 44 | details:@"目标对象为nul"]); 45 | } 46 | } else if ([@"UIEdgeInsets::getRight" isEqualToString:method]) { 47 | NSDictionary* args = (NSDictionary*) rawArgs; 48 | 49 | NSValue *target = (NSValue *) args[@"__this__"]; 50 | if (target != nil && (NSNull*) target != [NSNull null]) { 51 | UIEdgeInsets insets = [target UIEdgeInsetsValue]; 52 | methodResult(@(insets.right)); 53 | } else { 54 | methodResult([FlutterError errorWithCode:@"目标对象为nul" 55 | message:@"目标对象为nul" 56 | details:@"目标对象为nul"]); 57 | } 58 | } else if ([@"UIEdgeInsets::create" isEqualToString:method]) { 59 | NSDictionary* args = (NSDictionary*) rawArgs; 60 | 61 | NSNumber *top = (NSNumber *) args[@"top"]; 62 | NSNumber *left = (NSNumber *) args[@"left"]; 63 | NSNumber *bottom = (NSNumber *) args[@"bottom"]; 64 | NSNumber *right = (NSNumber *) args[@"right"]; 65 | 66 | UIEdgeInsets insets = UIEdgeInsetsMake([top floatValue], [left floatValue], [bottom floatValue], [right floatValue]); 67 | 68 | NSValue *valuePoint = [NSValue valueWithUIEdgeInsets:insets]; 69 | 70 | methodResult(valuePoint); 71 | } else { 72 | methodResult(FlutterMethodNotImplemented); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /ios/Classes/UIImageHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Yohom Bao on 2019/11/22. 3 | // 4 | 5 | #import 6 | #import 7 | #import "FoundationFluttifyPlugin.h" 8 | 9 | NS_ASSUME_NONNULL_BEGIN 10 | 11 | void UIImageHandler(NSString* method, id args, FlutterResult methodResult); 12 | 13 | NS_ASSUME_NONNULL_END 14 | -------------------------------------------------------------------------------- /ios/Classes/UIImageHandler.m: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Yohom Bao on 2019/11/22. 3 | // 4 | 5 | #import "UIImageHandler.h" 6 | 7 | extern BOOL enableLog; 8 | 9 | void UIImageHandler(NSString *method, id rawArgs, FlutterResult methodResult) { 10 | // UIImage::getData 11 | if ([@"UIImage::getData" isEqualToString:method]) { 12 | NSDictionary *args = (NSDictionary *) rawArgs; 13 | 14 | UIImage *target = (UIImage *) args[@"__this__"]; 15 | if (target != nil && (NSNull*) target != [NSNull null]) { 16 | NSData *data = UIImageJPEGRepresentation(target, 100); 17 | methodResult([FlutterStandardTypedData typedDataWithBytes:data]); 18 | } else { 19 | methodResult([FlutterError errorWithCode:@"目标对象为nul" 20 | message:@"目标对象为nul" 21 | details:@"目标对象为nul"]); 22 | } 23 | } 24 | // 创建UIImage 25 | else if ([@"UIImage::createUIImage" isEqualToString:method]) { 26 | NSDictionary *args = (NSDictionary *) rawArgs; 27 | 28 | FlutterStandardTypedData *bitmapBytes = (FlutterStandardTypedData *) args[@"bitmapBytes"]; 29 | 30 | UIImage *bitmap = [UIImage imageWithData:bitmapBytes.data scale:[UIScreen mainScreen].scale]; 31 | 32 | methodResult(bitmap); 33 | } 34 | // 创建UIImage 35 | else if ([@"UIImage::createWithPath" isEqualToString:method]) { 36 | NSDictionary *args = (NSDictionary *) rawArgs; 37 | 38 | NSString *resource = (NSString *) args[@"resource"]; 39 | NSString *type = (NSString *) args[@"type"]; 40 | NSString *fileName = (NSString *) args[@"fileName"]; 41 | 42 | NSString *path = [[NSBundle mainBundle] pathForResource:resource ofType:type]; 43 | path = [path stringByAppendingPathComponent:fileName]; 44 | 45 | UIImage *bitmap = [UIImage imageWithContentsOfFile:path]; 46 | 47 | methodResult(bitmap); 48 | } 49 | // 批量创建UIImage 50 | else if ([@"UIImage::createUIImage_batch" isEqualToString:method]) { 51 | NSArray *> *argsBatch = (NSArray *> *) rawArgs; 52 | 53 | NSMutableArray *resultList = [NSMutableArray array]; 54 | 55 | for (NSUInteger __i__ = 0; __i__ < argsBatch.count; __i__++) { 56 | NSDictionary *args = argsBatch[__i__]; 57 | 58 | FlutterStandardTypedData *bitmapBytes = (FlutterStandardTypedData *) args[@"bitmapBytes"]; 59 | 60 | UIImage *bitmap = [UIImage imageWithData:bitmapBytes.data scale:[UIScreen mainScreen].scale]; 61 | 62 | [resultList addObject:bitmap]; 63 | } 64 | 65 | methodResult(resultList); 66 | } else { 67 | methodResult(FlutterMethodNotImplemented); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /ios/Classes/UIImageViewHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImageViewHandler.h 3 | // foundation_fluttify 4 | // 5 | // Created by Yohom Bao on 2020/7/2. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | void UIImageViewHandler(NSString* method, id args, FlutterResult methodResult); 14 | 15 | NS_ASSUME_NONNULL_END 16 | -------------------------------------------------------------------------------- /ios/Classes/UIImageViewHandler.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImageViewHandler.m 3 | // foundation_fluttify 4 | // 5 | // Created by Yohom Bao on 2020/7/2. 6 | // 7 | 8 | #import "UIImageViewHandler.h" 9 | 10 | extern BOOL enableLog; 11 | 12 | void UIImageViewHandler(NSString *method, id rawArgs, FlutterResult methodResult) { 13 | if ([@"UIImageView::create" isEqualToString:method]) { 14 | NSDictionary *args = (NSDictionary *) rawArgs; 15 | 16 | UIImage *image = (UIImage *) args[@"image"]; 17 | 18 | UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; 19 | 20 | methodResult(imageView); 21 | } else { 22 | methodResult(FlutterMethodNotImplemented); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ios/Classes/UIViewControllerHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewControllerHandler.h 3 | // foundation_fluttify 4 | // 5 | // Created by Yohom Bao on 2020/6/6. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | void UIViewControllerHandler(NSString* method, id args, FlutterResult methodResult); 14 | 15 | NS_ASSUME_NONNULL_END 16 | -------------------------------------------------------------------------------- /ios/Classes/UIViewControllerHandler.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewControllerHandler.m 3 | // foundation_fluttify 4 | // 5 | // Created by Yohom Bao on 2020/6/6. 6 | // 7 | 8 | #import "UIViewControllerHandler.h" 9 | #import 10 | 11 | extern BOOL enableLog; 12 | 13 | void UIViewControllerHandler(NSString* method, id args, FlutterResult methodResult) { 14 | if ([@"UIViewController::get" isEqualToString:method]) { 15 | UIViewController* controller = [UIApplication sharedApplication].keyWindow.rootViewController; 16 | 17 | methodResult(controller); 18 | } else { 19 | methodResult(FlutterMethodNotImplemented); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ios/Classes/UIViewHandler.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Yohom Bao on 2019/11/22. 3 | // 4 | 5 | #import 6 | #import 7 | 8 | NS_ASSUME_NONNULL_BEGIN 9 | 10 | void UIViewHandler(NSString* method, id args, FlutterResult methodResult); 11 | 12 | NS_ASSUME_NONNULL_END 13 | -------------------------------------------------------------------------------- /ios/Classes/platform_view/UIViewFactory.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewFactory.h 3 | // foundation_fluttify 4 | // 5 | // Created by Yohom Bao on 2020/4/17. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface UIViewFactory : NSObject 14 | 15 | - (instancetype)initWithRegistrar:(NSObject *)registrar; 16 | 17 | @property(nonatomic) NSObject* registrar; 18 | 19 | @end 20 | 21 | @interface UIViewPlatformView : NSObject 22 | 23 | - (instancetype)initWithViewId:(int64_t)viewId frame:(CGRect)frame registrar:(NSObject *)registrar; 24 | 25 | @property(nonatomic) NSObject* registrar; 26 | 27 | @end 28 | 29 | NS_ASSUME_NONNULL_END 30 | -------------------------------------------------------------------------------- /ios/Classes/platform_view/UIViewFactory.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewFactory.m 3 | // foundation_fluttify 4 | // 5 | // Created by Yohom Bao on 2020/4/17. 6 | // 7 | 8 | #import "UIViewFactory.h" 9 | #import "FoundationFluttifyPlugin.h" 10 | 11 | // Dart端随机存取对象的容器 12 | extern NSMutableDictionary *HEAP; 13 | 14 | @implementation UIViewFactory { 15 | } 16 | 17 | - (instancetype)initWithRegistrar:(NSObject *)registrar { 18 | self = [super init]; 19 | if (self) { 20 | _registrar = registrar; 21 | } 22 | 23 | return self; 24 | } 25 | 26 | - (NSObject *)createWithFrame:(CGRect)frame viewIdentifier:(int64_t)viewId arguments:(id _Nullable)args { 27 | return [[UIViewPlatformView alloc] initWithViewId:viewId frame: frame registrar:_registrar]; 28 | } 29 | 30 | @end 31 | 32 | @implementation UIViewPlatformView { 33 | int64_t _viewId; 34 | CGRect _frame; 35 | UIView* _view; 36 | } 37 | 38 | - (instancetype)initWithViewId:(int64_t)viewId frame:(CGRect)frame registrar:(NSObject *)registrar { 39 | self = [super init]; 40 | if (self) { 41 | _viewId = viewId; 42 | _registrar = registrar; 43 | _frame = frame; 44 | } 45 | 46 | return self; 47 | } 48 | 49 | - (UIView *)view { 50 | if (_view == nil) { 51 | _view = [[UIView alloc] initWithFrame:_frame]; 52 | } 53 | // 这里用一个magic number调整一下id 54 | HEAP[[NSString stringWithFormat:@"%@", @(2147483647 - _viewId)]] = _view; 55 | HEAP[[NSString stringWithFormat:@"%@:%@", @"UIView", @(_view.hash)]] = _view; 56 | return _view; 57 | } 58 | 59 | @end 60 | 61 | -------------------------------------------------------------------------------- /ios/foundation_fluttify.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html 3 | # 4 | Pod::Spec.new do |s| 5 | s.name = 'foundation_fluttify' 6 | s.version = '0.0.1' 7 | s.summary = 'A new Flutter project.' 8 | s.description = <<-DESC 9 | A new Flutter project. 10 | DESC 11 | s.homepage = 'http://example.com' 12 | s.license = { :file => '../LICENSE' } 13 | s.author = { 'Your Company' => 'email@example.com' } 14 | s.source = { :path => '.' } 15 | s.source_files = 'Classes/**/*' 16 | s.public_header_files = 'Classes/**/*.h' 17 | s.dependency 'Flutter' 18 | 19 | s.ios.deployment_target = '8.0' 20 | s.static_framework = true 21 | # 系统framework 22 | s.frameworks = [] 23 | end 24 | 25 | -------------------------------------------------------------------------------- /lib/foundation_fluttify.dart: -------------------------------------------------------------------------------- 1 | library foundation_fluttify; 2 | 3 | export 'src/extension/image_provider.x.dart'; 4 | export 'src/function/functions.dart'; 5 | export 'src/object/obejcts.dart'; 6 | export 'src/type/core/array.dart'; 7 | export 'src/type/core/broadcast_event_channel.dart'; 8 | export 'src/type/core/fluttify_message_codec.dart'; 9 | export 'src/type/core/ref.dart'; 10 | export 'src/type/core/typedefs.dart'; 11 | export 'src/type/platform/android_type/android/app/activity.dart'; 12 | export 'src/type/platform/android_type/android/app/application.dart'; 13 | export 'src/type/platform/android_type/android/app/notification.dart'; 14 | export 'src/type/platform/android_type/android/app/pending_intent.dart'; 15 | export 'src/type/platform/android_type/android/content/broadcast_receiver.dart'; 16 | export 'src/type/platform/android_type/android/content/content_provider.dart'; 17 | export 'src/type/platform/android_type/android/content/context.dart'; 18 | export 'src/type/platform/android_type/android/content/intent.dart'; 19 | export 'src/type/platform/android_type/android/content/intent_filter.dart'; 20 | export 'src/type/platform/android_type/android/graphics/bitmap.dart'; 21 | export 'src/type/platform/android_type/android/graphics/drawable/drawable.dart'; 22 | export 'src/type/platform/android_type/android/graphics/point.dart'; 23 | export 'src/type/platform/android_type/android/graphics/point_f.dart'; 24 | export 'src/type/platform/android_type/android/location/location.dart'; 25 | export 'src/type/platform/android_type/android/opengl/gl_surface_view.dart'; 26 | export 'src/type/platform/android_type/android/os/binder.dart'; 27 | export 'src/type/platform/android_type/android/os/bundle.dart'; 28 | export 'src/type/platform/android_type/android/os/parcelable.dart'; 29 | export 'src/type/platform/android_type/android/util/pair.dart'; 30 | export 'src/type/platform/android_type/android/view/motion_event.dart'; 31 | export 'src/type/platform/android_type/android/view/surface_holder.dart'; 32 | export 'src/type/platform/android_type/android/view/surface_view.dart'; 33 | export 'src/type/platform/android_type/android/view/view.dart'; 34 | export 'src/type/platform/android_type/android/view/view_group.dart'; 35 | export 'src/type/platform/android_type/android/widget/frame_layout.dart'; 36 | export 'src/type/platform/android_type/android/widget/image_view.dart'; 37 | export 'src/type/platform/android_type/android/widget/linear_layout.dart'; 38 | export 'src/type/platform/android_type/android/widget/relative_layout.dart'; 39 | export 'src/type/platform/android_type/android/widget/text_view.dart'; 40 | export 'src/type/platform/android_type/java/io/closeable.dart'; 41 | export 'src/type/platform/android_type/java/io/file.dart'; 42 | export 'src/type/platform/android_type/java/io/serializable.dart'; 43 | export 'src/type/platform/android_type/java/lang/object.dart'; 44 | export 'src/type/platform/android_type/java/lang/throwable.dart'; 45 | export 'src/type/platform/android_type/org/json/json_object.dart'; 46 | export 'src/type/platform/ios_type/av_audio_session_category_options.dart'; 47 | export 'src/type/platform/ios_type/ca_action.dart'; 48 | export 'src/type/platform/ios_type/ca_animation.dart'; 49 | export 'src/type/platform/ios_type/ca_basic_animation.dart'; 50 | export 'src/type/platform/ios_type/ca_media_timing.dart'; 51 | export 'src/type/platform/ios_type/ca_property_animation.dart'; 52 | export 'src/type/platform/ios_type/cg_point.dart'; 53 | export 'src/type/platform/ios_type/cg_rect.dart'; 54 | export 'src/type/platform/ios_type/cg_size.dart'; 55 | export 'src/type/platform/ios_type/ns_coding.dart'; 56 | export 'src/type/platform/ios_type/ns_copying.dart'; 57 | export 'src/type/platform/ios_type/ns_data.dart'; 58 | export 'src/type/platform/ios_type/ns_date.dart'; 59 | export 'src/type/platform/ios_type/ns_error.dart'; 60 | export 'src/type/platform/ios_type/ns_mutable_copying.dart'; 61 | export 'src/type/platform/ios_type/ns_object.dart'; 62 | export 'src/type/platform/ios_type/ns_operation.dart'; 63 | export 'src/type/platform/ios_type/ns_url.dart'; 64 | export 'src/type/platform/ios_type/ns_user_activity.dart'; 65 | export 'src/type/platform/ios_type/ns_value.dart'; 66 | export 'src/type/platform/ios_type/ui_application.dart'; 67 | export 'src/type/platform/ios_type/ui_application_shortcut_item.dart'; 68 | export 'src/type/platform/ios_type/ui_bar_style.dart'; 69 | export 'src/type/platform/ios_type/ui_color.dart'; 70 | export 'src/type/platform/ios_type/ui_control.dart'; 71 | export 'src/type/platform/ios_type/ui_edge_insets.dart'; 72 | export 'src/type/platform/ios_type/ui_image.dart'; 73 | export 'src/type/platform/ios_type/ui_image_view.dart'; 74 | export 'src/type/platform/ios_type/ui_status_bar_style.dart'; 75 | export 'src/type/platform/ios_type/ui_user_notification_settings.dart'; 76 | export 'src/type/platform/ios_type/ui_view.dart'; 77 | export 'src/type/platform/ios_type/ui_view_controller.dart'; 78 | export 'src/type/widget/android_opengl_GLSurfaceView.widget.dart'; 79 | export 'src/type/widget/android_view_SurfaceView.widget.dart'; 80 | export 'src/type/widget/android_widget_FrameLayout.widget.dart'; 81 | export 'src/type/widget/scoped_release_pool.widget.dart'; 82 | export 'src/type/widget/ui_view.widget.dart'; 83 | -------------------------------------------------------------------------------- /lib/src/extension/image_provider.x.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:typed_data'; 3 | import 'dart:ui'; 4 | 5 | import 'package:flutter/material.dart'; 6 | 7 | Map _cache = {}; 8 | 9 | extension ImageProviderX on ImageProvider { 10 | Future toImageData(ImageConfiguration config) async { 11 | final completer = Completer(); 12 | final key = await obtainKey(config); 13 | if (_cache.containsKey(key.toString())) { 14 | debugPrint('命中缓存'); 15 | completer.complete(_cache[key.toString()]); 16 | } else { 17 | late ImageStreamListener listener; 18 | ImageStream stream = resolve(config); //获取图片流 19 | listener = ImageStreamListener((imageInfo, sync) async { 20 | final byteData = 21 | await imageInfo.image.toByteData(format: ImageByteFormat.png); 22 | final result = byteData?.buffer.asUint8List(); 23 | if (result != null) { 24 | _cache[key.toString()] = result; 25 | } 26 | 27 | if (!completer.isCompleted) completer.complete(result); 28 | 29 | stream.removeListener(listener); //移除监听 30 | }); 31 | stream.addListener(listener); 32 | } 33 | 34 | return completer.future; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/src/type/core/array.dart: -------------------------------------------------------------------------------- 1 | class Array { 2 | Array.ofList(this.data); 3 | 4 | final List data; 5 | } 6 | -------------------------------------------------------------------------------- /lib/src/type/core/broadcast_event_channel.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/services.dart'; 2 | import 'package:foundation_fluttify/src/type/platform/android_type/android/content/intent.dart'; 3 | 4 | class FluttifyBroadcastEventChannel extends EventChannel { 5 | const FluttifyBroadcastEventChannel(String name) : super(name); 6 | 7 | @override 8 | Stream receiveBroadcastStream([dynamic arguments]) { 9 | return super 10 | .receiveBroadcastStream(arguments) 11 | .map((event) => android_content_Intent()..refId = event); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /lib/src/type/core/stack.dart: -------------------------------------------------------------------------------- 1 | import 'dart:collection'; 2 | 3 | class Stack { 4 | final ListQueue _list = ListQueue(); 5 | 6 | /// check if the stack is empty. 7 | bool get isEmpty => _list.isEmpty; 8 | 9 | /// check if the stack is not empty. 10 | bool get isNotEmpty => _list.isNotEmpty; 11 | 12 | /// push element in top of the stack. 13 | void push(T e) { 14 | _list.addLast(e); 15 | } 16 | 17 | /// get the top of the stack and delete it. 18 | T pop() { 19 | T res = _list.last; 20 | _list.removeLast(); 21 | return res; 22 | } 23 | 24 | /// get the top of the stack without deleting it. 25 | T? peek() { 26 | if (_list.isEmpty) return null; 27 | return _list.last; 28 | } 29 | 30 | /// get the size of the stack. 31 | int size() { 32 | return _list.length; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/app/activity.dart: -------------------------------------------------------------------------------- 1 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 2 | import 'package:foundation_fluttify/src/object/obejcts.dart'; 3 | import 'package:foundation_fluttify/src/type/platform/android_type/android/content/context.dart'; 4 | import 'package:foundation_fluttify/src/type/platform/android_type/android/content/intent.dart'; 5 | 6 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 7 | class android_app_Activity extends android_content_Context { 8 | @override 9 | final String tag__ = 'platform'; 10 | 11 | static Future get() async { 12 | final result = 13 | await kMethodChannel.invokeMethod('android.app.Activity::get'); 14 | return android_app_Activity()..refId = result?.refId; 15 | } 16 | 17 | Future get intent async { 18 | final result = await kMethodChannel.invokeMethod( 19 | 'android.app.Activity::getIntent', {'__this__': this}); 20 | return android_content_Intent()..refId = result?.refId; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/app/application.dart: -------------------------------------------------------------------------------- 1 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 2 | import 'package:foundation_fluttify/src/object/obejcts.dart'; 3 | import 'package:foundation_fluttify/src/type/platform/android_type/android/content/context.dart'; 4 | 5 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 6 | class android_app_Application extends android_content_Context { 7 | @override 8 | final String tag__ = 'platform'; 9 | 10 | static Future get() async { 11 | final result = 12 | await kMethodChannel.invokeMethod('android.app.Application::get'); 13 | return android_app_Application()..refId = result?.refId; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/app/notification.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 3 | import 'package:foundation_fluttify/src/object/obejcts.dart'; 4 | import 'package:foundation_fluttify/src/type/platform/android_type/android/content/context.dart'; 5 | import 'package:foundation_fluttify/src/type/platform/android_type/android/content/intent.dart'; 6 | 7 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 8 | class android_app_Notification extends java_lang_Object { 9 | @override 10 | final String tag__ = 'platform'; 11 | 12 | static Future create({ 13 | required String contentTitle, 14 | required String contentText, 15 | int? when, 16 | required String channelId, 17 | required String channelName, 18 | bool enableLights = true, 19 | bool showBadge = true, 20 | }) async { 21 | final result = await kMethodChannel.invokeMethod( 22 | 'android.app.Notification::create', 23 | { 24 | 'contentTitle': contentTitle, 25 | 'contentText': contentText, 26 | 'when': when ?? DateTime.now().millisecondsSinceEpoch, 27 | 'channelId': channelId, 28 | 'channelName': channelName, 29 | 'enableLights': enableLights, 30 | 'showBadge': showBadge, 31 | }, 32 | ); 33 | return android_app_Notification()..refId = result?.refId; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/app/pending_intent.dart: -------------------------------------------------------------------------------- 1 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 2 | import 'package:foundation_fluttify/src/object/obejcts.dart'; 3 | import 'package:foundation_fluttify/src/type/platform/android_type/android/content/context.dart'; 4 | import 'package:foundation_fluttify/src/type/platform/android_type/android/content/intent.dart'; 5 | 6 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 7 | class android_app_PendingIntent extends java_lang_Object 8 | with android_os_Parcelable { 9 | @override 10 | final String tag__ = 'platform'; 11 | } 12 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/content/broadcast_receiver.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/cupertino.dart'; 2 | import 'package:flutter/services.dart'; 3 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 4 | import 'package:foundation_fluttify/src/object/obejcts.dart'; 5 | import 'package:foundation_fluttify/src/type/platform/android_type/java/lang/object.dart'; 6 | 7 | import 'intent.dart'; 8 | 9 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 10 | class android_content_BroadcastReceiver extends java_lang_Object { 11 | @override 12 | final String tag__ = 'platform'; 13 | 14 | Future create( 15 | ValueChanged onReceive, 16 | ) async { 17 | final result = await kMethodChannel.invokeMethod( 18 | 'android.content.Context::registerReceiver', 19 | { 20 | '__this__': this, 21 | 'broadcastReceiver': '', 22 | 'intentFilter': '', 23 | }, 24 | ); 25 | 26 | MethodChannel('android.content.BroadcastReceiver::create::Callback') 27 | .setMethodCallHandler((call) async { 28 | if (call.method == 29 | 'Callback::android.content.BroadcastReceiver::onReceive') { 30 | final intentRefId = call.arguments['intent'] as String; 31 | final intent = android_content_Intent()..refId = intentRefId; 32 | onReceive(intent); 33 | } 34 | }); 35 | return android_content_BroadcastReceiver()..refId = result?.refId; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/content/content_provider.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:foundation_fluttify/src/type/platform/android_type/java/lang/object.dart'; 4 | 5 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 6 | class android_content_ContentProvider extends java_lang_Object { 7 | @override 8 | final String tag__ = 'platform'; 9 | } 10 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/content/context.dart: -------------------------------------------------------------------------------- 1 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 2 | import 'package:foundation_fluttify/src/object/obejcts.dart'; 3 | import 'package:foundation_fluttify/src/type/platform/android_type/java/lang/object.dart'; 4 | 5 | import 'broadcast_receiver.dart'; 6 | import 'intent.dart'; 7 | import 'intent_filter.dart'; 8 | 9 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 10 | class android_content_Context extends java_lang_Object { 11 | @override 12 | final String tag__ = 'platform'; 13 | 14 | Future registerReceiver( 15 | android_content_BroadcastReceiver receiver, 16 | android_content_IntentFilter intentFilter, 17 | ) async { 18 | final result = await kMethodChannel.invokeMethod( 19 | 'android.content.Context::registerReceiver', 20 | { 21 | '__this__': this, 22 | 'broadcastReceiver': receiver, 23 | 'intentFilter': intentFilter, 24 | }, 25 | ); 26 | return android_content_Intent()..refId = result?.refId; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/content/intent.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:foundation_fluttify/src/object/obejcts.dart'; 4 | import 'package:foundation_fluttify/src/type/platform/android_type/android/os/bundle.dart'; 5 | import 'package:foundation_fluttify/src/type/platform/android_type/java/lang/object.dart'; 6 | 7 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 8 | class android_content_Intent extends java_lang_Object { 9 | @override 10 | final String tag__ = 'platform'; 11 | 12 | Future?> get bundle async { 13 | final result = await kMethodChannel.invokeMapMethod( 14 | 'android.content.Intent::getBundle', {'__this__': this}); 15 | return result; 16 | } 17 | 18 | Future get action async { 19 | final result = await kMethodChannel 20 | .invokeMethod('android.content.Intent::getAction', {'__this__': this}); 21 | return result; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/content/intent_filter.dart: -------------------------------------------------------------------------------- 1 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 2 | import 'package:foundation_fluttify/src/object/obejcts.dart'; 3 | import 'package:foundation_fluttify/src/type/platform/android_type/java/lang/object.dart'; 4 | 5 | import 'intent.dart'; 6 | 7 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 8 | class android_content_IntentFilter extends java_lang_Object { 9 | @override 10 | final String tag__ = 'platform'; 11 | 12 | Future create(String action) async { 13 | final result = await kMethodChannel.invokeMethod( 14 | 'android.content.IntentFilter::create', 15 | {'__this__': this, 'action': action}, 16 | ); 17 | return android_content_IntentFilter()..refId = result?.refId; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/graphics/bitmap.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 2 | 3 | import 'dart:typed_data'; 4 | 5 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 6 | import 'package:foundation_fluttify/src/object/obejcts.dart'; 7 | import 'package:foundation_fluttify/src/type/platform/android_type/java/lang/object.dart'; 8 | 9 | class android_graphics_Bitmap extends java_lang_Object { 10 | @override 11 | final String tag__ = 'platform'; 12 | 13 | static Future create(Uint8List bitmapBytes) async { 14 | final result = await kMethodChannel.invokeMethod( 15 | 'android.graphics.Bitmap::create', {'bitmapBytes': bitmapBytes}); 16 | return android_graphics_Bitmap()..refId = result?.refId; 17 | } 18 | 19 | static Future createWithDrawable( 20 | String drawableId, 21 | ) async { 22 | final result = await kMethodChannel.invokeMethod( 23 | 'android.graphics.Bitmap::createWithDrawable', 24 | {'drawableId': drawableId}, 25 | ); 26 | return android_graphics_Bitmap()..refId = result?.refId; 27 | } 28 | 29 | static Future?> create_batch( 30 | List bitmapBytesBatch, 31 | ) async { 32 | final resultBatch = await kMethodChannel.invokeListMethod( 33 | 'android.graphics.Bitmap::create_batch', 34 | [ 35 | for (final bitmapBytes in bitmapBytesBatch) {'bitmapBytes': bitmapBytes} 36 | ], 37 | ); 38 | return resultBatch 39 | ?.map((it) => android_graphics_Bitmap()..refId = it.refId) 40 | .toList(); 41 | } 42 | 43 | Future get data { 44 | return kMethodChannel 45 | .invokeMethod('android.graphics.Bitmap::getData', {'__this__': this}); 46 | } 47 | 48 | Future recycle() { 49 | return kMethodChannel 50 | .invokeMethod('android.graphics.Bitmap::recycle', {'__this__': this}); 51 | } 52 | 53 | Future get isRecycled { 54 | return kMethodChannel.invokeMethod( 55 | 'android.graphics.Bitmap::isRecycled', {'__this__': this}); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/graphics/drawable/drawable.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 2 | import 'package:foundation_fluttify/src/type/platform/android_type/java/lang/object.dart'; 3 | 4 | class android_graphics_drawable_Drawable extends java_lang_Object { 5 | @override 6 | final String tag__ = 'platform'; 7 | } 8 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/graphics/point.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 2 | 3 | import 'dart:typed_data'; 4 | 5 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 6 | import 'package:foundation_fluttify/src/object/obejcts.dart'; 7 | import 'package:foundation_fluttify/src/type/platform/android_type/java/lang/object.dart'; 8 | 9 | class android_graphics_Point extends java_lang_Object { 10 | @override 11 | final String tag__ = 'platform'; 12 | 13 | static Future create(int x, int y) async { 14 | final result = await kMethodChannel 15 | .invokeMethod('android.graphics.Point::create', {'x': x, 'y': y}); 16 | return android_graphics_Point()..refId = result?.refId; 17 | } 18 | 19 | Future get x { 20 | return kMethodChannel 21 | .invokeMethod('android.graphics.Point::getX', {'__this__': this}); 22 | } 23 | 24 | Future get y { 25 | return kMethodChannel 26 | .invokeMethod('android.graphics.Point::getY', {'__this__': this}); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/graphics/point_f.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 2 | import 'package:foundation_fluttify/src/type/platform/android_type/java/lang/object.dart'; 3 | 4 | class android_graphics_PointF extends java_lang_Object { 5 | @override 6 | final String tag__ = 'platform'; 7 | } 8 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/location/location.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 2 | 3 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 4 | import 'package:foundation_fluttify/src/object/obejcts.dart'; 5 | import 'package:foundation_fluttify/src/type/platform/android_type/java/lang/object.dart'; 6 | 7 | class android_location_Location extends java_lang_Object { 8 | static Future create(String provider) async { 9 | final result = await kMethodChannel.invokeMethod( 10 | 'android.location.Location::create', {'provider': provider}); 11 | return android_location_Location()..refId = result?.refId; 12 | } 13 | 14 | @override 15 | final String tag__ = 'platform'; 16 | 17 | Future get latitude { 18 | return kMethodChannel.invokeMethod( 19 | 'android.location.Location::getLatitude', {'__this__': this}); 20 | } 21 | 22 | Future get longitude { 23 | return kMethodChannel.invokeMethod( 24 | 'android.location.Location::getLongitude', {'__this__': this}); 25 | } 26 | 27 | Future get bearing { 28 | return kMethodChannel.invokeMethod( 29 | 'android.location.Location::getBearing', {'__this__': this}); 30 | } 31 | 32 | Future get altitude { 33 | return kMethodChannel.invokeMethod( 34 | 'android.location.Location::getAltitude', {'__this__': this}); 35 | } 36 | 37 | Future get accuracy { 38 | return kMethodChannel.invokeMethod( 39 | 'android.location.Location::getAccuracy', {'__this__': this}); 40 | } 41 | 42 | Future get speed { 43 | return kMethodChannel.invokeMethod( 44 | 'android.location.Location::getSpeed', {'__this__': this}); 45 | } 46 | 47 | Future setLatitude(double latitude) async { 48 | return kMethodChannel.invokeMethod( 49 | 'android.location.Location::setLatitude', 50 | {'__this__': this, 'latitude': latitude}, 51 | ); 52 | } 53 | 54 | Future setLongitude(double longitude) async { 55 | return kMethodChannel.invokeMethod( 56 | 'android.location.Location::setLongitude', 57 | {'__this__': this, 'longitude': longitude}, 58 | ); 59 | } 60 | 61 | Future setBearing(double bearing) async { 62 | return kMethodChannel.invokeMethod( 63 | 'android.location.Location::setBearing', 64 | {'__this__': this, 'bearing': bearing}, 65 | ); 66 | } 67 | 68 | Future setAltitude(double altitude) async { 69 | return kMethodChannel.invokeMethod( 70 | 'android.location.Location::setAltitude', 71 | {'__this__': this, 'altitude': altitude}, 72 | ); 73 | } 74 | 75 | Future setAccuracy(double accuracy) async { 76 | return kMethodChannel.invokeMethod( 77 | 'android.location.Location::setAccuracy', 78 | {'__this__': this, 'accuracy': accuracy}, 79 | ); 80 | } 81 | 82 | Future setSpeed(double speed) async { 83 | return kMethodChannel.invokeMethod( 84 | 'android.location.Location::setSpeed', 85 | {'__this__': this, 'speed': speed}, 86 | ); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/opengl/gl_surface_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 2 | 3 | class android_opengl_GLSurfaceView extends android_view_SurfaceView { 4 | @override 5 | final String tag__ = 'platform'; 6 | } 7 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/os/binder.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 2 | import 'package:foundation_fluttify/src/type/platform/android_type/java/lang/object.dart'; 3 | 4 | class android_os_Binder extends java_lang_Object { 5 | @override 6 | final String tag__ = 'platform'; 7 | } 8 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/os/bundle.dart: -------------------------------------------------------------------------------- 1 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 2 | import 'package:foundation_fluttify/src/object/obejcts.dart'; 3 | import 'package:foundation_fluttify/src/type/platform/android_type/java/lang/object.dart'; 4 | 5 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 6 | class android_os_Bundle extends java_lang_Object { 7 | static Future create() async { 8 | final result = 9 | await kMethodChannel.invokeMethod('android.os.Bundle::create'); 10 | return android_os_Bundle()..refId = result?.refId; 11 | } 12 | 13 | @override 14 | final String tag__ = 'platform'; 15 | 16 | Future putString(String key, String value) { 17 | return kMethodChannel.invokeMethod('android.os.Bundle::putString', { 18 | '__this__': this, 19 | 'key': key, 20 | 'value': value, 21 | }); 22 | } 23 | 24 | Future putInt(String key, int value) { 25 | return kMethodChannel.invokeMethod('android.os.Bundle::putInt', { 26 | '__this__': this, 27 | 'key': key, 28 | 'value': value, 29 | }); 30 | } 31 | 32 | Future getString(String key) { 33 | return kMethodChannel.invokeMethod( 34 | 'android.os.Bundle::getString', 35 | {'__this__': this, 'key': key}, 36 | ); 37 | } 38 | 39 | Future getInt(String key) { 40 | return kMethodChannel.invokeMethod( 41 | 'android.os.Bundle::getInt', 42 | {'__this__': this, 'key': key}, 43 | ); 44 | } 45 | 46 | Future getDouble(String key) { 47 | return kMethodChannel.invokeMethod( 48 | 'android.os.Bundle::getDouble', 49 | {'__this__': this, 'key': key}, 50 | ); 51 | } 52 | 53 | Future getFloat(String key) { 54 | return kMethodChannel.invokeMethod( 55 | 'android.os.Bundle::getFloat', 56 | {'__this__': this, 'key': key}, 57 | ); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/os/parcelable.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 2 | import 'package:foundation_fluttify/src/type/platform/android_type/java/lang/object.dart'; 3 | 4 | class _android_os_Parcelable_SUB extends java_lang_Object 5 | with android_os_Parcelable {} 6 | 7 | mixin android_os_Parcelable on java_lang_Object { 8 | @override 9 | final String tag__ = 'platform'; 10 | 11 | static android_os_Parcelable subInstance() { 12 | return _android_os_Parcelable_SUB(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/util/pair.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 2 | 3 | 4 | 5 | import 'package:foundation_fluttify/src/object/obejcts.dart'; 6 | import 'package:foundation_fluttify/src/type/platform/android_type/java/lang/object.dart'; 7 | 8 | class android_util_Pair extends java_lang_Object { 9 | @override 10 | final String tag__ = 'platform'; 11 | 12 | Future get first { 13 | return kMethodChannel 14 | .invokeMethod('android.util.Pair::getFirst', {'__this__': this}); 15 | } 16 | 17 | Future get second { 18 | return kMethodChannel 19 | .invokeMethod('android.util.Pair::getSecond', {'__this__': this}); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/view/motion_event.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 2 | import 'package:foundation_fluttify/src/type/platform/android_type/java/lang/object.dart'; 3 | 4 | class android_view_MotionEvent extends java_lang_Object { 5 | @override 6 | final String tag__ = 'platform'; 7 | } 8 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/view/surface_holder.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/services.dart'; 2 | import 'package:flutter/widgets.dart'; 3 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 4 | 5 | class _android_view_SurfaceHolder_SUB extends java_lang_Object 6 | with android_view_SurfaceHolder {} 7 | 8 | mixin android_view_SurfaceHolder on java_lang_Object { 9 | static android_view_SurfaceHolder subInstance() => 10 | _android_view_SurfaceHolder_SUB(); 11 | 12 | @override 13 | final String tag__ = 'platform'; 14 | 15 | Future addCallback( 16 | android_view_SurfaceHolder_Callback callback, 17 | ) async { 18 | // invoke native method 19 | await kMethodChannel.invokeMethod( 20 | 'android.view.SurfaceHolder::addCallback', 21 | {'__this__': this, 'callback': callback}, 22 | ); 23 | 24 | // handle native call 25 | MethodChannel( 26 | 'android.view.SurfaceHolder::addCallback::Callback', 27 | kMethodCodec, 28 | ).setMethodCallHandler((methodCall) async { 29 | try { 30 | final args = methodCall.arguments as Map?; 31 | switch (methodCall.method) { 32 | case 'Callback::android.view.SurfaceHolder.Callback::surfaceCreated': 33 | callback.surfaceCreated(args!['var1']); 34 | break; 35 | case 'Callback::android.view.SurfaceHolder.Callback::surfaceChanged': 36 | callback.surfaceChanged( 37 | args!['var1'], 38 | args['var2'], 39 | args['var3'], 40 | args['var4'], 41 | ); 42 | break; 43 | case 'Callback::android.view.SurfaceHolder.Callback::surfaceDestroyed': 44 | callback.surfaceDestroyed(args!['var1']); 45 | break; 46 | default: 47 | throw MissingPluginException('方法${methodCall.method}未实现'); 48 | } 49 | } catch (e) { 50 | debugPrint(e.toString()); 51 | rethrow; 52 | } 53 | }); 54 | } 55 | } 56 | 57 | mixin android_view_SurfaceHolder_Callback on java_lang_Object { 58 | @override 59 | final String tag__ = 'platform'; 60 | 61 | void surfaceCreated(android_view_SurfaceHolder? var1) {} 62 | 63 | void surfaceChanged( 64 | android_view_SurfaceHolder? var1, 65 | int? var2, 66 | int? var3, 67 | int? var4, 68 | ) {} 69 | 70 | void surfaceDestroyed(android_view_SurfaceHolder? var1) {} 71 | } 72 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/view/surface_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 2 | 3 | class android_view_SurfaceView extends android_view_View { 4 | @override 5 | final String tag__ = 'platform'; 6 | 7 | Future getHolder() async { 8 | final result = await kMethodChannel.invokeMethod( 9 | 'android.view.SurfaceView::getHolder', 10 | {'__this__': this}, 11 | ); 12 | return android_view_SurfaceHolder.subInstance()..refId = result?.refId; 13 | } 14 | 15 | Future setZOrderOnTop(bool onTop) async { 16 | await kMethodChannel.invokeMethod( 17 | 'android.view.SurfaceView::setZOrderOnTop', 18 | {'__this__': this, 'onTop': onTop}, 19 | ); 20 | } 21 | 22 | Future setZOrderMediaOverlay(bool isMediaOverlay) async { 23 | await kMethodChannel.invokeMethod( 24 | 'android.view.SurfaceView::setZOrderMediaOverlay', 25 | {'__this__': this, 'isMediaOverlay': isMediaOverlay}, 26 | ); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/view/view.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 2 | import 'package:foundation_fluttify/src/object/obejcts.dart'; 3 | import 'package:foundation_fluttify/src/type/platform/android_type/java/lang/object.dart'; 4 | 5 | class android_view_View extends java_lang_Object { 6 | @override 7 | final String tag__ = 'platform'; 8 | } 9 | 10 | class _android_view_View_OnApplyWindowInsetsListener_SUB 11 | extends java_lang_Object 12 | with android_view_View_OnApplyWindowInsetsListener { 13 | @override 14 | final String tag__ = 'platform'; 15 | } 16 | 17 | mixin android_view_View_OnApplyWindowInsetsListener on java_lang_Object { 18 | static android_view_View_OnApplyWindowInsetsListener subInstance() => 19 | _android_view_View_OnApplyWindowInsetsListener_SUB(); 20 | @override 21 | final String tag__ = 'platform'; 22 | } 23 | 24 | class _android_view_View_OnClickListener_SUB extends java_lang_Object 25 | with android_view_View_OnClickListener {} 26 | 27 | mixin android_view_View_OnClickListener on java_lang_Object { 28 | static android_view_View_OnClickListener subInstance() => 29 | _android_view_View_OnClickListener_SUB(); 30 | @override 31 | final String tag__ = 'platform'; 32 | } 33 | 34 | class _android_view_View_OnTouchListener_SUB extends java_lang_Object 35 | with android_view_View_OnTouchListener {} 36 | 37 | mixin android_view_View_OnTouchListener on java_lang_Object { 38 | static android_view_View_OnTouchListener subInstance() => 39 | _android_view_View_OnTouchListener_SUB(); 40 | @override 41 | final String tag__ = 'platform'; 42 | } 43 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/view/view_group.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 2 | import 'package:foundation_fluttify/src/object/obejcts.dart'; 3 | import 'package:foundation_fluttify/src/type/platform/android_type/android/view/view.dart'; 4 | 5 | class android_view_ViewGroup extends android_view_View { 6 | @override 7 | final String tag__ = 'platform'; 8 | 9 | Future addView(android_view_View child) { 10 | return kMethodChannel.invokeMethod( 11 | 'android.view.ViewGroup::addView', 12 | {'__this__': this, 'child': child}, 13 | ); 14 | } 15 | 16 | Future removeAllViews() { 17 | return kMethodChannel.invokeMethod( 18 | 'android.view.ViewGroup::removeAllViews', 19 | {'__this__': this}, 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/widget/frame_layout.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 2 | import 'package:foundation_fluttify/src/type/platform/android_type/android/view/view_group.dart'; 3 | 4 | class android_widget_FrameLayout extends android_view_ViewGroup { 5 | @override 6 | final String tag__ = 'platform'; 7 | } 8 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/widget/image_view.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 2 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 3 | import 'package:foundation_fluttify/src/type/platform/android_type/android/view/view.dart'; 4 | 5 | class android_widget_ImageView extends android_view_View { 6 | @override 7 | final String tag__ = 'platform'; 8 | 9 | static Future createWithBitmap( 10 | android_graphics_Bitmap bitmap, 11 | ) async { 12 | final result = await kMethodChannel.invokeMethod( 13 | 'android.widget.ImageView::createWithBitmap', 14 | {'bitmap': bitmap}, 15 | ); 16 | return android_widget_ImageView()..refId = result?.refId; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/widget/linear_layout.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 2 | import 'package:foundation_fluttify/src/type/platform/android_type/android/view/view_group.dart'; 3 | 4 | class android_widget_LinearLayout extends android_view_ViewGroup { 5 | @override 6 | final String tag__ = 'platform'; 7 | } 8 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/widget/relative_layout.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 2 | import 'package:foundation_fluttify/src/type/platform/android_type/android/view/view_group.dart'; 3 | 4 | class android_widget_RelativeLayout extends android_view_ViewGroup { 5 | @override 6 | final String tag__ = 'platform'; 7 | } 8 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/android/widget/text_view.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 2 | import 'package:foundation_fluttify/src/type/platform/android_type/android/view/view.dart'; 3 | 4 | class android_widget_TextView extends android_view_View { 5 | @override 6 | final String tag__ = 'platform'; 7 | } 8 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/java/io/closeable.dart: -------------------------------------------------------------------------------- 1 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 2 | 3 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 4 | class _java_io_Closeable_SUB extends java_lang_Object with java_io_Closeable { 5 | @override 6 | final String tag__ = 'platform'; 7 | } 8 | 9 | mixin java_io_Closeable on java_lang_Object { 10 | static java_io_Closeable subInstance() { 11 | return _java_io_Closeable_SUB(); 12 | } 13 | 14 | @override 15 | final String tag__ = 'platform'; 16 | } 17 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/java/io/file.dart: -------------------------------------------------------------------------------- 1 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 2 | 3 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 4 | class java_io_File extends java_lang_Object { 5 | @override 6 | final String tag__ = 'platform'; 7 | 8 | static Future create(String path) async { 9 | final result = await kMethodChannel 10 | .invokeMethod('java.io.File::create', {'path': path}); 11 | return java_io_File()..refId = result?.refId; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/java/io/serializable.dart: -------------------------------------------------------------------------------- 1 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 2 | 3 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 4 | class _java_io_Serializable_SUB extends java_lang_Object 5 | with java_io_Serializable { 6 | @override 7 | final String tag__ = 'platform'; 8 | } 9 | 10 | mixin java_io_Serializable on java_lang_Object { 11 | static java_io_Serializable subInstance() { 12 | return _java_io_Serializable_SUB(); 13 | } 14 | 15 | @override 16 | final String tag__ = 'platform'; 17 | } 18 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/java/lang/object.dart: -------------------------------------------------------------------------------- 1 | import 'package:foundation_fluttify/src/type/core/ref.dart'; 2 | 3 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 4 | class java_lang_Object extends Ref { 5 | @override 6 | final String tag__ = 'platform'; 7 | } 8 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/java/lang/throwable.dart: -------------------------------------------------------------------------------- 1 | import 'package:foundation_fluttify/src/type/core/ref.dart'; 2 | 3 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 4 | class java_lang_Throwable extends Ref { 5 | @override 6 | final String tag__ = 'platform'; 7 | } 8 | -------------------------------------------------------------------------------- /lib/src/type/platform/android_type/org/json/json_object.dart: -------------------------------------------------------------------------------- 1 | import 'package:foundation_fluttify/src/type/platform/android_type/java/lang/object.dart'; 2 | 3 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 4 | class org_json_JSONObject extends java_lang_Object { 5 | @override 6 | final String tag__ = 'platform'; 7 | } 8 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/av_audio_session_category_options.dart: -------------------------------------------------------------------------------- 1 | //typedef NS_OPTIONS(NSUInteger, AVAudioSessionCategoryOptions) 2 | //{ 3 | // /* MixWithOthers is only valid with AVAudioSessionCategoryPlayAndRecord, AVAudioSessionCategoryPlayback, and AVAudioSessionCategoryMultiRoute */ 4 | // AVAudioSessionCategoryOptionMixWithOthers = 0x1, 5 | // /* DuckOthers is only valid with AVAudioSessionCategoryAmbient, AVAudioSessionCategoryPlayAndRecord, AVAudioSessionCategoryPlayback, and AVAudioSessionCategoryMultiRoute */ 6 | // AVAudioSessionCategoryOptionDuckOthers = 0x2, 7 | // /* AllowBluetooth is only valid with AVAudioSessionCategoryRecord and AVAudioSessionCategoryPlayAndRecord */ 8 | // AVAudioSessionCategoryOptionAllowBluetooth API_UNAVAILABLE(tvos, watchos, macos) = 0x4, 9 | // /* DefaultToSpeaker is only valid with AVAudioSessionCategoryPlayAndRecord */ 10 | // AVAudioSessionCategoryOptionDefaultToSpeaker API_UNAVAILABLE(tvos, watchos, macos) = 0x8, 11 | // /* InterruptSpokenAudioAndMixWithOthers is only valid with AVAudioSessionCategoryPlayAndRecord, AVAudioSessionCategoryPlayback, and AVAudioSessionCategoryMultiRoute */ 12 | // AVAudioSessionCategoryOptionInterruptSpokenAudioAndMixWithOthers API_AVAILABLE(ios(9.0), watchos(2.0), tvos(9.0)) API_UNAVAILABLE(macos) = 0x11, 13 | // /* AllowBluetoothA2DP is only valid with AVAudioSessionCategoryPlayAndRecord */ 14 | // AVAudioSessionCategoryOptionAllowBluetoothA2DP API_AVAILABLE(ios(10.0), watchos(3.0), tvos(10.0)) API_UNAVAILABLE(macos) = 0x20, 15 | // /* AllowAirPlay is only valid with AVAudioSessionCategoryPlayAndRecord */ 16 | // AVAudioSessionCategoryOptionAllowAirPlay API_AVAILABLE(ios(10.0), tvos(10.0)) API_UNAVAILABLE(watchos, macos) = 0x40, 17 | //}; 18 | enum AVAudioSessionCategoryOptions { 19 | AVAudioSessionCategoryOptionMixWithOthers, 20 | AVAudioSessionCategoryOptionDuckOthers, 21 | AVAudioSessionCategoryOptionAllowBluetooth, 22 | AVAudioSessionCategoryOptionDefaultToSpeaker, 23 | AVAudioSessionCategoryOptionInterruptSpokenAudioAndMixWithOthers, 24 | AVAudioSessionCategoryOptionAllowBluetoothA2DP, 25 | AVAudioSessionCategoryOptionAllowAirPlay 26 | } 27 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/ca_action.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 3 | 4 | mixin CAAction on NSObject { 5 | @override 6 | final String tag__ = 'platform'; 7 | } 8 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/ca_animation.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 3 | 4 | import 'ca_media_timing.dart'; 5 | 6 | class CAAnimation extends NSObject with NSCopying, CAMediaTiming { 7 | @override 8 | final String tag__ = 'platform'; 9 | } 10 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/ca_basic_animation.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | import 'ca_property_animation.dart'; 3 | 4 | class CABasicAnimation extends CAPropertyAnimation { 5 | CABasicAnimation(this.fromValue, this.toValue, this.byValue); 6 | 7 | @override 8 | final String tag__ = 'platform'; 9 | 10 | final dynamic fromValue; 11 | final dynamic toValue; 12 | final dynamic byValue; 13 | 14 | @override 15 | String toString() { 16 | return 'CABasicAnimation{fromValue: $fromValue, toValue: $toValue, byValue: $byValue}'; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/ca_media_timing.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | 3 | 4 | 5 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 6 | 7 | mixin CAMediaTiming on NSObject { 8 | @override 9 | final String tag__ = 'platform'; 10 | 11 | /// The begin time of the object, in relation to its parent object, if 12 | /// applicable. Defaults to 0. 13 | double? beginTime; 14 | 15 | /// The basic duration of the object. Defaults to 0. 16 | double? duration; 17 | 18 | /// The rate of the layer. Used to scale parent time to local time, e.g. 19 | /// if rate is 2, local time progresses twice as fast as parent time. 20 | /// Defaults to 1. 21 | double? speed; 22 | 23 | /// Additional offset in active local time. i.e. to convert from parent 24 | /// time tp to active local time t: t = (tp - begin) * speed + offset. 25 | /// One use of this is to "pause" a layer by setting `speed' to zero and 26 | /// `offset' to a suitable value. Defaults to 0. */ 27 | double? timeOffset; 28 | 29 | /// The repeat count of the object. May be fractional. Defaults to 0. 30 | double? repeatCount; 31 | 32 | /// The repeat duration of the object. Defaults to 0. 33 | double? repeatDuration; 34 | 35 | /// When true, the object plays backwards after playing forwards. Defaults 36 | /// to NO. 37 | bool? autoreverses; 38 | 39 | /// Defines how the timed object behaves outside its active duration. 40 | /// Local time may be clamped to either end of the active duration, or 41 | /// the element may be removed from the presentation. The legal values 42 | /// are `backwards', `forwards', `both' and `removed'. Defaults to 43 | /// `removed'. 44 | bool? fillMode; 45 | } 46 | 47 | enum CAMediaTimingFillMode { 48 | backwards, 49 | forwards, 50 | both, 51 | removed, 52 | } 53 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/ca_property_animation.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | import 'ca_animation.dart'; 3 | 4 | class CAPropertyAnimation extends CAAnimation { 5 | @override 6 | final String tag__ = 'platform'; 7 | } 8 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/cg_point.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | 3 | import 'dart:math'; 4 | 5 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 6 | import 'package:foundation_fluttify/src/object/obejcts.dart'; 7 | 8 | class CGPoint extends Ref { 9 | @override 10 | final String tag__ = 'platform'; 11 | 12 | static Future create(double x, double y) async { 13 | final result = await kMethodChannel 14 | .invokeMethod('CGPoint::create', {'x': x, 'y': y}); 15 | return CGPoint()..refId = result?.refId; 16 | } 17 | 18 | static Future createWithPoint(Point point) async { 19 | final result = await kMethodChannel 20 | .invokeMethod('CGPoint::create', {'x': point.x, 'y': point.y}); 21 | return CGPoint()..refId = result?.refId; 22 | } 23 | 24 | static Future> create_batch( 25 | List x, 26 | List y, 27 | ) async { 28 | final resultBatch = await kMethodChannel 29 | .invokeListMethod('CGPoint::create_batch', {'x': x, 'y': y}); 30 | return [ 31 | for (final item in resultBatch ?? []) CGPoint()..refId = item.refId 32 | ]; 33 | } 34 | 35 | Future get x { 36 | return kMethodChannel.invokeMethod('CGPoint::getX', {'__this__': this}); 37 | } 38 | 39 | Future get y { 40 | return kMethodChannel.invokeMethod('CGPoint::getY', {'__this__': this}); 41 | } 42 | } 43 | 44 | extension CGPointListX on List { 45 | Future?> get x_batch { 46 | return kMethodChannel 47 | .invokeMethod('CGPoint::getX_batch', {'__this__': this}); 48 | } 49 | 50 | Future?> get y_batch { 51 | return kMethodChannel 52 | .invokeMethod('CGPoint::getY_batch', {'__this__': this}); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/cg_rect.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | 3 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 4 | 5 | class CGRect extends Ref { 6 | @override 7 | final String tag__ = 'platform'; 8 | 9 | static Future create( 10 | double x, 11 | double y, 12 | double width, 13 | double height, 14 | ) async { 15 | final result = await kMethodChannel.invokeMethod('CGRect::create', { 16 | 'x': x, 17 | 'y': y, 18 | 'width': width, 19 | 'height': height, 20 | }); 21 | return CGRect()..refId = result?.refId; 22 | } 23 | 24 | Future get x { 25 | return kMethodChannel.invokeMethod('CGRect::getX', {'__this__': this}); 26 | } 27 | 28 | Future get y { 29 | return kMethodChannel.invokeMethod('CGRect::getY', {'__this__': this}); 30 | } 31 | 32 | Future get width { 33 | return kMethodChannel.invokeMethod('CGRect::getWidth', {'__this__': this}); 34 | } 35 | 36 | Future get height { 37 | return kMethodChannel.invokeMethod('CGRect::getHeight', {'__this__': this}); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/cg_size.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | 3 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 4 | 5 | class CGSize extends Ref { 6 | @override 7 | final String tag__ = 'platform'; 8 | 9 | static Future create( 10 | double width, 11 | double height, 12 | ) async { 13 | final result = await kMethodChannel.invokeMethod('CGSize::create', { 14 | 'width': width, 15 | 'height': height, 16 | }); 17 | return CGSize()..refId = result?.refId; 18 | } 19 | 20 | Future get width { 21 | return kMethodChannel.invokeMethod('CGSize::getWidth', {'__this__': this}); 22 | } 23 | 24 | Future get height { 25 | return kMethodChannel.invokeMethod('CGSize::getHeight', {'__this__': this}); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/ns_coding.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | import 'ns_object.dart'; 3 | 4 | // ignore: camel_case_types 5 | class _NSCoding_SUB extends NSObject with NSCoding {} 6 | 7 | mixin NSCoding on NSObject { 8 | @override 9 | final String tag__ = 'platform'; 10 | 11 | static NSCoding subInstance() => _NSCoding_SUB(); 12 | } 13 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/ns_copying.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | import 'ns_object.dart'; 3 | 4 | // ignore: camel_case_types 5 | class _NSCopying_SUB extends NSObject with NSCopying {} 6 | 7 | mixin NSCopying on NSObject { 8 | @override 9 | final String tag__ = 'platform'; 10 | 11 | static NSCopying subInstance() => _NSCopying_SUB(); 12 | } 13 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/ns_data.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | 3 | import 'dart:typed_data'; 4 | 5 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 6 | import 'package:foundation_fluttify/src/object/obejcts.dart'; 7 | 8 | class NSData extends NSObject { 9 | @override 10 | final String tag__ = 'platform'; 11 | 12 | static Future createWithUint8List(Uint8List data) async { 13 | final result = await kMethodChannel 14 | .invokeMethod('NSData::createWithUint8List', {'data': data}); 15 | return NSData()..refId = result?.refId; 16 | } 17 | 18 | Future getData() { 19 | return kMethodChannel.invokeMethod( 20 | 'NSData::getData', 21 | {'__this__': this}, 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/ns_date.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | 3 | 4 | 5 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 6 | import 'package:foundation_fluttify/src/object/obejcts.dart'; 7 | 8 | class NSDate extends NSObject { 9 | @override 10 | final String tag__ = 'platform'; 11 | 12 | /// 时间戳 单位秒 13 | Future get timeIntervalSince1970 { 14 | return kMethodChannel.invokeMethod( 15 | 'NSDate::get_timeIntervalSince1970', 16 | {'__this__': this}, 17 | ); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/ns_error.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | 3 | 4 | 5 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 6 | 7 | import 'ns_object.dart'; 8 | 9 | class NSError extends NSObject { 10 | @override 11 | final String tag__ = 'platform'; 12 | 13 | Future get code async { 14 | final int? errorCode = await kMethodChannel 15 | .invokeMethod('NSError::getCode', {'__this__': this}); 16 | return errorCode; 17 | } 18 | 19 | Future get description async { 20 | final String? description = await kMethodChannel 21 | .invokeMethod('NSError::getDescription', {'__this__': this}); 22 | return description; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/ns_mutable_copying.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | import 'ns_object.dart'; 3 | 4 | class _NSMutableCopying_SUB extends NSObject with NSMutableCopying {} 5 | 6 | mixin NSMutableCopying on NSObject { 7 | static NSMutableCopying subInstance() => _NSMutableCopying_SUB(); 8 | 9 | @override 10 | final String tag__ = 'platform'; 11 | } 12 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/ns_object.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | 3 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 4 | 5 | class NSObject extends Ref { 6 | @override 7 | final String tag__ = 'platform'; 8 | } 9 | 10 | extension NSObjectListX on List {} 11 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/ns_operation.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | import 'ns_object.dart'; 3 | 4 | class NSOperation extends NSObject { 5 | @override 6 | final String tag__ = 'platform'; 7 | } 8 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/ns_url.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 3 | 4 | class NSURL extends NSObject { 5 | @override 6 | final String tag__ = 'platform'; 7 | } 8 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/ns_user_activity.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 3 | 4 | class NSUserActivity extends NSObject { 5 | @override 6 | final String tag__ = 'platform'; 7 | } 8 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/ns_value.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 3 | 4 | class NSValue extends NSObject with NSCopying { 5 | @override 6 | final String tag__ = 'platform'; 7 | } 8 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/ui_application.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 3 | 4 | class UIApplication extends NSObject { 5 | @override 6 | final String tag__ = 'platform'; 7 | } 8 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/ui_application_shortcut_item.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 3 | 4 | class UIApplicationShortcutItem extends NSObject { 5 | @override 6 | final String tag__ = 'platform'; 7 | } 8 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/ui_bar_style.dart: -------------------------------------------------------------------------------- 1 | enum UIBarStyle { 2 | UIBarStyleDefault, 3 | UIBarStyleBlack, 4 | } 5 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/ui_color.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | 3 | import 'dart:ui'; 4 | 5 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 6 | import 'package:foundation_fluttify/src/object/obejcts.dart'; 7 | 8 | import 'ns_object.dart'; 9 | 10 | class UIColor extends NSObject { 11 | @override 12 | final String tag__ = 'platform'; 13 | 14 | static Future create(Color color) async { 15 | final result = await kMethodChannel 16 | .invokeMethod('UIColor::create', {'colorValue': color.value}); 17 | return UIColor()..refId = result?.refId; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/ui_control.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | import 'ns_object.dart'; 3 | 4 | class UIControl extends NSObject { 5 | @override 6 | final String tag__ = 'platform'; 7 | } 8 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/ui_edge_insets.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | 3 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 4 | import 'package:foundation_fluttify/src/object/obejcts.dart'; 5 | 6 | class UIEdgeInsets extends Ref { 7 | @override 8 | final String tag__ = 'platform'; 9 | 10 | static Future create( 11 | double top, 12 | double left, 13 | double bottom, 14 | double right, 15 | ) async { 16 | final result = 17 | await kMethodChannel.invokeMethod('UIEdgeInsets::create', { 18 | 'top': top, 19 | 'left': left, 20 | 'bottom': bottom, 21 | 'right': right, 22 | }); 23 | return UIEdgeInsets()..refId = result?.refId; 24 | } 25 | 26 | Future get top { 27 | return kMethodChannel 28 | .invokeMethod('UIEdgeInsets::getTop', {'__this__': this}); 29 | } 30 | 31 | Future get left { 32 | return kMethodChannel 33 | .invokeMethod('UIEdgeInsets::getLeft', {'__this__': this}); 34 | } 35 | 36 | Future get bottom { 37 | return kMethodChannel 38 | .invokeMethod('UIEdgeInsets::getBottom', {'__this__': this}); 39 | } 40 | 41 | Future get right { 42 | return kMethodChannel 43 | .invokeMethod('UIEdgeInsets::getRight', {'__this__': this}); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/ui_image.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 2 | 3 | import 'dart:typed_data'; 4 | 5 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 6 | import 'package:foundation_fluttify/src/object/obejcts.dart'; 7 | 8 | import 'ns_object.dart'; 9 | 10 | class UIImage extends NSObject { 11 | @override 12 | final String tag__ = 'platform'; 13 | 14 | static Future create(Uint8List bitmapBytes) async { 15 | final result = await kMethodChannel.invokeMethod( 16 | 'UIImage::createUIImage', 17 | {'bitmapBytes': bitmapBytes}, 18 | ); 19 | return UIImage()..refId = result?.refId; 20 | } 21 | 22 | static Future createWithPath( 23 | String resource, 24 | String type, 25 | String fileName, 26 | ) async { 27 | final result = await kMethodChannel.invokeMethod( 28 | 'UIImage::createWithPath', 29 | { 30 | 'resource': resource, 31 | 'type': type, 32 | 'fileName': fileName, 33 | }, 34 | ); 35 | return UIImage()..refId = result?.refId; 36 | } 37 | 38 | static Future> create_batch( 39 | List bitmapBytesBatch, 40 | ) async { 41 | final resultBatch = await kMethodChannel.invokeListMethod( 42 | 'UIImage::createUIImage_batch', 43 | [ 44 | for (final bitmapBytes in bitmapBytesBatch) {'bitmapBytes': bitmapBytes} 45 | ], 46 | ); 47 | return resultBatch?.map((it) => UIImage()..refId = it.refId).toList() ?? []; 48 | } 49 | 50 | Future get data { 51 | return kMethodChannel.invokeMethod('UIImage::getData', {'__this__': this}); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/ui_image_view.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | 3 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 4 | import 'package:foundation_fluttify/src/object/obejcts.dart'; 5 | 6 | import 'ui_view.dart'; 7 | 8 | class UIImageView extends UIView { 9 | @override 10 | final String tag__ = 'platform'; 11 | 12 | static Future create(UIImage image) async { 13 | final result = await kMethodChannel.invokeMethod( 14 | 'UIImageView::create', 15 | {'image': image}, 16 | ); 17 | return UIImageView()..refId = result?.refId; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/ui_status_bar_style.dart: -------------------------------------------------------------------------------- 1 | enum UIStatusBarStyle { 2 | UIStatusBarStyleDefault, 3 | UIStatusBarStyleLightContent, 4 | UIStatusBarStyleDarkContent, 5 | } 6 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/ui_user_notification_settings.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 3 | 4 | class UIUserNotificationSettings extends NSObject { 5 | @override 6 | final String tag__ = 'platform'; 7 | } 8 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/ui_view.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | 3 | import 'dart:math'; 4 | 5 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 6 | import 'package:foundation_fluttify/src/object/obejcts.dart'; 7 | import 'package:foundation_fluttify/src/type/platform/ios_type/cg_point.dart'; 8 | 9 | import 'cg_rect.dart'; 10 | import 'ns_object.dart'; 11 | 12 | class UIView extends NSObject { 13 | @override 14 | final String tag__ = 'platform'; 15 | 16 | static Future create() async { 17 | final result = await kMethodChannel.invokeMethod('UIView::create'); 18 | return UIView()..refId = result?.refId; 19 | } 20 | 21 | /// 旋转 22 | /// 23 | /// 单位为度 24 | Future rotate(double angle) async { 25 | await kMethodChannel.invokeMethod('UIView::rotate', { 26 | '__this__': this, 27 | 'angle': angle, 28 | }); 29 | } 30 | 31 | /// 执行缩放动画 32 | Future scaleWithDuration({ 33 | Duration duration = const Duration(seconds: 1), 34 | double fromValue = 0, 35 | required double toValue, 36 | int repeatCount = 0, 37 | int repeatMode = 1, 38 | }) async { 39 | assert(fromValue >= 0); 40 | assert(toValue >= 0); 41 | await kMethodChannel.invokeMethod('UIView::scaleWithDuration', { 42 | '__this__': this, 43 | 'duration': duration.inMilliseconds / 1000, 44 | 'fromValue': fromValue, 45 | 'toValue': toValue, 46 | 'repeatCount': repeatCount, 47 | 'repeatMode': repeatMode, 48 | }); 49 | } 50 | 51 | /// 执行移动动画 52 | Future translateWithDuration({ 53 | Duration duration = const Duration(seconds: 1), 54 | required CGPoint toValue, 55 | int repeatCount = 0, 56 | int repeatMode = 1, 57 | }) async { 58 | await kMethodChannel.invokeMethod('UIView::translateWithDuration', { 59 | '__this__': this, 60 | 'duration': duration.inMilliseconds / 1000, 61 | 'toX': await toValue.x, 62 | 'toY': await toValue.y, 63 | 'repeatCount': repeatCount, 64 | 'repeatMode': repeatMode, 65 | }); 66 | } 67 | 68 | /// 执行透明度动画 69 | /// 70 | /// 范围为0-1 71 | Future alphaWithDuration({ 72 | Duration duration = const Duration(seconds: 1), 73 | double fromValue = 0, 74 | required double toValue, 75 | int repeatCount = 0, 76 | int repeatMode = 0, 77 | }) async { 78 | assert(fromValue >= 0 && fromValue <= 1); 79 | assert(toValue >= 0 && toValue <= 1); 80 | await kMethodChannel.invokeMethod('UIView::alphaWithDuration', { 81 | '__this__': this, 82 | 'duration': duration.inMilliseconds / 1000, 83 | 'fromValue': fromValue, 84 | 'toValue': toValue, 85 | 'repeatCount': repeatCount, 86 | 'repeatMode': repeatMode, 87 | }); 88 | } 89 | 90 | /// 执行旋转动画 91 | /// 92 | /// 单位为度, 逆时针旋转 93 | Future rotateWithDuration({ 94 | Duration duration = const Duration(seconds: 1), 95 | double fromValue = 0, 96 | required double toValue, 97 | int repeatCount = 0, 98 | int repeatMode = 0, 99 | }) async { 100 | await kMethodChannel.invokeMethod('UIView::rotateWithDuration', { 101 | '__this__': this, 102 | 'duration': duration.inMilliseconds / 1000, 103 | 'fromValue': fromValue / 180 * pi, 104 | 'toValue': -toValue / 180 * pi, 105 | 'repeatCount': repeatCount, 106 | 'repeatMode': repeatMode, 107 | }); 108 | } 109 | 110 | /// 执行组合动画 111 | /// 112 | /// [keyPath]为构造CABasicAnimation时的[CABasicAnimation animationWithKeyPath:keyPath]; 113 | /// 缩放为`transform.scale`, 透明度为`opacity`, 旋转为`transform.rotation` 114 | /// 115 | /// [fromValue], [toValue]和[keyPath]的长度必须相等 116 | Future groupWithDuration({ 117 | Duration duration = const Duration(seconds: 1), 118 | required List fromValue, 119 | required List toValue, 120 | required List keyPath, 121 | int repeatCount = 0, 122 | int repeatMode = 0, 123 | }) async { 124 | assert(fromValue.length == toValue.length); 125 | assert(toValue.length == keyPath.length); 126 | await kMethodChannel.invokeMethod('UIView::groupWithDuration', { 127 | '__this__': this, 128 | 'duration': duration.inMilliseconds / 1000, 129 | 'fromValue': [for (final item in fromValue) item / 180 * pi], 130 | 'toValue': [for (final item in fromValue) -item / 180 * pi], 131 | 'keyPath': keyPath, 132 | 'repeatCount': repeatCount, 133 | 'repeatMode': repeatMode, 134 | }); 135 | } 136 | 137 | Future get frame async { 138 | final result = await kMethodChannel 139 | .invokeMethod('UIView::getFrame', {'__this__': this}); 140 | return CGRect()..refId = result?.refId; 141 | } 142 | 143 | Future get hidden async { 144 | final result = await kMethodChannel 145 | .invokeMethod('UIView::getHidden', {'__this__': this}); 146 | return result; 147 | } 148 | 149 | Future setHidden(bool hidden) async { 150 | await kMethodChannel.invokeMethod('UIView::setHidden', { 151 | '__this__': this, 152 | 'hidden': hidden, 153 | }); 154 | } 155 | 156 | Future setAnchorPoint(double anchorU, double anchorV) async { 157 | await kMethodChannel.invokeMethod('UIView::setAnchorPoint', { 158 | '__this__': this, 159 | 'anchorU': anchorU, 160 | 'anchorV': anchorV, 161 | }); 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /lib/src/type/platform/ios_type/ui_view_controller.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | 3 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 4 | 5 | import 'ns_object.dart'; 6 | 7 | class UIViewController extends NSObject { 8 | @override 9 | final String tag__ = 'platform'; 10 | 11 | static Future get() async { 12 | final result = 13 | await kMethodChannel.invokeMethod('UIViewController::get'); 14 | return UIViewController()..refId = result?.refId; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/src/type/widget/android_opengl_GLSurfaceView.widget.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 2 | 3 | 4 | 5 | import 'dart:io'; 6 | 7 | import 'package:flutter/foundation.dart'; 8 | import 'package:flutter/gestures.dart'; 9 | import 'package:flutter/material.dart'; 10 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 11 | import 'package:foundation_fluttify/src/type/platform/ios_type/ui_view.dart'; 12 | 13 | typedef _OnViewCreated = Future Function( 14 | android_opengl_GLSurfaceView? controller, 15 | ); 16 | typedef _OnViewDispose = Future Function(); 17 | 18 | class android_opengl_GLSurfaceViewWidget extends StatefulWidget { 19 | const android_opengl_GLSurfaceViewWidget({ 20 | Key? key, 21 | this.onGLSurfaceViewCreated, 22 | this.onDispose, 23 | this.gestureRecognizers, 24 | }) : super(key: key); 25 | 26 | final _OnViewCreated? onGLSurfaceViewCreated; 27 | final _OnViewDispose? onDispose; 28 | final Set>? gestureRecognizers; 29 | 30 | @override 31 | _android_opengl_GLSurfaceViewWidgetState createState() => 32 | _android_opengl_GLSurfaceViewWidgetState(); 33 | } 34 | 35 | class _android_opengl_GLSurfaceViewWidgetState 36 | extends State { 37 | android_opengl_GLSurfaceView? _view; 38 | 39 | @override 40 | Widget build(BuildContext context) { 41 | if (Platform.isAndroid) { 42 | final gestureRecognizers = widget.gestureRecognizers ?? 43 | >{ 44 | Factory( 45 | () => EagerGestureRecognizer()), 46 | }; 47 | final messageCodec = FluttifyMessageCodec(tag: 'platform'); 48 | return AndroidView( 49 | viewType: 'me.yohom/foundation_fluttify/android.opengl.GLSurfaceView', 50 | creationParamsCodec: messageCodec, 51 | gestureRecognizers: gestureRecognizers, 52 | onPlatformViewCreated: (viewId) async { 53 | final refId = await viewId2RefId((2147483647 - viewId).toString()); 54 | _view = android_opengl_GLSurfaceView() 55 | ..refId = 'android.opengl.GLSurfaceView:$refId'; 56 | if (widget.onGLSurfaceViewCreated != null) { 57 | await widget.onGLSurfaceViewCreated!(_view); 58 | } 59 | }, 60 | ); 61 | } else { 62 | return Center(child: Text('不支持的平台')); 63 | } 64 | } 65 | 66 | @override 67 | void dispose() { 68 | if (widget.onDispose != null) { 69 | widget.onDispose!().then((_) => _view!.release__()); 70 | } else { 71 | _view!.release__(); 72 | } 73 | super.dispose(); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /lib/src/type/widget/android_view_SurfaceView.widget.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 2 | 3 | import 'dart:io'; 4 | 5 | import 'package:flutter/foundation.dart'; 6 | import 'package:flutter/gestures.dart'; 7 | import 'package:flutter/material.dart'; 8 | import 'package:flutter/services.dart'; 9 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 10 | import 'package:foundation_fluttify/src/type/platform/ios_type/ui_view.dart'; 11 | 12 | typedef _OnViewCreated = Future Function( 13 | android_view_SurfaceView? controller, 14 | ); 15 | typedef _OnViewDispose = Future Function(); 16 | 17 | class android_view_SurfaceViewWidget extends StatefulWidget { 18 | const android_view_SurfaceViewWidget({ 19 | Key? key, 20 | this.onSurfaceViewCreated, 21 | this.surfaceCreated, 22 | this.surfaceChanged, 23 | this.surfaceDestroyed, 24 | this.onDispose, 25 | this.gestureRecognizers, 26 | }) : super(key: key); 27 | 28 | final _OnViewCreated? onSurfaceViewCreated; 29 | final ValueChanged? surfaceCreated; 30 | final void Function(android_view_SurfaceHolder, int?, int?, int?)? 31 | surfaceChanged; 32 | final ValueChanged? surfaceDestroyed; 33 | final _OnViewDispose? onDispose; 34 | final Set>? gestureRecognizers; 35 | 36 | @override 37 | _android_view_SurfaceViewWidgetState createState() => 38 | _android_view_SurfaceViewWidgetState(); 39 | } 40 | 41 | class _android_view_SurfaceViewWidgetState 42 | extends State { 43 | android_view_SurfaceView? _view; 44 | 45 | @override 46 | void initState() { 47 | super.initState(); 48 | MethodChannel( 49 | 'android.view.SurfaceHolder::addCallback::Callback', 50 | kMethodCodec, 51 | ).setMethodCallHandler((methodCall) async { 52 | try { 53 | final args = methodCall.arguments as Map?; 54 | switch (methodCall.method) { 55 | case 'Callback::android.view.SurfaceHolder.Callback::surfaceCreated': 56 | if (widget.surfaceCreated != null) { 57 | final ref = args!['holder'] as Ref; 58 | widget.surfaceCreated!( 59 | android_view_SurfaceHolder.subInstance()..refId = ref.refId, 60 | ); 61 | } 62 | break; 63 | case 'Callback::android.view.SurfaceHolder.Callback::surfaceChanged': 64 | if (widget.surfaceChanged != null) { 65 | final ref = args!['holder'] as Ref; 66 | widget.surfaceChanged!( 67 | android_view_SurfaceHolder.subInstance()..refId = ref.refId, 68 | args['format'], 69 | args['width'], 70 | args['height'], 71 | ); 72 | } 73 | break; 74 | case 'Callback::android.view.SurfaceHolder.Callback::surfaceDestroyed': 75 | if (widget.surfaceDestroyed != null) { 76 | final ref = args!['holder'] as Ref; 77 | widget.surfaceDestroyed!( 78 | android_view_SurfaceHolder.subInstance()..refId = ref.refId, 79 | ); 80 | } 81 | break; 82 | default: 83 | throw MissingPluginException('方法${methodCall.method}未实现'); 84 | } 85 | } catch (e) { 86 | debugPrint(e.toString()); 87 | rethrow; 88 | } 89 | }); 90 | } 91 | 92 | @override 93 | Widget build(BuildContext context) { 94 | if (Platform.isAndroid) { 95 | final gestureRecognizers = widget.gestureRecognizers ?? 96 | >{ 97 | Factory( 98 | () => EagerGestureRecognizer()), 99 | }; 100 | final messageCodec = FluttifyMessageCodec(); 101 | return AndroidView( 102 | viewType: 'me.yohom/foundation_fluttify/android.view.SurfaceView', 103 | creationParamsCodec: messageCodec, 104 | gestureRecognizers: gestureRecognizers, 105 | onPlatformViewCreated: (viewId) async { 106 | final refId = await viewId2RefId((2147483647 - viewId).toString()); 107 | _view = android_view_SurfaceView() 108 | ..refId = 'android.view.SurfaceView:$refId'; 109 | if (widget.onSurfaceViewCreated != null) { 110 | await widget.onSurfaceViewCreated!(_view); 111 | } 112 | }, 113 | ); 114 | } else { 115 | return Center(child: Text('不支持的平台')); 116 | } 117 | } 118 | 119 | @override 120 | void dispose() { 121 | if (widget.onDispose != null) { 122 | widget.onDispose!().then((_) => _view!.release__()); 123 | } else { 124 | _view!.release__(); 125 | } 126 | super.dispose(); 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /lib/src/type/widget/android_widget_FrameLayout.widget.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names, camel_case_types, missing_return, unused_import 2 | 3 | 4 | 5 | import 'dart:io'; 6 | 7 | import 'package:flutter/foundation.dart'; 8 | import 'package:flutter/gestures.dart'; 9 | import 'package:flutter/material.dart'; 10 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 11 | import 'package:foundation_fluttify/src/type/platform/ios_type/ui_view.dart'; 12 | 13 | typedef _OnViewCreated = Future Function( 14 | android_widget_FrameLayout? controller); 15 | typedef _OnViewDispose = Future Function(); 16 | 17 | class android_view_FrameLayoutWidget extends StatefulWidget { 18 | const android_view_FrameLayoutWidget({ 19 | Key? key, 20 | this.onFrameLayoutCreated, 21 | this.onDispose, 22 | this.gestureRecognizers, 23 | }) : super(key: key); 24 | 25 | final _OnViewCreated? onFrameLayoutCreated; 26 | final _OnViewDispose? onDispose; 27 | final Set>? gestureRecognizers; 28 | 29 | @override 30 | _android_view_FrameLayoutWidgetState createState() => 31 | _android_view_FrameLayoutWidgetState(); 32 | } 33 | 34 | class _android_view_FrameLayoutWidgetState 35 | extends State { 36 | android_widget_FrameLayout? _view; 37 | 38 | @override 39 | Widget build(BuildContext context) { 40 | if (Platform.isAndroid) { 41 | final gestureRecognizers = widget.gestureRecognizers ?? 42 | >{ 43 | Factory( 44 | () => EagerGestureRecognizer()), 45 | }; 46 | final messageCodec = FluttifyMessageCodec(); 47 | return AndroidView( 48 | viewType: 'me.yohom/foundation_fluttify/android.widget.FrameLayout', 49 | creationParamsCodec: messageCodec, 50 | gestureRecognizers: gestureRecognizers, 51 | onPlatformViewCreated: (viewId) async { 52 | final refId = await viewId2RefId((2147483647 - viewId).toString()); 53 | _view = android_widget_FrameLayout() 54 | ..refId = 'android.widget.FrameLayout:$refId'; 55 | if (widget.onFrameLayoutCreated != null) { 56 | await widget.onFrameLayoutCreated!(_view); 57 | } 58 | }, 59 | ); 60 | } else { 61 | return Center(child: Text('不支持的平台')); 62 | } 63 | } 64 | 65 | @override 66 | void dispose() { 67 | if (widget.onDispose != null) { 68 | widget.onDispose!().then((_) => _view!.release__()); 69 | } else { 70 | _view!.release__(); 71 | } 72 | super.dispose(); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /lib/src/type/widget/scoped_release_pool.widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 3 | import 'package:foundation_fluttify/src/type/core/ref.dart'; 4 | 5 | class ScopedReleasePool extends StatefulWidget { 6 | const ScopedReleasePool({ 7 | Key? key, 8 | required this.child, 9 | required this.tag, 10 | }) : super(key: key); 11 | 12 | final Widget child; 13 | 14 | /// 标记一类对象 15 | /// 16 | /// 如果设置了, 则释放时根据这个tag进行释放, 防止误伤 17 | final String tag; 18 | 19 | @override 20 | ScopedReleasePoolState createState() => ScopedReleasePoolState(); 21 | } 22 | 23 | class ScopedReleasePoolState extends State { 24 | final Set _releasePool = {}; 25 | 26 | @override 27 | void initState() { 28 | super.initState(); 29 | gReleasePoolStack.push(this); 30 | } 31 | 32 | @override 33 | Widget build(BuildContext context) { 34 | return widget.child; 35 | } 36 | 37 | @override 38 | void dispose() { 39 | log('ScopedReleasePool释放对象: $_releasePool'); 40 | gReleasePoolStack.pop(); 41 | _releasePool 42 | // 过滤出tag为目标tag的对象进行释放 或 tag为null表示不过滤 43 | .where((e) => e.tag__ == widget.tag) 44 | .release_batch() 45 | .then((value) => _releasePool.clear()); 46 | super.dispose(); 47 | } 48 | 49 | void add(Ref ref) { 50 | _releasePool.add(ref); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /lib/src/type/widget/ui_view.widget.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:flutter/foundation.dart'; 4 | import 'package:flutter/gestures.dart'; 5 | import 'package:flutter/material.dart'; 6 | import 'package:foundation_fluttify/foundation_fluttify.dart'; 7 | 8 | typedef OnUIViewCreated = Future Function(UIView? controller); 9 | typedef _OnUiKitViewDispose = Future Function(); 10 | 11 | class UIViewWidget extends StatefulWidget { 12 | const UIViewWidget({ 13 | Key? key, 14 | this.onUIViewCreated, 15 | this.onDispose, 16 | this.gestureRecognizers, 17 | }) : super(key: key); 18 | 19 | final OnUIViewCreated? onUIViewCreated; 20 | final _OnUiKitViewDispose? onDispose; 21 | final Set>? gestureRecognizers; 22 | 23 | @override 24 | _UIViewWidgetState createState() => _UIViewWidgetState(); 25 | } 26 | 27 | class _UIViewWidgetState extends State { 28 | UIView? _view; 29 | 30 | @override 31 | Widget build(BuildContext context) { 32 | if (Platform.isIOS) { 33 | final gestureRecognizers = widget.gestureRecognizers ?? 34 | >{ 35 | Factory( 36 | () => EagerGestureRecognizer()), 37 | }; 38 | final messageCodec = FluttifyMessageCodec(); 39 | return UiKitView( 40 | viewType: 'me.yohom/foundation_fluttify/UIView', 41 | creationParamsCodec: messageCodec, 42 | gestureRecognizers: gestureRecognizers, 43 | onPlatformViewCreated: (viewId) async { 44 | final refId = await viewId2RefId((2147483647 - viewId).toString()); 45 | _view = UIView()..refId = 'UIView:$refId'; 46 | if (widget.onUIViewCreated != null) { 47 | await widget.onUIViewCreated!(_view); 48 | } 49 | }, 50 | ); 51 | } else { 52 | return Center(child: Text('不支持的平台')); 53 | } 54 | } 55 | 56 | @override 57 | void dispose() { 58 | if (widget.onDispose != null) { 59 | widget.onDispose!().then((_) => _view?.release__()); 60 | } else { 61 | _view?.release__(); 62 | } 63 | super.dispose(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | url: "https://pub.flutter-io.cn" 9 | source: hosted 10 | version: "2.8.2" 11 | boolean_selector: 12 | dependency: transitive 13 | description: 14 | name: boolean_selector 15 | url: "https://pub.flutter-io.cn" 16 | source: hosted 17 | version: "2.1.0" 18 | characters: 19 | dependency: transitive 20 | description: 21 | name: characters 22 | url: "https://pub.flutter-io.cn" 23 | source: hosted 24 | version: "1.2.0" 25 | charcode: 26 | dependency: transitive 27 | description: 28 | name: charcode 29 | url: "https://pub.flutter-io.cn" 30 | source: hosted 31 | version: "1.3.1" 32 | clock: 33 | dependency: transitive 34 | description: 35 | name: clock 36 | url: "https://pub.flutter-io.cn" 37 | source: hosted 38 | version: "1.1.0" 39 | collection: 40 | dependency: transitive 41 | description: 42 | name: collection 43 | url: "https://pub.flutter-io.cn" 44 | source: hosted 45 | version: "1.16.0" 46 | fake_async: 47 | dependency: transitive 48 | description: 49 | name: fake_async 50 | url: "https://pub.flutter-io.cn" 51 | source: hosted 52 | version: "1.3.0" 53 | flutter: 54 | dependency: "direct main" 55 | description: flutter 56 | source: sdk 57 | version: "0.0.0" 58 | flutter_test: 59 | dependency: "direct dev" 60 | description: flutter 61 | source: sdk 62 | version: "0.0.0" 63 | matcher: 64 | dependency: transitive 65 | description: 66 | name: matcher 67 | url: "https://pub.flutter-io.cn" 68 | source: hosted 69 | version: "0.12.11" 70 | material_color_utilities: 71 | dependency: transitive 72 | description: 73 | name: material_color_utilities 74 | url: "https://pub.flutter-io.cn" 75 | source: hosted 76 | version: "0.1.4" 77 | meta: 78 | dependency: transitive 79 | description: 80 | name: meta 81 | url: "https://pub.flutter-io.cn" 82 | source: hosted 83 | version: "1.7.0" 84 | path: 85 | dependency: transitive 86 | description: 87 | name: path 88 | url: "https://pub.flutter-io.cn" 89 | source: hosted 90 | version: "1.8.1" 91 | sky_engine: 92 | dependency: transitive 93 | description: flutter 94 | source: sdk 95 | version: "0.0.99" 96 | source_span: 97 | dependency: transitive 98 | description: 99 | name: source_span 100 | url: "https://pub.flutter-io.cn" 101 | source: hosted 102 | version: "1.8.2" 103 | stack_trace: 104 | dependency: transitive 105 | description: 106 | name: stack_trace 107 | url: "https://pub.flutter-io.cn" 108 | source: hosted 109 | version: "1.10.0" 110 | stream_channel: 111 | dependency: transitive 112 | description: 113 | name: stream_channel 114 | url: "https://pub.flutter-io.cn" 115 | source: hosted 116 | version: "2.1.0" 117 | string_scanner: 118 | dependency: transitive 119 | description: 120 | name: string_scanner 121 | url: "https://pub.flutter-io.cn" 122 | source: hosted 123 | version: "1.1.0" 124 | term_glyph: 125 | dependency: transitive 126 | description: 127 | name: term_glyph 128 | url: "https://pub.flutter-io.cn" 129 | source: hosted 130 | version: "1.2.0" 131 | test_api: 132 | dependency: transitive 133 | description: 134 | name: test_api 135 | url: "https://pub.flutter-io.cn" 136 | source: hosted 137 | version: "0.4.9" 138 | vector_math: 139 | dependency: transitive 140 | description: 141 | name: vector_math 142 | url: "https://pub.flutter-io.cn" 143 | source: hosted 144 | version: "2.1.2" 145 | sdks: 146 | dart: ">=2.17.0-0 <3.0.0" 147 | flutter: ">=2.0.0" 148 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: foundation_fluttify 2 | description: Foundation for `Fluttify`. 3 | version: 0.13.0+1 4 | homepage: https://github.com/fluttify-project/foundation_fluttify 5 | 6 | environment: 7 | sdk: '>=2.12.0 <3.0.0' 8 | flutter: '>=2.0.0' 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | 14 | dev_dependencies: 15 | flutter_test: 16 | sdk: flutter 17 | 18 | flutter: 19 | plugin: 20 | platforms: 21 | android: 22 | package: me.yohom.foundation_fluttify 23 | pluginClass: FoundationFluttifyPlugin 24 | ios: 25 | pluginClass: FoundationFluttifyPlugin -------------------------------------------------------------------------------- /test/foundation_fluttify_test.dart: -------------------------------------------------------------------------------- 1 | void main() {} 2 | --------------------------------------------------------------------------------