网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

aflutteron的简单介绍

"flutter"是什么意思

1. (鸟)振翼,拍翅

创新互联建站专注于企业成都全网营销、网站重做改版、仙居网站定制设计、自适应品牌网站建设、H5场景定制成都商城网站开发、集团公司官网建设、外贸网站制作、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为仙居等各大城市提供网站开发制作服务。

2. (旗帜等)飘动,飘扬

The flag fluttered in the breeze.

旗帜在微风中飘动。

3. (脉搏,心脏)不规则跳动

Her heart fluttered with fear.

她因害怕心跳得厉害。

4. 焦急地乱动

5. 颤动;(激动得)发抖

His fingers fluttered.

他的手指颤动。

vt.

1. 振(翼),拍(翅)

The young bird fluttered its wings.

雏鸟拍打着它的翅膀。

2. 使焦急,使不安

3. 使飘动

n.

1. 振翼;飘动[S]

2. 兴奋;激动;焦急[S]

That TV play caused a mild flutter among the viewers.

那出电视剧在观众中稍稍引起轰动。

3. 【英】【口】小赌;小投机[C][S1]

4. 【医】(心脏等的)扑动,振颤[C]

5. (录音机)放音失真,音频颤动[U]

有关于引导的介词必备短语

在英语里,介词短语数量之多,可以和片语动词互相比拟,不与它们亲近也难。

由on引导的介词短语

(1) On the air:在广播中

The Prime Minister's National Day speech was broadcast live and will be on the air again.

(2) On balance:权衡轻重之后

Our national football feam sometimes won but sometimes lost. On balance, it has had a quite good track record.

(3) On the dole:接受福利金

In the West, unemployed workers can still survive if they are on the dole.

(4) On an even keel:平稳的

The grocery business has experienced a tough period, but it is back on an even keel.

(5) On the loose:不受拘束的

According to some newspaper reports, a big tiger is on the loose in an outlying island.

(6) On the make:热衷于追求名利

Among your friends, do you have some continually on the make?

(7) On the mend:病情在好转件

When I saw Mike last time, he was quite ill, but he is now said to be on the mend.

(8) On the move :在活动中

A good friend of mine has been on the move in and out of the country, trying to find business to do.

(9) On a par with:和平等

The flowers in that garden are pretty, but I am not sure if they are on a par with yours.

(10) On the quiet:秘密地

Some foreign students have been making money on the quiet during school holidays.

(11) On the rocks:遭受失败

His ill-fated attempt has landed itself on the rocks.

(12) on the run:在逃跑中

One kidnapper has been arrested, but others are still on the run.

(13) On a shoestring:小本经营地

Xiao Lei ran his business on a shoestring before it was expanded.

(14) On the side:作为兼职

Some low-income people have to take up a second job on the side.

(15) On the sly:秘密地;偷偷地

Smoking was prohibited in school, but some students did it on the sly or in the lavatory.

(16) On the spot:当场;立即

When an adult shoplifter is caught on the spot, he or she will be sent to prison.

(17) On tenterhooks:提心吊胆

Those waiting for the outcome of university admission are on tenterhooks beyond their control.

(18) On the rack:极度焦虑不安

When the doctor did not say anything after seeing the patient, the patiant felt somewhat on the rack.

(19) On tap:随时可得到的

The director has a wide circle of friends who are on tap when needed.

(20) On the cards :有可能重现的

Unconfirmed news has it that a new university could be on the cards.

(21) On edge:紧张;着急;

When the small boy could not see his mother in the crowd, he was on edge and cried.

(22) On call:待命

The company car is always on call to take the Chief Executive Officer to meetings.

由in引导的介词短语

(1) In the air:尚未确定的

Some neighbouring governments' concrete plans to alleviate their economic problems are still in the air.

(2) In clover:(常和 live连用)生活舒适

Those living in clover will not be able to understand the misery of the poor.

(3) In deep water:深深陷入困境

You had better get away from that business or you will be in deep water with no one to pull you out.

(4) In low spirits:士气低沉的

What's wrong with you ? You looked fine a moment ago. Why are you now in low spirits?

(5) In a fix:面临困境

Some newly-weds are in a fix now; when can they get their HDB flats and move in ?

(6) In a flutter:处在紧张状态中

The news about the dignitary's visit put the staff in a flutter.

(7) In full swing:如火如荼地

The celebration for welcoming the victorious national team is already in full swing.

(8) In the know:知道详情的

The manager has resigned. For further information, please see the secretary, who is in the know.

(9) In limbo:处于不确定的状态中

The decision on the oversea project is in limbo, due to some indeterminate factors.

(10) In a flash:瞬息间

I don't know what happened to Grace, who went out and retuned in a flash.

(11) In the limelight:众人注意的焦点

Once a person becomes famous, he will be in the limelight. all the time with very litte private time.

(12) In a nutshell:简而言之

I have a lot to say about his latest book, but to put it in a nutshell, it is a good work.

(13) In the offing:即将到来

According to a newspaer report, a minor cabinet reshuffle is in the offing.

(14) In the pipeline:在准备中

The TV magazine indicates that some new TV serials are in the pipeline.

(15) In the open:公开的

The hearsay about a minister's resignation has now become a fact; everything is now in the open.

(16) In the same boat:面临同样的不幸处境

If a company cannot survive, many others will be in the same bboat, and working people will be in for a hard life.

(17) In step with:和符合

Is it possible to expect the opinion of every member to be in step with that of the party leaders?

(18) In store for:即将发生;即将到来

For every capable person, there is a promising future in store for him.

(19) In the swim:通晓时务

If you are to keep your information up to date, please see Jimmy, who is always in the swim.

(20) In a tight squeeze:(财务等)紧缩

When in a tight squeeze, a company has to resort to the bank for assistance.

由at引导的介词短语

1. At bay:(经常和keep或hold连用)使不能接近

One of the gangsters kept the police at bay until the rest escaped.

2. At bottom:实际上

Judy said she was not jealous of her friends' success, but at bottom, she was.

3. At close quarters:逼近地

The two rivals grappled at close quarters.

4. At cross purposes:互相误解

I think we are at cross purposes. When I said J.C., I meant Jason Chen, not John Chen.

5. At daggers drawn:势不两立

Dan and Bob have been at daggers drawn for years. There is no evidence that they will make up.

6. At every turn:处处

When you go downtown, you will see shops, big and small, at every turn.

7. At one fell swoop:一举

Which country can invade another country and conquer it at one fell swoop?

8. At issue:在讨论中的

The question asked was not relevant to the matter at issue .

9. At large:一般的;逍遥法外的。

a. The people at large support the government's various policies.

b. Some illegal immigrants were caught, but some others are still at large.

10. At length:详细地

Time did not allow the speaker to talk about the financial turmoil at length.

11. At loggerheads with:经常和争吵

Mr and Mrs Thang are often at loggerheads with each other. Why can't they get along well?

12. At a loss for words:不知说什么好

The news came so surprisingly that she was at a loss for words.

13. At a low ebb:处于低潮

Henry's mood seems to be at a low ebb now; let's cheer him up a bit.

14. At a price:付高代价

Some people became successful at a price; their health and family life were adversely affected.

15. At random:随意地

One may choose things at random, but not the prospective life partner.

16. At the ready:处在准备状态中

At the news conference, news reporters gathered around, pens and notebooks at the ready.

17. At sea:茫然

Those not interested in politics will be at sea when people discuss political issues.

18. At a stretch:连续地

In order to earn money, some workers do overtime works for a few days at a stretch.

19. At will:任意地

In a society like ours, one has to be law-abiding and not to do things at will.

20. At one's wits end:不知所措

Chased by the enemy to an abyss, the man could not advance any more, nor could he retreat; he was at his wits end.

21. At heart:在内心里;本质上

a. A good leader often has the people's interests at heart.

b. Though Xiao Gan works in a city, he is a country boy at heart.

22. At sixes and sevens:乱七八糟

When the maid returned to work after three days' leave, she found all the rooms at sixes and sevens.

Flutter进阶篇(4)-- Flutter的Future异步详解

本文首发在公众号 Flutter那些事 ,欢迎大家多多关注。

工具安装:

Flutter基础篇:

Flutter进阶篇:

Dart语法基础篇:

Dart语法进阶篇:

说明:本文中的所有函数的引用在 main 函数中:

这里的执行结果是:

Futue直接new就可以了。我这里没有具体的返回数据,所以就用匿名函数代替了, Future future = new Future(() = null); 相当于 FutureNull future = new Future(() = null); 泛型如果为null可以省略不写,为了便于维护和管理,开发中建议加上泛型。

输出结果是:

future里面有几个函数:

then :异步操作逻辑在这里写。

whenComplete :异步完成时的回调。

catchError :捕获异常或者异步出错时的回调。

因为这里面的异步操作过程中没有遇到什么错误,所以catchError回调不会调用。

我们可以看到执行结果是:

我们可以看到输出结果是: 2 1 3 和我们创建Future对象的先后顺序完全一致。

我们可以看到结果为 1 2 3 ,和我们调用then的先后顺序无关。:

当then回调函数里面还有then回调的时候,这时候的流程跟前面就不太一样了,也是一个大坑,也是面试经常会被问到的一个知识点。

我们可以看到执行结果如下:

结果还是一样的:

运行结果是:

这里再次证明了上面我的猜想: 执行顺序和和创建Future的先后顺序有关,如果有多个then嵌套执行,先执行外面的then,然后执行里面的then。

执行结果如下,我们可以看到then内部创建的Future要等到then执行完了,最后再去执行的:

根据上文总结的特点,我们可以不用运行也能推断出输出结果:

为了验证我们的猜想,我们打印一下输出结果,果然我们的证明是正确的。

我们重点看看 then函数的文档说明:

then 注册在 Future 完成时调用的回调。

当这个 Future 用一个 value 完成时,将使用该值调用 onValue 回调。

如果 Future 已经完成,则不会立即调用回调,而是将在稍后的 microtask(微任务) 中调度。

如果回调返回 Future ,那么 then 返回的 future 将与 callback 返回的 future 结果相同。

onError 回调必须接受一个参数或两个参数,后者是[StackTrace]。

如果 onError 接受两个参数,则使用错误和堆栈跟踪时调用它,否则仅使用错误对象时候调用它。

onError 回调必须返回一个可用于完成返回的future的值或future,因此它必须是可赋值给 FutureOr R 的东西。

返回一个新的 Future ,该 Future 是通过调用 onValue (如果这个Future是通过一个value完成的)或' onError (如果这个Future是通过一个error完成的)的结果完成的。

如果调用的回调抛出异常,返回的 future 将使用抛出的错误和错误的堆栈跟踪完成。在 onError 的情况下,如果抛出的异常与 onError 的错误参数“相同(identical)”,则视为重新抛出,并使用原始堆栈跟踪替代

如果回调返回 Future ,则 then 返回的 Future 将以与回调返回的 Future 相同的结果完成。

如果未给出 onError ,并且后续程序走了刚出现了错误,则错误将直接转发给返回的 Future 。

在大多数情况下,单独使用 catchError 更可读,可能使用 test 参数,而不是在单个 then 调用中同时处理 value 和 error 。

请注意,在添加监听器(listener)之前, future 不会延迟报告错误。如果第一个 then 或 catchError 调用在 future 完成后发生 error ,那么 error 将报告为未处理的错误。

Flutter入门这一篇效率文章就够了

本文面向 Flutter 初学者,旨在用易懂的方式带大家入门。除了 Flutter 代码,还会介绍到语法、原理、特性等基础知识。相信本文能帮助你学习和理解 Flutter。

我们先看一下目前的一些跨平台方案,从前端渲染的角度来分类的话,大致可以分为以下几种方案。

WebView 渲染

这种方案就很好理解,现在很多项目都会嵌入 H5 的页面。就是用 JavaScript 等前端技术进行开发,在客户端上用 WebView 来进行渲染。微信小程序目前使用的就是这种方案。

它的优点很明显,使用成熟的前端技术进行开发,学习成本低,开发效率高,并且支持动态发布代码。

但缺点也很明显,在性能体验上,和原生还是存在较大差距的。

原生控件渲染

既然 WebView 的性能不够好,于是就有了使用原生控件进行渲染的方案。这种方案,同样也是使用 JavaScript 开发,区别是它最终是调用原生控件进行渲染的。这种方案的代表是 Facebook 的 React Native。

由于使用原生控件进行渲染,性能体验也会更接近原生。但也只是更接近,和原生还是有差距的,因为它需要频繁的进行 JavaScript 和原生之间的通信,这个通信效率是比较低的。

另外,由于需要适配各个平台的控件,那就有可能出现,系统控件更新了,而框架本身还没有更新,由此产生了一些问题。换句话说,这种方案是受到原生控件限制的。

绘图引擎渲染

接下来就是主角了。

在前端,如果完全不使用原生控件,我们可以通过系统的绘图 API 绘制出一个用户界面。从这个角度出发,可以在各个平台使用一个统一接口的绘图引擎来进行界面绘制,这个引擎最终调用的是系统的 API 绘制的。这样的话,它的性能可以做到接近原生,并且又不受原生控件的限制,在不同平台上能够做到 UI 统一。

Flutter 就是这样的一个开发框架。

一个跨平台 UI 解决方案

Flutter 是由 Google 开发的,一个跨平台 UI 解决方案。换句话说,它原则上只管 UI 的问题,如果涉及到平台本身的一些功能,比如调用蓝牙、摄像头,一般还是需要原生代码去操作。但现在也会有一些第三方库帮我们解决这些问题。

绘图引擎 Skia

Flutter 使用 Skia 作为它的绘图引擎。Skia 已经被 Google 收购,目前很多 Google 旗下的产品都是用 Skia 绘制的,包括 Android。

Android 内置了 Skia,但 iOS 没有,所以在打 iOS 安装包的时候,会把 Skia 一起打进去。这就导致了,用同一份 Flutter 代码打包之后,iOS 的包要比 Android 的包大一些。

开发语言 Dart

Flutter 使用的开发语言,叫 Dart。Dart 也是 Google 自家的,它是一门面向对象的语言,从它身上会看到一些其他开发语言的影子。学习起来难度不大的。

前面讲跨平台方案的时候,可以发现别的方案基本都是用 JavaScript 作为开发语言的,但为什么 Flutter 不用?就因为 Dart 是谷歌自家的吗?这个问题先留着,我们后面会提到。

这里部分就简单点带过了,具体的搭建流程可以在官网查看:

主要的搭建步骤如下:

下载 Flutter SDK

官网下载地址:

由于在国内访问可能受限,官方为中国开发者搭建了镜像:

更新环境变量

解压后,将 flutter\bin 的全路径添加到环境变量 PATH 中。

安装开发工具

理论上,任何文本编辑器都可以用来开发 Flutter 应用,但推荐的开发工具是 Android Studio、IntelliJ 以及 VS Code。因为在这些开发工具上,可以安装官方的 Flutter 和 Dart 插件,得到更好的开发体验。文章里使用 Android Studio 来演示。

如果你打算开发 iOS 应用,则还需要安装 Xcode。

安装插件

在开发工具的插件设置中,安装上面说到的 Flutter 和 Dart 插件。Flutter 插件用于支持 Flutter 的运行、调试、热重载等功能,而 Dart 插件则提供了代码的输入校验、代码补全等功能。

万物始于 Hello World,我们先来创建一个显示 Hello World 的 Flutter 项目。

在 Android Studio 的欢迎页面选择 Start a new Flutter project ,或者通过菜单栏的 File New New Flutter Project ,创建一个新的 Flutter 项目。

创建好的项目里面包含了 android 和 ios 两个文件夹,它们是标准的 Android 和 iOS 项目。我们的 Flutter 代码,存放在 lib 文件夹里。项目创建好后,会默认带一个计数器的示例,我们不管它,把 main.dart 的代码改成 Hello World:

启动一个模拟器,或者连上真机,点击 Run 运行一下,就能看这样一个界面了:

具体代码先混个眼熟就好,具体的后面会再讲到。

在写 Flutter 之前,还要先跟大家简单介绍一下 Dart 的语法。如果你有 Java 或 JavaScript 的开发经验,以及面向对象的编程思想,学起来是很快的。

我们可以在 test 文件夹下新建一个 dart 文件,用来写测试代码。

指定类型

var

但和 JavaScript 不同的是,以下代码在 JavaScript 是不会报错的,但在 Dart 里会报错:

Object

如果非要上面这样写,那也可以。把 var 换成 Object 就不报错了:

和 Java 类似,Object 是所有对象的根基类。但是这样的话,如果想打印一下 num 的字符串长度,是会报错的:

因为 length 是属于 String 的,但系统只知道 num 是一个对象,并不知道它是一个 String。

dynamic

如果还是非要这样写,那也可以。Dart 有一个特有的关键字 dynamic,把 Object 改成 dynamic 就不报错了:

我们运行一下这个文件,可以在控制台看到正确打印出了字符串长度。

函数

dynamic

在 Dart 里,函数也是可以不写返回类型的,不写的话会被当做 dynamic 来处理。这样的话,函数的类型就是 return 的类型,如果没有 return 则是 void 类型。比如可以这样:

运行之后是能正确打印出字符串长度的。

用于传参

Dart 里的函数也是一个对象,所以可以把函数作为参数来传递,比如:

可选参数

在 Dart 的函数传参里,有一个叫可选参数的概念,我们以文字控件 Text 为例,在源码里可以看到 Text 的构造函数是这样的:

首先,在参数里有一个 data,它是要显示的文字内容,是一个必填项。而 data 后面的一堆参数,是用一个大括号括起来的,这些参数就叫做可选参数,意思是这些参数可传可不传。

假如我们要显示一个比较长的文字,又想限制它最多显示两行,就可以这样来创建一个 Text:

可选参数,在 Flutter 里面用的非常多。

异步

Future

在 Dart 里使用 Future 来处理异步任务,比如我们现在延时一秒打印 666,代码如下:

Future 的语法和 Promise 非常像。任务执行成功会调用 then,执行失败会调用 catchError,而无论成功还是失败,都会调用 whenComplete。

async/await

如果你不喜欢上面那种写法,或者是想把异步转成同步,就可以用 async 和 await 这两个关键字来转换。

我们把上面的代码转换一下,写一个 getString 方法,返回的类型是 Future,它会延时返回一个字符串。在 main 函数后面加上 async 关键字,在 getString() 前面加上 await,代码如下:

运行之后可以看到,能正常延时一秒后,把字符串打印出来。这里 getString() 返回的类型是 Future,而 await getString() 则是返回了延时之后返回的字符串。await 要在 async 的函数里面才能使用。

async 和 await 其实是一个语法糖,它最终也是转换成 Future 调用链的形式执行的。

接下来回到 Flutter,Flutter 里最重要的一个概念是 Widget(下面翻译作控件)。

在原生开发里面,我们可能会在界面上区分,这是一个 View,这是一个 Layout,这是一个 View Controller。但在 Flutter 里面,它们全都属于一个统一的模型 Widget。可以说,在 Flutter 界面里,所有东西都是 Widget。

以前学面向对象的时候,我们都听过一句话,叫万物皆对象。我这里套用一下,在 Flutter 里, 万物皆控件 。

具体有哪些控件,我做了一下简单的分类。

根控件

所有的控件都属于 StatefulWidget 或 StatelessWidget 。它们的区别是,StatefulWidget 拥有状态 State ,而 StatelessWidget 没有。

StatefulWidget

当一个控件是可变的时候,就要使用 StatefulWidget 来构建。StatefulWidget 本身不可变,但它持有的状态 State 是可变的。

StatelessWidget

当一个控件状态是固定不可变的时候,就可以使用 StatelessWidget。前面我们写的 Hello World 就是使用 StatelessWidget。

容器控件

容器类控件一般是将某些属性或配置,作用在它的子控件上,比如控件所在的宽高、背景、位置等。

常用的容器控件有 Container、Center、Padding 等。

布局控件

布局控件可以类比作原生开发中的 Layout,通常它会拥有一个 children 的属性,用于接收一个控件数组,对这些控件进行特定的排版。

常用的布局控件有 Row、Column、Stack、Flex 等。

基础控件

基础控件就是常用的文字、按钮、图片等控件。

常用的基础控件有 Text、TextField、Button、Image 等。

功能控件

在 Flutter 里还有一类控件,它们不影响 UI 布局,但带有一些特定的功能,比如页面跳转、事件监听、定义主题等。我们把这一类控件称作功能控件。

常用的功能控件有 Navigator、NotificationListener、Theme 等。

开始写 Flutter 代码了。还记不记得,在 Flutter 项目创建之后,是自带一个计数器 demo 的,现在我们用自己的代码实现一遍。代码修改成如下:

运行之后,就可以看到这样的界面了:

按钮每点击一次,数字就会加一。下面我们来分析一下这段代码,看下里面用到的一些 Widget。

StatefulWidget

由于页面中的数字是跟随状态变化的,所以该页面改用 StatefulWidget。StatefulWidget 并不会直接返回一个 Widget,而是返回状态 State,在 State 里再返回 Widget。

Scaffold

Scaffold 是一个标准的 Material Design 页面,它包含了标题栏、浮动按钮、侧滑菜单、底部导航栏等配置。我们这里用到了标题栏 appBar、页面内容 body、浮动按钮 floatingActionButton。

AppBar

AppBar 就是标题栏,通过查看控件的构造方法,我们可以知道它可配置的属性。

AppBar 的可选参数除了标题 title,还可以配置标题前的内容 leading,右侧的操作按钮 anctions,控件垂直高度 elevation 等。我们只传了 title,其他属性都用默认值。

Center

Center 是一个容器类控件,它的作用就是让它的子控件居中显示。

FloatingActionButton

熟悉安卓开发的应该对这个控件比较熟悉,它就是页面右下角一个特定样式的 Button,参数里面的 onPressed 是一个必填项,要传一个点击之后的回调函数。

根据这个例子,下面给大家介绍一下 Flutter 两个比较重要的特性。

点击 Button 之后,我们把 num 变量加一,并使用 setState 通知状态发生了改变,Flutter 会根据新的状态更新 UI。如果有接触过小程序开发,setState 就和小程序的 setData 类似。

在 Flutter 里面我们不需要用 set 方法来更新 UI,可变控件是和状态绑定的,这就是 Flutter 的响应式 UI 编程。

在 Android Q 和 iOS 13 里都加入了暗黑模式,我们也换一个暗黑主题来玩一下。MaterialApp 里有一个 theme 的属性,我们把它配置一下:

这次改完之后不点 Run 了,我们点一下闪电图标 Flutter Hot Reload ,就能看到界面发生了变化:

这就是 Flutter 的 热重载 ,在修改完代码之后,通过热重载就能马上在设备上看到修改结果,可以很大程度上增加开发效率。

下面再给大家介绍几个 Flutter 里的常见操作。

在 Flutter 里,使用 Navigator 来管理页面跳转,比如要跳转到一个 NewPage 可以这样写:

进栈使用 push,出栈则是 pop。

使用 MaterialPageRoute 会模拟出 Android 上页面跳转的过场效果。

我们来看看怎么显示一张本地图片。

先在根目录新建一个存放图片的文件夹,比如叫 images,把图片 picture.png 放进去。

找到根目录下的 pubspec.yaml 文件,这个便是 Flutter 依赖配置文件,我们需要在这里配置一下刚才的图片:

这样,我们就能使用 Image 控件把这张图片显示出来了:

和 node 的 npm 以及 Android 的 jcenter 类似,Flutter 也拥有一个公共仓库 pub.dev。pub.dev 是 Google 官方的 Dart 仓库,在上面可以找到我们需要的包和插件。

Flutter 本身没有 Toast,我们来接入一个。在 pub.dev 上搜索后,我决定使用 fluttertoast:

按照说明,在 pubspec.yaml 文件里的 dependencies 下配置:

点一下 Android Studio 右上角的 Packages get 同步之后就可以使用了:

我们上面使用的都是 Material Design 的控件,它们都是在 flutter/material.dart 包里面的。如果要使用 iOS 风格的控件,则要用到 flutter/cupertino.dart 包:

iOS 风格的控件,基本都以 Cupertino 开头。我们把计时器页面里的控件替换一下:

效果如下:

代码的部分就到这里了,接下来跟大家聊一下编译方式,编程语言的编译方式有两种。

关于它们孰优孰劣,就要看从哪个角度去对比了。JIT 的话,它的一大特点就是支持动态发布代码,也就是支持热更新。但要是从性能的角度考虑,AOT 会更好,因为在运行的时候不用再进行编译的操作的,运行的效率会更高一些。

回到我们一开始的时候留下的问题,为什么别的跨平台方案都是用 JavaScript,而 Flutter 要用 Dart 来开发。JavaScript 的编译方式是 JIT 的,它不支持 AOT。而 Dart 同时支持 JIT 和 AOT。

Flutter 在开发阶段使用 JIT,让我们用上了热重载,增加了开发效率。在打包时改用 AOT,保证了正式版应用的性能。

最后讲一下大家比较关心的一个东西,Flutter 是否支持热更新?前面说到 Dart 支持 JIT,所以从技术层面它是支持的。但是目前是不支持的,在官方的计划文档中,可以看到:

至于原因,官方在这里进行了说明。总的来说,是由于政策的限制,以及出于对性能和安全性的考虑,暂时不支持了。

到这就结束啦。由于想把 Flutter 基础在一篇内讲完,没有涉及太多细节,如果要写 Flutter 代码还需要深入学习。但相信理解之后再学,会轻松很多。

“忐忑不安” 怎么用英文翻译??

be very upset; be in fidgets; be in a rather nervous state; be on nettles; be overwhelmed with anxiety; be thrown into [put in; put into] a flutter; feel troubled and uneasy; fret and fume; ill at ease; nervous and uneasy; uneasy at heart


当前题目:aflutteron的简单介绍
路径分享:http://bjjierui.cn/article/hooeis.html

其他资讯