flutter1.5.4,flutter22

Flutter笔记-调用原生IOS高德地图sdk

2017年底因公司业务组合部门调整,新的团队部分维护的项目用React Native技术混合开发。为适应环境变化,开启疯狂RN学习之旅,晚上回来啃资料看视频。可能由于本身对RN技术体验不感冒或者在环境之下强迫学习有点不爽。开始寻找代替方案,Fluter像一束曙光引起了我的注意,之后一直关注并利用闲余时间开始探索。2018年一直学习到使用Flutter写项目,从0.2.0开始到现在1.5版本的发布,终于开始慢慢的爬出坑位了,但是因为部分控件感觉还是不如原生控件好用,因而Flutter提供了PlatformView部件。近期因项目中严重使用依赖地图,故而做了Fluterr使用原生IOS高德地图调研。因为我本身是一名android开发人员,初学IOS并记录下来。

创新互联公司2013年成立,是专业互联网技术服务公司,拥有项目成都网站建设、网站设计网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元祁县做网站,已为上家服务,为祁县各地企业和个人服务,联系电话:18982081108

PlatformView是 flutter 官方提供的一个可以嵌入 Android 和 iOS 平台原生 view 的小部件。

在我们实际开发中,我们遇到一些 flutter 官方没有提供的插件可以自己创建编写插件来实现部分功能,但是原生View在 flutter 中会遮挡住flutter 中的小部件,比如你想使用高德地图sdk、视频播放器、直播等原生控件,就无法很好的与 flutter 项目结合。

1、info.plist文件设置

2、 ios 端实现原生组件PlatformView提供原生view

3 、ios 端创建PlatformViewFactory用于生成PlatformView

4、 ios 端创建FlutterPlugin用于注册原生组件

5 、flutter 平台嵌入 原生view

iOS端的UiKitView目前还只是preview状态, 默认是不支持的, 需要手动打开开关, 在info.plist文件中新增一行io.flutter.embedded_views_preview为true.

创建类 FlutterMapView 并实现FlutterPlatformView 协议

FlutterMapView.h

FlutterMapView.m

FlutterMapFactory.h

FlutterMapFactory.m

FlutterMapPlugin.h

FlutterMapPlugin.m

请前往 高德开放平台控制台 申请 iOS Key。

注意:Bundle Identifier需要与申请的时候填写的一致

地图依赖的库列举如下:

基础 SDK AMapFoundationKit.framework

第一步:将解压后的MAMapKit.framework 文件 copy 或 拖拽 到工程文件夹中,左侧目录选中工程名,在 TARGETS-Build Phases- Link Binary With Libaries 中点击“+”按钮,在弹出的窗口中点击“Add Other”按钮,选择工程目录下的 MAMapKit.framework 文件添加到工程中。

千万不要忘记将AMapFoundationKit也一起加入工程。

3D地图正确配置应如下图所示:

需要引入的资源文件包括:AMap.bundle,其中:AMap.bundle 在 MAMapKit.framework 包中,AMap.bundle资源文件中存储了定位、默认大头针标注视图等图片,可利用这些资源图片进行开发。

左侧目录中选中工程名,在右键菜单中选择Add Files to “工程名”…,从MAMapKit.framework中选择AMap.bundle文件,并勾选“Copy items if needed”复选框,单击“Add”按钮,将资源文件添加到工程中。

成功跑起来 。。 。

Android Studio Emulator依然显示删除的device

如下,

当你添加完所有环境变量,或者多次卸掉重装android studio后,再次插入手机,或者是开启模拟器的时候,vscode或android studio都显示no devices的时候,以下简单的解决方法或许能帮到你。

1、先检查自己以往是否有安装adb。在cmd中查看adb的版本。输入:adb version。

2、如果有安装的话,建议在C:WindowsSystem和C:WindowsSystem32删除adb.exe, AdbWinApi.dll和AdbWinUsbApi.dll三个文件即可。

3、你在android studio经过了一顿操作,例如安装了一系列的sdk文件,还有创建了模拟器之后,也执行了第二步,环境变量也设置好了,在cmd中输入adb version。

这就代表了你已经彻底清除了旧版本的adb,用的是目前最新版本的adb。这个也会随着flutter upgrade的更新而更新。我今天更新了flutter版本,adb应该是最新的。

4、在管理员模式下打开cmd,输入adb devices,会看见当前已经打开了的安卓设备。

5、输入adb connect 你安卓设备的名字 。我的安卓设备名字是4ad32643。所以我就输入adb connect 4ad32543。

failed那一行不用管,这时候看回vscode或者是android studio,即会出现设备,可进行flutter的正常调试。

flutter 反编译

You are building a fat APK that includes binaries for android-arm, android-arm64.

If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.

To generate an app bundle, run:

    flutter build appbundle --target-platform android-arm,android-arm64

    Learn more on:

To split the APKs per ABI, run:

    flutter build apk --target-platform android-arm,android-arm64 --split-per-abi

    Learn more on: 

Initializing gradle...                                              2.3s

Resolving dependencies...                                          14.2s

Running Gradle task 'assembleRelease'...                                                  ע: E:\work_tool\flutter\.pub-cache\hosted\pub.flutter-io.cn\connectivity-0.4.4\android\src\main\java\io\flutter\plugins\connectivity\ConnectivityPlugin.javaʹ�û????����ѹ�ʱ�� API��

ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:deprecation ���±��롣

ע: E:\work_tool\flutter\.pub-cache\hosted\pub.flutter-io.cn\url_launcher-5.1.3\android\src\main\java\io\flutter\plugins\urllauncher\WebViewActivity.javaʹ

�û????����ѹ�ʱ�� API��

ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:deprecation ���±��롣

Calling mockable JAR artifact transform to create file: C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\android.jar\baf414ed95f14e507d85c560886dfbe2\android.jar with input E:\work_tool\sdk\android-sdk-windows\platforms\android-28\android.jar

Calling mockable JAR artifact transform to create file: C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\android.jar\ab096bb3fb172ccb785acdb1058c10a9\android.jar with input E:\work_tool\sdk\android-sdk-windows\platforms\android-27\android.jar

Request to incrementing alive workforce from 0. Current workforce (dead or alive) 0

thread-pool size=4

ProGuard, version 6.0.3

Reading input...

Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\flutter.jar\ab2691c929f4d2aa57a17fa551e662a6\jetified-flutter.jar] (filtered)

Reading program jar [F:\dartSpace\flutter\jiddspace\nfc\build\app\intermediates\flutter\release\libs.jar] (filtered)

Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\localbroadcastmanager-1.0.0.aar\7a407f962902eada026a8e241a760bac\jars\classes.jar] (filtered)

Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\work-runtime-2.1.0.aar\8e3a1e8a8ff79006a94df6c01ceeb4f5\jars\classes.jar] (filtered)

Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\fragment-1.1.0.aar\4fa7d1b49e3514cb08c8a696f9b59436\jars\classes.jar] (filtered)

Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\room-runtime-2.1.0.aar\1b8774fa39759f08defb930275652eac\jars\classes.jar] (filtered)

Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\room-runtime-2.1.0.aar\1b8774fa39759f08defb930275652eac\jars\libs\room-common-java8-2.1.0.jar] (filtered)

Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\viewpager-1.0.0.aar\885186e7f6f969363bc93cd607d741a5\jars\classes.jar] (filtered)

Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\loader-1.0.0.aar\f84f22ad0a97d2c689850b912fc04277\jars\classes.jar] (filtered)

Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\activity-1.0.0.aar\a46db1490fae1b9001fc672a24eb288f\jars\classes.jar] (filtered)

Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\customview-1.0.0.aar\fe8bf4a709414e884086911d2168b715\jars\classes.jar] (filtered)

Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\core-1.1.0.aar\87febb54759dd5a2c7be8e971d745644\jars\classes.jar] (filtered)

Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\versionedparcelable-1.1.0.aar\754157c6f50ca4e4cf3ac8d7cb5ced26\jars\classes.jar] (filtered)

Reading program jar [C:\Users\Administrator\.gradle\caches\modules-2\files-2.1\androidx.collection\collection\1.1.0\1f27220b47669781457de0d600849a5de0e89909\collection-1.1.0.jar] (filtered)

Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\lifecycle-livedata-2.0.0.aar\de6944801d37d99b1dd0b877649fde1f\jars\classes.jar] (filtered)

Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\lifecycle-livedata-core-2.0.0.aar\e21d6663beb6faa41a30fd5a582cb4d9\jars\classes.jar] (filtered)

Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\core-runtime-2.0.1.aar\724bb0cc2ce99eaf0a23a99bb1cc5c23\jars\classes.jar] (filtered)

Reading program jar [C:\Users\Administrator\.gradle\caches\modules-2\files-2.1\androidx.room\room-common\2.1.0\b87765704590bd992ea0d92ac50253a9df7818a0\room-common-2.1.0.jar] (filtered)

Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\sqlite-framework-2.0.1.aar\9cbdf82e938f7e565620a3682d2406e9\jars\classes.jar] (filtered)

Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\sqlite-2.0.1.aar\1215aa5476f752bd431fb2d8059a1a39\jars\classes.jar] (filtered)

Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\lifecycle-service-2.0.0.aar\9d24ebd4d6766d7b2cd515369a737934\jars\classes.jar] (filtered)

Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\lifecycle-runtime-2.1.0.aar\ca02c0867547ae607130bcc54a4a9ba5\jars\classes.jar] (filtered)

Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\lifecycle-viewmodel-2.1.0.aar\594e1ff6298a01d8933530bb534fa472\jars\classes.jar] (filtered)

Reading program jar [C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\savedstate-1.0.0.aar\8a2c3791a34fc80e5d9d268bf2886f95\jars\classes.jar] (filtered)

Reading program jar [C:\Users\Administrator\.gradle\caches\modules-2\files-2.1\androidx.lifecycle\lifecycle-common\2.1.0\c67e7807d9cd6c329b9d0218b2ec4e505dd340b7\lifecycle-common-2.1.0.jar] (filtered)

Reading program jar [C:\Users\Administrator\.gradle\caches\modules-2\files-2.1\androidx.arch.core\core-common\2.1.0\b3152fc64428c9354344bd89848ecddc09b6f07e\core-common-2.1.0.jar] (filtered)

Reading program jar [C:\Users\Administrator\.gradle\caches\modules-2\files-2.1\androidx.annotation\annotation\1.1.0\e3a6fb2f40e3a3842e6b7472628ba4ce416ea4c8\annotation-1.1.0.jar] (filtered)

Reading program jar [C:\Users\Administrator\.gradle\caches\modules-2\files-2.1\com.google.guava\listenablefuture\1.0\c949a840a6acbc5268d088e47b04177bf90b3cad\listenablefuture-1.0.jar] (filtered)

Reading program jar [F:\dartSpace\flutter\jiddspace\nfc\build\flutter_downloader\intermediates\intermediate-jars\release\classes.jar] (filtered)

Reading program jar [F:\dartSpace\flutter\jiddspace\nfc\build\shared_preferences\intermediates\intermediate-jars\release\classes.jar] (filtered)

Reading program jar [F:\dartSpace\flutter\jiddspace\nfc\build\url_launcher\intermediates\intermediate-jars\release\classes.jar] (filtered)

Reading program jar [F:\dartSpace\flutter\jiddspace\nfc\build\sqflite\intermediates\intermediate-jars\release\classes.jar] (filtered)

Reading program jar [F:\dartSpace\flutter\jiddspace\nfc\build\connectivity\intermediates\intermediate-jars\release\classes.jar] (filtered)

Reading program jar [F:\dartSpace\flutter\jiddspace\nfc\build\path_provider\intermediates\intermediate-jars\release\classes.jar] (filtered)

Reading program jar [F:\dartSpace\flutter\jiddspace\nfc\build\package_info\intermediates\intermediate-jars\release\classes.jar] (filtered)

Reading program directory [F:\dartSpace\flutter\jiddspace\nfc\build\app\intermediates\javac\release\compileReleaseJavaWithJavac\classes] (filtered)

Reading program jar [F:\dartSpace\flutter\jiddspace\nfc\build\app\intermediates\transforms\mergeJavaRes\release\0.jar] (filtered)

Reading library jar [C:\Users\Administrator\.gradle\caches\modules-2\files-2.1\androidx.annotation\annotation\1.0.0\45599f2cd5965ac05a1488fa2a5c0cdd7c499ead\annotation-1.0.0.jar] (filtered)

Reading library jar [E:\work_tool\sdk\android-sdk-windows\platforms\android-28\android.jar]

Reading library jar [E:\work_tool\sdk\android-sdk-windows\build-tools\28.0.3\core-lambda-stubs.jar]

Reading library jar [E:\work_tool\sdk\android-sdk-windows\platforms\android-28\optional\org.apache.http.legacy.jar]

Reading library jar [E:\work_tool\sdk\android-sdk-windows\platforms\android-28\optional\android.test.mock.jar]

Reading library jar [E:\work_tool\sdk\android-sdk-windows\platforms\android-28\optional\android.test.base.jar]

Reading library jar [E:\work_tool\sdk\android-sdk-windows\platforms\android-28\optional\android.test.runner.jar]

Initializing...

Warning: io.flutter.embedding.android.FlutterView: can't find referenced method 'android.graphics.Insets getSystemGestureInsets()' in library class android.view.WindowInsets

Warning: io.flutter.embedding.android.FlutterView: can't find referenced class android.graphics.Insets

Warning: io.flutter.embedding.android.FlutterView: can't find referenced class android.graphics.Insets

Warning: io.flutter.embedding.android.FlutterView: can't find referenced class android.graphics.Insets

Warning: io.flutter.embedding.android.FlutterView: can't find referenced class android.graphics.Insets

Warning: io.flutter.embedding.android.FlutterView: can't find referenced class android.graphics.Insets

Warning: io.flutter.embedding.android.FlutterView: can't find referenced class android.graphics.Insets

Warning: io.flutter.view.FlutterView: can't find referenced method 'android.graphics.Insets getSystemGestureInsets()' in library class android.view.WindowInsets

Warning: io.flutter.view.FlutterView: can't find referenced class android.graphics.Insets

Warning: io.flutter.view.FlutterView: can't find referenced class android.graphics.Insets

Note: io.flutter.view.AccessibilityViewEmbedder$ReflectionAccessors: can't find dynamically referenced class android.util.LongArray

Warning: io.flutter.view.FlutterView: can't find referenced class android.graphics.Insets

Warning: io.flutter.view.FlutterView: can't find referenced class android.graphics.Insets

Warning: io.flutter.view.FlutterView: can't find referenced class android.graphics.Insets

Warning: io.flutter.view.FlutterView: can't find referenced class android.graphics.Insets

Note: there were 1 unresolved dynamic references to classes or interfaces.

  You should check if you need to specify additional program jars.

  ()

Warning: Exception while processing task java.io.IOException: Please correct the above warnings first.

Thread(Tasks limiter_1): destruction

Warning: there were 12 unresolved references to classes or interfaces.

    You may need to add missing library jars or update their versions.

    If your code works fine without the missing classes, you can suppress

    the warnings with '-dontwarn' options.

    ()

Warning: there were 2 unresolved references to library class members.

    You probably need to update the library versions.

    ()

FAILURE: Build failed with an exception.

* What went wrong:

Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.

Job failed, see logs for details

* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at

BUILD FAILED in 4m 23s

Running Gradle task 'assembleRelease'...

Running Gradle task 'assembleRelease'... Done                    264.4s (!)

*******************************************************************************************

The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.

See for more information on the problem and how to fix it.

*******************************************************************************************

Gradle task assembleRelease failed with exit code 1

新建一个flutter项目,可以在ios上运行,四步搞定!

1. 建立一个flutter项目的命令

2. 在ios文件夹下,生成pods文件夹

3. Xcode环境签名设置;

把错误的版本删除再添加,可解决签名错误问题;必须先删除再添加,直接修改可能不起作用。团队开发,必须使用团队的签名。

4.运行创建的flutter项目;

选择真机、模拟机,点击运行按钮,或使用命令运行:

下面两步是赠送的:

5.新加一款插件,所涉及的命令;

ios 端所涉及的命令

6. 刚更新的插件和已有的插件有冲突怎么办?

可以试一试以下步骤:

为什么Flutter开发APP性能最接近原生,前端程序员请关注

Flutter是谷歌公司推出的跨终端的开发框架,支持Android、iOS和WEB终端。1.0版在2018年12月5日发布,目前的最新版本是1.5,它采用的开发语言是Dart,Dart也是谷歌开发的计算机编程语言,语法类似C,是编译型语言:

hello world例子,打印字符串“Hello World!”:

1、没有桥接层

React Native、Weex等技术都是跨终端的框架,然而性能跟原生App存在很大差距。这是由于它们的工作原理决定的:

React Native、Weex等技术多了一个桥接层,所以界面渲染会慢一些,由于UI渲染非常频繁,想要不卡顿,基本上比较难,性能和用户体验跟原生代码有差距。而这恰恰是Flutter的优势所在:

Dart可以被编译成不同平台的本地代码,让Flutter不通过桥接层直接跟平台通信,自然性能会快一些。

2、编译执行

JavaScript是解释执行的,Dart是编译执行的,性能谁好一目了然。

3、Flutter Engine虚拟机

Flutter是依靠Flutter Engine虚拟机在iOS和Android上运行的,Flutter Engine使用C/C++编写,开发人员通过Flutter框架直接和API在内部进行交互,所以具有输入低延迟和UI渲染高帧速率的特点。除了这特点之外,Flutter还提供了自己的小部件,Flutter小部件是使用从React获取灵感的现代框架构建的。 中心思想是您使用小部件构建UI。

窗口小部件根据其当前配置和状态描述了它们的视图。 当窗口小部件的状态发生更改时,窗口小部件会重建其描述,框架将根据前面的描述进行区分,以确定底层呈现树从一个状态转换到下一个状态所需的最小更改。可以直接在OS平台提供的画布上进行描绘,也就是一些核心类库直接放到虚拟机里面,调用起来更快。

从它的系统结构可以看出,类似安卓的ART(Android Run Time)虚拟机,同样采用AOT(Ahead of TIme)技术,会在APP安装时就编译成机器语言,不再解释执行,从而优化了APP运行的性能。

4、自带渲染引擎

Flutter使用谷歌自己的Skia渲染引擎,而Android系统自带Skia引擎,iOS平台上Flutter也会把Skia引擎打包到APP中,从而实现了高效渲染。而React Native通过桥接层访问原生UI,操作频繁就容易出性能问题。

综合所述,Flutter 是性能最接近原生代码 的一种开发框架,未来也会是构建谷歌Fuchsia应用的主要方式,前途不可限量,唯一的问题就是需要学习一门新的语言:Dart,而有Java或者C#语言基础的程序员会比较容易学习。

离不开DART的Flutter(dart篇)

hello world例子

在终端打印字符串‘Hello World!’

计算斐波那契数列

一个简单的类

计算两点距离

异步并发示例

使用了Isolate

1.面向对象

对于面向对象这个概念,相信了解Java的同学对这个概念一定不会陌生。

例如:我们有个Person Object他有很多特征和行为。

这些都是这个Person Object的属性。

也就是因为有了这些特征,行为等等才决定了这个人是谁。

那么回到Dart当中,所有的都是对象,那么在就可以可以跟进对象的属性的特征,方法等等来进行编程。

之所以我们在这里又特别强调了一下面向对象的概念,是因为这个概念在Dart语言当中,至关重要!

2.最重要的几个概念

3.Dart的部分特性

4.Dart的内置库

包名

描述

dart:asynv

异步编程,提供Future,Stream类

dart:collection

集合

dart:convert

不同类型的字符编码解码

dart:core

Dart语言核心功能,内置类型

dart:html

网页开发用到的库

dart:io

文件读写,IO相关

dart:math

数字常量以及函数,随机算法等

dart:svg

事件和动画矢量图支持

综上述所说要想学Flutter,先学Dart!关于Flutter下篇我会讲到。为什么离不开dart!

有关更多面经、核心技术笔记;自己也是从事Android开发5年有余了;整理了一些Android开发技术核心笔记和面经题纲, 如有需要的同学请私信我回复“核心笔记”或“面试”领取!


网站栏目:flutter1.5.4,flutter22
当前URL:http://bzwzjz.com/article/dsdogcc.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 成都网站建设 营销型网站建设 成都网站建设 攀枝花网站设计 网站建设改版 重庆网站建设 成都网站设计公司 成都网站建设推广 成都网站建设 企业手机网站建设 重庆网站建设 企业网站建设公司 高端品牌网站建设 响应式网站设计 成都商城网站制作 LED网站设计方案 移动网站建设 外贸网站设计方案 手机网站建设 成都网站设计 重庆网站制作 成都网站制作