flutter开发小程序
Why do app makers love Flutter? Because Flutter is amazing.
为什么应用程序制造商喜欢Flutter? 因为Flutter很棒。
Flutter caters to both businesses (by offering reasonable development costs) and developers (by offering great usability and speed). That’s why some big companies have switched to Flutter, such as Google Ads, Alibaba, Reflectly, and many more.
Flutter同时满足企业(通过提供合理的开发成本)和开发人员(通过提供出色的可用性和速度)。 这就是为什么一些大公司转而使用Flutter的原因,例如Google Ads,阿里巴巴,Reflectly等。
Google has done a great job building Flutter, and they continue making this framework even better.
Google在构建Flutter方面做得很出色,并且他们继续使该框架变得更好。
In this post, I’ll give a quick overview of Flutter and its brand new perks, and I'll talk about why this framework is worth working with. Plus, I'll discuss what may hold big companies back from adopting Flutter.
在本文中,我将简要介绍Flutter及其全新的功能,并讨论为何值得使用此框架。 另外,我将讨论什么可能阻止大公司采用Flutter。
But first things first.
但是首先是第一件事。
什么是颤振的要旨? (What’s the Gist of Flutter?)
Here are things about Flutter you may already know:
以下是您可能已经知道的有关Flutter的信息:
- it's an open-source, cross-platform toolkit 这是一个开源,跨平台的工具包
- apps are written in the Dart programming language 应用程序是用Dart编程语言编写的
- it has its own graphics engine (Skia) 它有自己的图形引擎(Skia)
- it supports three platforms officially: iOS, Android, and web (in beta) 它正式支持三种平台:iOS,Android和Web(测试版)
- unofficially – it also supports desktop 非官方的-它也支持桌面
Google introduced the first version of Flutter at the end of Feb 2018. As of April 2020, 1.12 release is available.
Google于2018年2月底推出了Flutter的第一个版本。从2020年4月开始,1.12版本可用。
Flutter有什么特别之处? (What's so special about Flutter? )
Flutter combines the quality of native apps with the flexibility of cross-platform development.
Flutter结合了本机应用程序的质量和跨平台开发的灵活性。
Actually, many cross-platform tools let you write the code once and use it on both iOS and Android. Yet not all can render the same look like a native app.
实际上,许多跨平台工具允许您编写一次代码并在iOS和Android上使用它。 但是,并非所有人都可以像本机应用程序一样呈现相同的外观。
But that's exactly what Flutter does: instead of being a wrapper on top of native UI components (like React Native and Xamarin), Flutter draws the UI from scratch.
但这正是Flutter所做的:Flutter并不是从本地UI组件(如React Native和Xamarin)之上进行包装,而是从头开始绘制UI。
Flutter maintains the native experience and feel of the app, and you don't have to worry about its performance on any platform.
Flutter保留了该应用程序的本机体验和感觉,您无需担心其在任何平台上的性能。
Besides, since Flutter's an open-source framework, any dev can make changes to it on GitHub and send merge requests. And if you take a look at Flutter's popularity – 90.4K GitHub stars, 12k forks, and 18,445 commits – you'll get the idea that devs love Flutter and contribute to making it better.
此外,由于Flutter是一个开源框架,因此任何开发人员都可以在GitHub上对其进行更改并发送合并请求。 而且,如果您看一看Flutter的受欢迎程度– 90.4K GitHub star , 12k forks和18,445 commits –您会发现开发人员喜欢Flutter并为使其变得更好做出了贡献。
颤振如何工作? (How Does Flutter Work?)
Flutter isn't compiled directly to iOS or Android apps. Apps are launched based on a combination of rendering engine (built on C++) and Flutter (built on Dart). All files generated this way attach to each app and SDK assemblies software for a specific platform.
Flutter不能直接编译为iOS或Android应用程序 。 应用是基于渲染引擎(基于C ++构建)和Flutter(基于Dart构建)的组合启动的。 以这种方式生成的所有文件都将附加到特定平台的每个应用程序和SDK程序集软件。
It's like game development: a game doesn't allocate its framework, and functionality is carried out with the game engine. Same for Flutter software – all apps based on the Flutter SDK replace parts of native frameworks with Flutter elements.
就像游戏开发一样:游戏不分配框架,功能由游戏引擎执行。 与Flutter软件相同–所有基于Flutter SDK的应用程序都使用Flutter元素替换了本机框架的某些部分。
Although it can impact the size of the end app, performance is still quite good – rendering is made with speeds up to 120 FPS.
尽管它会影响最终应用程序的大小,但性能仍然相当不错-渲染速度高达120 FPS 。
Due to native compilation for ARM processors, simple rendering, and a set of integrated widgets and tools, Flutter makes the development process simpler.
由于针对ARM处理器的本机编译,简单的呈现以及一组集成的小部件和工具,Flutter使开发过程更简单。
Plus, it offers a few very tasty features like Hot Reload.
此外,它还提供了一些非常实用的功能,例如Hot Reload 。
Here’s how it works:
运作方式如下:
When you click on the Hot Reload button, all changes in code are displayed in gadgets, emulators, and simulators right away. The app continues working from where it was before you hit the hot reload: the code updates, but execution continues.
当您单击Hot Reload按钮时,所有代码更改都会立即显示在小工具,仿真器和仿真器中。 该应用程序从您遇到热重载之前的位置继续工作:代码已更新,但执行仍在继续。
为什么要为跨平台应用程序选择Flutter? (Why Choose Flutter for Cross-Platform Apps?)
New Flutter versions will keep coming out with more advanced features up their sleeves. But there are already a lot of enhanced features that perfectly explain why Flutter is so well-loved.
Flutter的新版本将不断推出更多高级功能。 但是已经有很多增强功能可以完美地解释为什么Flutter如此受欢迎。
First, cross-platform development with Flutter, contrary to popular belief, doesn't make software worse.
首先 ,与流行的看法相反,使用Flutter进行跨平台开发不会使软件变得更糟。
Flutter comes with all native widgets for Android and iOS interfaces like Material Design and Cupertino. Besides, the framework can change the behavior of separate elements to create similar UX for the app's users.
Flutter随附了适用于Android和iOS界面的所有本机小部件,例如Material Design和Cupertino。 此外,框架可以更改单独元素的行为,以为应用程序用户创建类似的UX。
Second, Flutter makes it possible to implement discrete file compilation in the dev mode. JiT compilation speeds up development and software debugging.
其次 ,Flutter使在dev模式下实现离散文件编译成为可能。 JiT编译加快了开发和软件调试的速度。
Third, Flutter allows for a flexible and scalable backend.
第三 ,Flutter允许灵活且可扩展的后端。
It supports plugins like Firebase, SQLite, and so on (pub.dev will help you find the one you require). Firebase makes the app's infrastructure scalable, serverless, and redundant.
它支持Firebase,SQLite等插件( pub.dev将帮助您找到所需的插件)。 Firebase使该应用程序的基础架构可扩展,无服务器且具有冗余性。
So if you're working on apps that require real-time databases or cloud functions, Flutter's got your back.
因此,如果您在需要实时数据库或云功能的应用程序上工作,Flutter会支持您的。
And the last one: Flutter is very easy to learn.
最后一个:Flutter非常易于学习 。
From the very beginning, Google devs set a goal to lower the entry barrier. They carefully worked out documentation and resources developers can use. It even has special sections you can use to start learning the framework depending on your specialization:
从一开始,Google开发人员就设定了降低准入门槛的目标。 他们仔细地制定了文档和开发人员可以使用的资源。 它甚至包含一些特殊的部分,您可以根据自己的专长来开始学习该框架:
Flutter for Android devs
适用于Android开发人员的Flutter
Flutter for iOS devs
适用于iOS开发人员的Flutter
Flutter for React Native devs
面向React Native开发人员的Flutter
Flutter for Xamarin.Forms devs
Xamarin.Forms开发人员的Flutter
Flutter for web devs
针对Web开发人员的Flutter
Because of Flutter's detailed documentation, you'll figure out how to write code in Dart even if you only have experience with Unity graphic tools for making Android games.
由于Flutter的详细文档,即使您只有使用Unity图形工具制作Android游戏的经验,您仍将弄清楚如何用Dart编写代码。
Flutter 1.12(最新版本)及其特权 (Flutter 1.12 (Latest Version) and Its Perks)
Let's see what hot features Flutter introduced in its latest 1.12 version:
让我们看看Flutter在最新的1.12版本中引入了哪些热门功能:
iOS暗模式 (iOS Dark mode)
From now on, Flutter supports the iOS 13 look and feel, including complete dark mode support in the Cupertino widgets. And it isn’t just about swapping out the background but adapting the rest of the colors to be a good match.
从现在开始,Flutter支持iOS 13外观,包括Cupertino小部件中的完整暗模式支持。 这不仅是换掉背景,还需要调整其余的颜色以使其很好地匹配。
附加到应用程序的支持 (Add-to-app support)
Another big improvement is the Add-to-App update, which is for integrating Flutter into already existing iOS/Android apps.
另一个重大改进是“添加到应用程序”更新,该更新用于将Flutter集成到已经存在的iOS / Android应用程序中。
The new version of Flutter supports adding one fullscreen Flutter instance to the app, along with:
新版本的Flutter支持向应用程序添加一个全屏Flutter实例,以及:
Stabilized APIs integration in Java, Kotlin, Objective-C and Swift
Java,Kotlin,Objective-C和Swift中的稳定API集成
- Support for using plugins in Flutter modules 支持在Flutter模块中使用插件
- Additional integration mechanisms via Android AARs and iOS frameworks 通过Android AAR和iOS框架的其他集成机制
Beta Web支持 (Beta web support)
New Flutter master, dev, and beta channels provide improved support for the web. Want some examples?
Flutter的新的master,dev和beta频道为Web提供了更好的支持。 想要一些例子吗?
Here’s Rivet, an education project that used Flutter and Firebase to create a web version of their app.
这是Rivet ,这是一个教育项目,使用Flutter和Firebase来创建其应用程序的网络版本。
Dart2.7 (Dart 2.7)
The new version of the framework introduces Dart 2.7.
该框架的新版本引入了Dart 2.7。
This update enhances the experience of functioning with Dart 2.5 in how safe strings handles abilities and extension processes. This helps developers prevent errors when variables get a zero value and parse integers in a string.
此更新增强了Dart 2.5在安全字符串处理能力和扩展过程方面的功能体验。 当变量获取零值并解析字符串中的整数时,这有助于开发人员防止错误。
And here are some other features of the latest Flutter version:
以下是最新Flutter版本的其他一些功能:
- macOS desktop support (alpha) macOS桌面支持(alpha)
- multi-device debugging 多设备调试
- golden image testing 黄金图像测试
- Android build improvements Android构建改进
- updated DartPad 更新的DartPad
很好,但并非没有问题:阻碍开发的是什么? (It's Good, But Not Without Problems: What’s Holding Devs Back?)
Flutter is really cool: easy to start, simple to work with, and presented by a huge tech company. Yet here are the reasons why your Senior Developer may not share your optimism.
Flutter真的很酷:易于启动,易于使用,并且由一家大型科技公司提供。 但是,这就是为什么您的高级开发人员可能不会分享您的乐观态度的原因。
Dart的受欢迎程度低 (Dart’s (low) popularity)
Unlike Java/Kotlin for Android or Swift/Objective-C for iOS, Dart doesn't have high popularity yet. And it's highly unlikely it will.
与Android的Java / Kotlin或iOS的Swift / Objective-C不同,Dart尚未普及。 而且极不可能。
Dart isn't too hard to learn, and there are tons of tutorials (like this one), but some devs keep sticking to Java and other familiar tools.
Dart是不是太难学,有吨教程(像这样的一个 ),但有些开发者一直坚持Java和其他熟悉的工具。
At the same time, you can't use Flutter and not use Dart: even Flutter's killer feature – Hot Reload – won't work without Dart.
同时,您不能使用Flutter,也不能使用Dart:即使没有Dart,Flutter的杀手级功能(热重装)也无法使用。
不支持所有设备 (Doesn't support all devices)
You can't make apps for 32-bit iOS devices like those older than iPhone 5s. Same for Windows desktops: you can't run Flutter on your 32-bit laptop.
您无法为32位iOS设备(例如比iPhone 5s早的设备)开发应用。 与Windows台式机相同:您不能在32位笔记本电脑上运行Flutter。
And Flutter devs have no plans on fixing it as "this would involve a very significant amount of work."
Flutter开发人员没有修复它的计划,因为“这将涉及大量工作。”
So if you want to code with Flutter, you'll have to own an x64-bit device or upgrade the one you use now.
因此,如果要使用Flutter进行编码,则必须拥有一台x64位设备或升级您现在使用的设备。
图书馆数量有限 (Limited number of libraries)
Although there are many Flutter libs like fl_chart (for drawing graphics in Flutter), path_provider (used to locate a file on Android/iOS), flutter_sliding_tutorial and many more, the number is still limited.
尽管有很多Flutter库,例如fl_chart (用于在Flutter中绘制图形), path_provider (用于在Android / iOS上定位文件), flutter_sliding_tutorial等,但数量仍然有限。
This isn't hard to explain: Flutter is a relatively new framework, and developers haven't had enough time to develop as many libs as native languages offer.
这不难解释:Flutter是一个相对较新的框架,并且开发人员没有足够的时间来开发本机语言提供的那么多lib。
Still, the most important libraries are already there, and new ones are coming out all the time.
尽管如此,最重要的库已经存在,并且新的库一直在涌现。
Flutter应用的尺寸更大 (Flutter apps are bigger in size)
...compared to native developed applications. Flutter's team measured the minimal app size (with no Material Components, just a single Center widget, built with flutter build apk --split-per-abi), bundled and compressed, to be 4.3 MB for ARM, and 4.6 MB for ARM 64.
...与本机开发的应用程序相比 Flutter的团队测量了最小化的应用程序大小(没有材料组件,只有一个Center小部件,使用flutter build apk --split-per-abi构建),打包并压缩后,对于ARM来说是4.3 MB,对于ARM 64来说是4.6 MB 。
The basic app now is ~4MB in Android and ~10MB in iOS.
现在,基本应用在Android中约为4MB ,在iOS中约为10MB 。
经过验证的专业知识 (Little proven expertise)
Flutter may be loved by developers, but large companies haven't hurried to stop making native (or React Native) apps and turn to Flutter. For most companies, the biggest issue is Flutter's novelty. Dart is newer than Java or C#, and Flutter itself is brand new. Of course, there are many Flutter open-source apps, including big ones like Google Ads or Hamilton (check the full list here), yet not too many.
Flutter可能会受到开发人员的喜爱,但是大型公司并未急于停止制作本机(或React Native)应用程序,而转向Flutter。 对于大多数公司而言,最大的问题是Flutter的新颖性。 Dart比Java或C#更新,Flutter本身是全新的。 当然,有很多Flutter开源应用程序 ,包括Google Ads或Hamilton这类大型应用程序 (请在此处查看完整列表),但数量并不太多。
And no one wants to be the person who adopts a brand new framework only to have to switch to native development a few months later.
没人愿意成为采用全新框架的人,而几个月后就不得不转向本地开发。
But what’s even more important is that Flutter is the path you walk alone:
但是更重要的是,Flutter是您独自行走的道路:
- there aren’t many confirmed best practices (at least at large-scale projects) 确认的最佳做法并不多(至少在大型项目中如此)
- always a chance you're the first one facing this particular problem 您总是有机会成为第一个面临此特定问题的人
- little hope someone will help you out – you'll have to take each step carefully and be ready to face the consequences 几乎没有希望有人能帮助您–您必须认真地采取每一步,并准备好应对后果
在哪里使用Flutter (Where to Use Flutter)
First of all, it's better to use Flutter for MVP startups when you have limited time and often money to verify the business model.
首先,最好在时间有限且经常花钱验证业务模型的情况下,将Flutter用于MVP初创公司。
A Flutter app is cheaper*:
Flutter应用更便宜 *:
- *compared to the cost of two native apps *与两个本机应用程序的成本相比
- the development team is 40% smaller 开发团队小40%
- linear processes 线性过程
- you can spend more time working on the app’s features 您可以花更多时间在应用程序的功能上
By opting for a Flutter project, you’re cutting down the number of development hours. Flutter development doesn't take as much time compared to native.
通过选择Flutter项目,您可以减少开发时间。 与本地开发相比,Flutter开发不需要花费太多时间。
Here’s an example. Let’s say you’re making an Instagram-like app for two platforms. iOS development is going to take, roughly, about 700 hours, Android – also 700h.
这是一个例子。 假设您要为两个平台制作类似Instagram应用。 iOS开发要带,大致,约700小时,Android的-也700H。
With Flutter, you’ll cover both platforms and save time: 700h Android + 700h iOS vs. 700h Flutter.
使用Flutter,您将涵盖两种平台并节省时间: 700h Android + 700h iOS与700h Flutter。
You’re saving tons of time you can spend on something else, like polishing the features.
您可以节省大量时间,可以花在其他方面,例如完善功能。
结语 (Wrapping Up)
If you're building apps in limited time with a limited budget, Flutter is definitely worth trying.
如果您在有限的时间内有限的时间内构建应用程序,那么Flutter绝对值得尝试。
It's just as good as it seems to be, and with each new update, Google devs add more even tools for cross-platform development.
它看起来和现在一样好,并且随着每个新的更新,Google开发人员都会为跨平台开发添加甚至更多的工具。
Of course, this framework may seem unusual for C# and Java lovers, but it does not mean it'll force you out of your comfort zone. Having mastered the small syntax differences, you will soon see that UI development goes a few times faster compared to native development.
当然,对于C#和Java爱好者来说,此框架可能看起来并不常见,但这并不意味着它将迫使您脱离舒适的环境。 掌握了微小的语法差异之后,您很快就会发现UI开发比本地开发快几倍。
And if you're successful, and if Flutter sticks around, it could bring you some exciting mobile development experience and opportunities in the future.
如果您成功了,而且Flutter坚持不懈,那么它将为您带来一些激动人心的移动开发经验和未来的机遇。
翻译自: https://www.freecodecamp.org/news/why-mobile-apps-makers-are-in-love-with-flutter/
flutter开发小程序