flutter开发小程序

I dabbled a bit in Android and iOS development quite a few years back using Java and Objective-C. After spending about a month working with both of them, I decided to move on. I just couldn’t get into it.

几年前,我使用Java和Objective-C涉足Android和iOS开发。 与他们两个人花了大约一个月的时间后,我决定继续前进。 我只是无法进入。

But recently, I learned about Flutter and decided to give mobile app development another shot. I instantly fell in love with it as it made developing multi-platform apps a ton of fun. Since learning about it, I’ve created an app and a library using it. Flutter seems to be a very promising step forward and I’d like to explain a few different reasons why I believe this.

但是最近,我了解了Flutter,并决定再次开发移动应用程序。 我立即爱上了它,因为它使开发多平台应用程序变得非常有趣。 自了解以来,我已经创建了一个应用程序和一个使用它的库。 Flutter似乎是向前迈出的非常有希望的一步,我想解释一些我为什么相信这一点的原因。

由Dart提供支持 (Powered by Dart)

Flutter uses the Google-developed Dart language. If you’ve used Java before, you’ll be fairly familiar with the syntax of Dart as they are quite similar. Besides the syntax, Dart is a fairly different language.

Flutter使用Google开发的Dart语言。 如果您以前使用过Java,则您将非常熟悉Dart的语法,因为它们非常相似。 除了语法之外,Dart是一种完全不同的语言。

I’m not going to be talking about Dart in depth as it’s a bit out of scope, but I’d like to discuss one of the most helpful features in my opinion. This feature being support for asynchronous operations. Not only does Dart support it, but it makes it exceptionally easy.

我不会深入讨论Dart,因为它有点超出范围,但我想讨论一下我认为最有用的功能之一。 此功能支持异步操作。 Dart不仅支持它,而且使其异常容易。

This is something you’ll most likely be using throughout all of your Flutter applications if you’re doing IO or other time-consuming operations such as querying a database. Without asynchronous operations, any time-consuming operations will cause the program to freeze up until they complete. To prevent this, Dart provides us with the async and await keywords which allow our program to continue execution while waiting for these longer operations to complete.

如果您正在执行IO或其他耗时的操作(例如查询数据库),则很可能会在所有Flutter应用程序中使用此功能。 如果没有异步操作,任何耗时的操作都会导致程序冻结,直到完成为止。 为防止这种情况,Dart为我们提供了asyncawait关键字,这些关键字使我们的程序可以在等待这些较长的操作完成时继续执行。

Let's take a look at a couple of examples: one without asynchronous operations and one with.

让我们看几个例子:一个没有异步操作,一个有异步操作。

And the output:

并输出:

This isn’t ideal. No one wants to use an app that freezes up when it executes long operations. So let’s modify this a bit and make use of the async and await keywords.

这不理想。 没有人愿意使用在执行长时间操作时冻结的应用程序。 因此,让我们对其进行一些修改,并使用asyncawait关键字。

And the output once again:

并再次输出:

Thanks to asynchronous operations, we’re able to execute code that takes a while to complete without blocking the execution of the rest of our code.

由于异步操作,我们能够执行需要一段时间才能完成的代码,而不会阻塞其余代码的执行。

编写一次,在Android和iOS上运行 (Write Once, Run on Android and iOS)

Developing mobile apps can take a lot of time considering you need to use a different codebase for Android and iOS. That is unless you use an SDK like Flutter, where you have a single codebase that allows you to build your app for both operating systems. Not only that, but you can run them completely natively. This means things such as scrolling and navigation, to name a few, act just like they should for the OS being used.

考虑到您需要为Android和iOS使用不同的代码库,开发移动应用程序可能会花费很多时间。 除非您使用Flutter之类的SDK,否则您只有一个代码库,可以为两个操作系统构建应用程序。 不仅如此,您还可以在本地完全运行它们。 这意味着诸如滚动和导航之类的功能,就像它们对于所使用的操作系统一样。

To keep with the theme of simplicity, as long as you have a device or simulator running, Flutter makes building and running your app for testing as simple as clicking a button.

为了保持简单性这一主题,只要您运行的设备或模拟器,Flutter都可以使创建和运行应用程序的过程像单击按钮一样简单。

UI开发 (UI Development)

UI development is one of those things that I almost never look forward to. I’m more of a backend developer, so when it comes to working on something that is heavily dependent on it, I want something simple. This is where Flutter shines in my eyes.

UI开发是我几乎从未期待过的事情之一。 我更多地是后端开发人员,因此,在处理高度依赖它的东西时,我想要简单的东西。 这是Flutter在我眼中闪耀的地方。

UI is created by combining different widgets together and modifying them to fit the look of your app. You have near full control over how these widgets display, so you’ll always end up with exactly what you’re looking for. For laying out the UI, you have widgets such as Row, Column, and Container. For content, you have widgets like Text and RaisedButton. This is only a few of the widgets Flutter offers, there are a lot more. Using these widgets, we can build a very simple UI:

通过将不同的小部件组合在一起并对其进行修改以适合您的应用程序外观来创建UI。 您几乎完全可以控制这些小部件的显示方式,因此始终可以得到所需的确切信息。 为了布置UI,您需要使用小部件,例如RowColumnContainer 。 对于内容,您具有诸如TextRaisedButton类的小部件。 这只是Flutter提供的小部件中的几个,还有更多。 使用这些小部件,我们可以构建一个非常简单的UI:

Flutter has more tricks up its sleeve that makes theming your app a breeze. You could go through and manually change the fonts, colors, and looks for everything one by one, but that takes way too long. Instead, Flutter provides us with something called ThemeData that allows us to set values for colors, fonts, input fields, and much more. This feature is great for keeping the look of your app consistent.

Flutter袖手旁观,可轻松设置主题主题。 您可以手动更改字体,颜色,然后逐一查找所有内容,但这花费的时间太长。 相反,Flutter为我们提供了一个名为ThemeData东西,它允许我们设置颜色,字体,输入字段等的值。 此功能非常适合使您的应用程序外观保持一致。

With this ThemeData, we set the apps colors, font family, and some text styles. Everything besides the text styles will automatically be applied app-wide. Text styles have to be set manually for each text widget, but it's still simple:

通过此ThemeData ,我们可以设置应用程序的颜色,字体系列和某些文本样式。 除文本样式外,所有内容都会自动在整个应用范围内应用。 必须为每个文本小部件手动设置文本样式,但这仍然很简单:

To make things even more efficient, Flutter can hot reload apps so you don’t need to restart it every time you make a change to the UI. You can now make a change, save it, then see the change within a second or so.

为了使事情变得更加高效,Flutter可以热重载应用程序,因此您无需在每次更改UI时都重新启动它。 现在,您可以进行更改,将其保存,然后在一秒钟左右的时间内看到更改。

图书馆 (Libraries)

Flutter provides a lot of great features out of the box, but there are times when you need a bit more than it offers. This is no problem at all considering the extensive number of libraries available for Dart and Flutter. Interested in putting ads in your app? There’s a library for that. Want new widgets? There are libraries for that.

Flutter开箱即用地提供了许多很棒的功能,但是有时候您需要的东西比它所提供的更多。 考虑到Dart和Flutter可用的大量库,这根本没有问题。 有兴趣在您的应用中投放广告吗? 有一个图书馆。 需要新的小部件吗? 有图书馆。

If you’re more of a do-it-yourselfer, make your own library and share it with the rest of the community in no time at all. Adding libraries to your project is simple and can be done by adding a single line to your pubspec.yaml file. For example, if you wanted to add the sqflite library:

如果您更喜欢自己动手做,请创建自己的图书馆,并立即与社区其他成员共享。 将库添加到项目很简单,可以通过在pubspec.yaml文件中添加一行来完成。 例如,如果要添加sqflite库:

After adding it to the file, run flutter packages get and you're good to go. Libraries make developing Flutter apps a breeze and save a lot of time during development.

将其添加到文件中后,运行flutter packages get ,您就可以开始了。 库使开发Flutter应用程序变得轻而易举,并在开发过程中节省了大量时间。

后端开发 (Backend Development)

Most apps nowadays depend on some sort of data, and that data needs to be stored somewhere so it can be displayed and worked with later on. So keeping this in mind when looking to create apps with a new SDK, such as Flutter, is important.

如今,大多数应用程序都依赖某种数据,这些数据需要存储在某个地方,以便以后显示和使用。 因此,在使用新的SDK(例如Flutter)创建应用程序时,请记住这一点,这一点很重要。

Once again, Flutter apps are made using Dart, and Dart is great when it comes to backend development. I’ve talked a lot about simplicity in this article, and backend development with Dart and Flutter is no exception to this. It’s incredibly simple to create data-driven apps, for beginners and experts alike, but this simplicity by no means equates to a lack of quality.

再说一次,Flutter应用程序是使用Dart制作的,Dart在后端开发方面很棒。 在本文中,我已经讨论了很多关于简单性的问题,使用Dart和Flutter进行后端开发也不例外。 对于初学者和专家而言,创建数据驱动的应用程序非常简单,但是这种简单性绝不等于缺乏质量。

To tie this in with the previous section, libraries are available so you can work with the database of your choosing. Using the sqflite library, we can be up and running with an SQLite database fairly quickly. And thanks to singletons, we can access the database and query it from practically anywhere without needing to recreate an object every single time.

要将其与上一节联系在一起,可以使用库,因此您可以使用自己选择的数据库。 使用sqflite库,我们可以相当快地启动并运行SQLite数据库。 而且由于有了单例,我们几乎可以在任何地方访问数据库并查询它,而无需每次都重新创建对象。

After retrieving data from a database, you can convert that to an object using a model. Or if you want to store an object in the database, you can convert it to JSON using the same model.

从数据库检索数据后,可以使用模型将其转换为对象。 或者,如果要将对象存储在数据库中,则可以使用相同的模型将其转换为JSON。

This data isn’t all that useful without a way to display it to the user. This is where Flutter comes in with widgets such as the FutureBuilder or StreamBuilder. If you're interested in a more in-depth look at creating data-driven apps using Flutter, SQLite, and other technologies, I encourage you to check out the article I wrote on that:

如果没有将数据显示给用户的方式,这些数据并不是那么有用。 这是Flutter附带诸如FutureBuilderStreamBuilder小部件的StreamBuilder 。 如果您想更深入地了解如何使用Flutter,SQLite和其他技术创建数据驱动的应用程序,建议您阅读我写的文章:

Using Streams, BLoCs, and SQLite in FlutterStreams, BLoCs, and SQLite make for a great combination when it comes to working with data in your Flutter…

在Flutter中使用Streams,BLoC和SQLite在Flutter中处理数据时, Streams,BLoC和SQLite可以很好地结合在一起。

最后的想法 (Final Thoughts)

With Flutter, the possibilities are practically endless, so even super extensive apps can be created with ease. If you develop mobile apps and have yet to give Flutter a try, I highly recommend you do as I’m sure you’ll fall in love with it as well. After using Flutter for quite a few months, I think it’s safe to say that it’s the future of mobile development. If not, it’s definitely a step in the right direction.

使用Flutter,可能性几乎是无限的,因此甚至可以轻松创建超级扩展的应用程序。 如果您开发移动应用程序并且还没有尝试Flutter,我强烈建议您这样做,因为我相信您也会爱上它。 在使用Flutter几个月后,我可以肯定地说这是移动开发的未来。 如果没有,那绝对是朝正确方向迈出的一步。

翻译自: https://www.freecodecamp.org/news/why-i-think-flutter-is-the-future-of-mobile-app-development-768332b73c0d/

flutter开发小程序

flutter开发小程序_为什么我认为Flutter是移动应用程序开发的未来相关推荐

  1. 构建meteor应用程序_我构建了一个渐进式Web应用程序并将其发布在3个应用程序商店中。 这是我学到的。...

    构建meteor应用程序 by JudahGabriel Himango 犹大(Gabriel Himango) 我构建了一个渐进式Web应用程序并将其发布在3个应用程序商店中. 这是我学到的. (I ...

  2. linux上开发应用程序_如何在Linux上安装软件应用程序

    linux上开发应用程序 如何在Linux上安装应用程序? 与许多操作系统一样,该问题不仅有一个答案. 应用程序可以来自许多来源-几乎无法计数-每个开发团队都可以以自己认为最佳的方式交付软件. 知道如 ...

  3. flutter release 版本 调试_腾讯课堂Flutter工程实践系列——接入篇

    前言 课堂目前的技术栈是React Native + Hybird + Native,随着技术的演进多端融合的趋势越来越明显,而RN的弊端也突显出来,jsBridge性能不是最优,占用前端人力,定位问 ...

  4. Java客户端开发是什么_客户端桌面应用一般是用什么技术开发的?

    JAVA GUI 觉得java是最好学的语言.也是像我这种非科班出生的,踏入码农行业的敲门砖(看C c++ 学了一年,也就hello word,会写几个demo界面). Windows桌面应用程序开发 ...

  5. 我的python程序_我试着运行我的python程序,但当我运行它时什么也没有发生

    我在运行我用python编写的交互式小故事时遇到了问题.我总是遇到一些非ASCII错误,或者是一些不允许我运行程序的错误.在 如果你想试试这个程序:Program 我的代码是:#Programmer: ...

  6. python安装与程序_二、Python安装和第一个程序

    <1.Python语言介绍 1.官方介绍:Python 是一款易于学习且功能强大的编程语言. 它具有高效率的数据结构,能够简单又有效地实现面向对象编程.Python 简洁的语法与动态输入之特性, ...

  7. vscode重置应用程序_如何在Windows 10上重置应用程序的数据

    vscode重置应用程序 With Windows 10's Anniversary Update, you can now reset an app's data without actually ...

  8. [转载] flutter开发桌面程序_在开始使用Flutter开发应用程序之前要了解的5条提示

    参考链接: Python中的桌面通知程序 flutter开发桌面程序 1.始终取消您的流订阅: (1. Always cancel your stream subscription:) When I ...

  9. android开发小项目实例_微信小程序开发的实例教程

    一.注册小程序帐户 1.进入微信公众平台,注册一个小程序帐号,并根据提示填写相应的信息. 2.成功注册后,进入主页,然后在小程序发布过程->小程序开发和管理->配置服务器中单击" ...

最新文章

  1. linux 下camera调试笔记【转】
  2. Learning by doing 系列文章(之一)如何在 Python 中使用 epoll ?
  3. 关于i++和++i的实验结果解释
  4. 天胶指数发布 对话国际农民丰收节贸易会海垦集团走出去
  5. spring ioc的包的扫描(基于注解)
  6. 火山小视频尼尔森:2019新线消费市场人群洞察报告(附下载)
  7. Keras 深度学习框架中文文档
  8. 阿里开源支持10万亿模型的自研分布式训练框架EPL(EasyParallelLibrary)
  9. stl向量_如何在C ++ STL中将数组元素复制到向量?
  10. centos php mcrypt_Centos 建议使用epel源
  11. 韩顺平php视频笔记47 函数使用
  12. git删除中间某个commit
  13. Gym102028G Shortest Paths on Random Forests 生成函数、多项式Exp
  14. D - 昂贵的聘礼(最短路径)
  15. html页面添加视频背景设置为自动播放,打开网址就会自动播放,简单有效亲测
  16. 获取css style值
  17. iOS 友盟分享总结
  18. 【爬虫】用Python爬取《Nature》杂志文章的题目、摘要、下载地址
  19. linux查询进程命令stap,linux systemtap, stap++使用
  20. linux挂载硬盘提示我格式化,linux中磁盘格式化挂载使用

热门文章

  1. 详解AFNetworking的HTTPS模块
  2. uni-app 封装企业微信config
  3. 突破微信小程序五层层级限制的解决方案
  4. 微信小程序让屏幕自动向下滚动
  5. Codeforces Educational round 58
  6. Console-算法-冒泡排序法|倒水法
  7. 2017SDN市场一片繁荣,全球企业纷纷“亮剑“
  8. centos安装easy_instal
  9. POJ 2135 Farm Tour 最小费用流
  10. poj(2325)线段树