Flutter 入門路線圖

本文整理自 Roadmap To Become A Flutter Developer,請參考原文閱讀react

本文是爲那些渴望開始學習 flutter 的人們而準備的,這是一個適合初學者從全部必要資源中逐步學習的路線圖。android

什麼是 flutter

Flutter 是 Google 的 UI 工具包,可經過單個代碼庫爲移動設備,web 和桌面系統構建漂亮的,本機編譯的應用程序。ios

下面兩個視頻很好地介紹了 flutter;git

Introducing Flutter1github

What's new in Flutter 20192web

[1] https://youtu.be/fq4N0hgOWzU
[2] https://youtu.be/5VbAwhBBHsg sql

爲何是 flutter?

咱們已經知道有不少框架能夠提供跨平臺功能,那麼在這場激烈競爭中,是什麼讓 flutter 顯得特別呢?數據庫

快速開發

Flutter 的熱加載功能可幫助您快速輕鬆地進行實驗,構建用戶界面,添加功能並更快地修復錯誤。在 iOS 和 Android 的模擬器和硬件上體驗亞秒級的從新加載時間,而不會丟失狀態。json

富有表現力的精美用戶界面

Flutter 內置的精美 Material Design 和 Cupertino(iOS-flavor)小部件,豐富的運動 API,流暢的天然滾動以及對平臺的瞭解,可爲您的用戶帶來更多驚喜。react-native

native 級別的性能

Flutter 的小部件結合了全部重要的平臺差別,例如滾動,導航,圖標和字體,以在 iOS 和 Android 上提供完整的 native 性能。

查看 Flutter 的功能

如下是全球開發人員構建的 Flutter 應用程序的展現。

Apps take flight with Flutter3

An open list of apps built with Flutter4

Flutter Awesome5

Start Flutter | Forever free, open source, and easy to use.6

[3]https://flutter.dev/showcase
[4]https://itsallwidgets.com/
[5]https://flutterawesome.com/
[6]https://startflutter.com/

首先要作什麼?

Flutter 既快速又容易,若是您熟悉 Java 或任何面向對象的語言,那麼很不錯,可是我強烈建議您具有 Dart 的基本知識。

如下是一些可能對您有所幫助的視頻。

Dart Programming for Flutter7

Dart Programming Tutorial - Full Course8

Introduction to Dart for Beginners9

Dart: Basics of Dart Part - 1/2 | Flutter10

[7]https://youtu.be/5rtujDjt50I?list=PLlxmoA0rQ-LyHW9voBdNo4gEEIh0SjG-q
[8]https://youtu.be/Ej_Pcr4uC2Q
[9]https://youtu.be/8F2uemqLwvE?list=PLJbE2Yu2zumDjfrfu8kisK9lQVcpMDDzZ
[10]https://youtu.be/DFRl4UyS7c8?list=PLR2qQy0Zxs_W4a6P70VYtzna7jwl3-lxI

對於那些不喜歡看視頻的人,能夠查看如下站點

Tutorials11

Dart Programming Tutorial12

Learn Dart In A Week With These Free Resources13

[11]https://dart.dev/tutorials
[12]https://www.tutorialspoint.com/dart_programming/index.htm
[13]https://hackernoon.com/learn-dart-in-a-week-with-these-free-resources-b892e5265220

是什麼使 Dart 如此典型,爲何 flutter 會使用它?

爲何 Flutter 使用 Dart?

能夠查看如下文章和視頻

Why Flutter Uses Dart?14

視頻:Why Flutter Uses Dart?15

[14]https://hackernoon.com/why-flutter-uses-dart-dd635a054ebf
[15]https://youtu.be/5F-6n_2XWR8

Flutter 底層是如何工做的?

因爲 iOS 不容許動態編譯,所以您的 Dart 代碼會使用 AOT 直接編譯爲本地代碼。

要了解更多信息,請在下面查看這些資源:

Technical overview16

How to Dart and Flutter Work Together?17

What's Revolutionary about Flutter18

How Flutter reners Widgets19

How is Flutter different for app development20

[16]https://flutter.dev/docs/resources/technical-overview
[17]https://youtu.be/iVYpeEd3Jes
[18]https://hackernoon.com/whats-revolutionary-about-flutter-946915b09514
[19]https://youtu.be/996ZgFRENMs
[20]https://youtu.be/l-YO9CmaSUM

Flutter快速且易於使用,如今讓咱們看看如何安裝它。

如何安裝Flutter?

這是開發人員文檔的連接,您能夠在其中找到在現有的操做系統中安裝Flutter。

Install21

[21]https://flutter.dev/docs/get-started/install

解決安裝過程當中的問題

若是您在安裝 flutter 時遇到任何問題,而且 flutter 沒法正常工做,那麼這就是出現了一些問題。

設置 flutter 路徑時遇到麻煩-找不到flutter命令22

Flutter Doctor沒法識別Android Studio flutter和dart插件,但已安裝插件23

Flutter和Dart插件未在Flutter Doctor中安裝警告24

安裝 flutter 時的一些常見問題。25

[22]https://stackoverflow.com/questions/49268297/having-trouble-setting-flutter-path-flutter-commands-not-found
[23]https://github.com/flutter/flutter/issues/21881
[24]https://github.com/flutter/flutter/issues/11940
[25]https://github.com/flutter/flutter/wiki/Workarounds-for-common-issues

設置Flutter的編輯器

Set up an editor26

[26]https://flutter.dev/docs/get-started/editor

建立您的Flutter項目

經過如下命令建立 flutter 項目

flutter create <project-name>
複製代碼

或者您能夠使用IDE(Intellij,Android Studio等)

項目概況

當您建立 flutter 應用程序時,您會看到這些文件和文件夾,大多數代碼是用 dart 編寫在 lib 文件夾中,native 代碼放在 android 和 ios 目錄下。

Jay Tillu的一篇文章解釋了該項目的結構。

Flutter Project Structure27

[27]https://dev.to/jay_tillu/flutter-project-structure-1lhe

運行你的第一個 App

Test drive28

或者你能夠使用如下命令來運行您的第一個應用程序

flutter run
複製代碼

當您啓動第一個應用程序時,必定會感到很興奮(從技術上說,這不是您的應用程序,代碼已經在那裏😜)。 我也很興奮🎉。

建立flutter應用程序時,您會看到計數器應用程序已經有代碼了。

運行代碼時,您將看到此信息。這是一個簡單的計數器應用程序,其中有一個FAB(FloatingActionButton)和 Text 來指示已按下 FAB 多少次。

[28]https://flutter.dev/docs/get-started/test-drive

flutter 中的 widget

若是看到代碼,您將看到 StatefulWidget 和 StatelessWidget。在深刻探討以前,咱們先來了解一下什麼是 Widget。

Introduction to widget29

基本上,在 flutter 應用程序中看到的全部內容都是一個小部件。

我發現 What is a Widget in Flutter30 一文中的解釋很是準確

Flutter小組還提供了一個YouTube播放列表(Widget of the week31),該列表僅討論flutter中的Widget。

[29]https://flutter.dev/docs/development/ui/widgets-intro
[30]https://stackoverflow.com/questions/50958238/what-is-a-widget-in-flutter
[31]https://youtu.be/b_sQ9bMltGU?list=PLjxrf2q8roU23XGwz3Km7sQZFTdB996iG

什麼是有狀態和無狀態小部件?

在 Stateless Widget 中,其全部屬性都是不可變的,這意味着 StatelessWidget 永遠不會自行重建(但能夠從外部事件重建),而 StatefulWidget 能夠。

Intro to Flutter - Stateful and Stateless Widgets, Widget Tree - Part One32

Flutter: Stateful vs Stateless Widget33

How to Create Stateless Widgets - Flutter Widgets 101 Ep. 134

How Stateful Widgets Are Used Best - Flutter Widgets 101 Ep. 235

Google's Flutter Tutorials | 6 - Stateless & Stateful Widgets | Android & iOS | Dart36

[32]https://youtu.be/-QRQIKtPTlI
[33]https://medium.com/flutter-community/flutter-stateful-vs-stateless-db325309deae
[34]https://www.youtube.com/watch?v=wE7khGHVkYY&feature=emb_title
[35]https://www.youtube.com/watch?v=AqCMFXEmf3w&feature=emb_title
[36]https://www.youtube.com/watch?list=PLR2qQy0Zxs_UdqAcaipPR3CG1Ly57UlhV&v=VnWHOogtDk8&feature=emb_title

讓咱們建立第一個Flutter應用

Google已經提供了一個 Codelab,您能夠從那裏開始學習如何構建本身的第一個 Flutter 應用程序。

Write Your First Flutter App, part 137

Write Your First Flutter App, part 238

Flutter Tutorial Part 1: Build a Flutter app from scratch39

1.3 Flutter Hello World Tutorial: Create First Flutter Application: Flutter Dart Tutorial40

1.4 First Flutter Application using Dart: PART-2 Flutter Tutorial for Beginners using Dart41

[37]https://codelabs.developers.google.com/codelabs/first-flutter-app-pt1/#4
[38]https://codelabs.developers.google.com/codelabs/first-flutter-app-pt2/#0
[39]https://medium.com/aviabird/flutter-tutorial-how-to-build-an-app-from-scratch-b88d4e0e10d7
[40]https://www.youtube.com/watch?list=PLlxmoA0rQ-Lw6tAs2fGFuXGP13-dWdKsB&v=dsyucuytW2k
[41]https://www.youtube.com/watch?list=PLlxmoA0rQ-Lw6tAs2fGFuXGP13-dWdKsB&v=ycHX8QtV08c

如何在 Flutter 中建立 UI?

爲了使 UI 更加流暢,您須要基本瞭解佈局以及如何使用它們。

Layouts in Flutter42

Flutter layout Cheat Sheet43

[42]https://flutter.dev/docs/development/ui/layout
[43]https://medium.com/flutter-community/flutter-layout-cheat-sheet-5363348d037e

如何在您的應用中添加交互?

在 flutter 中,您不能只是分配一個值並留下它

例如

String value="Hello";
------------------------------
Text(value);
---SOMEWHERE IN THE CODE------
onTap(){
value="How are you?";
}
複製代碼

若是您認爲文本將要更改,那麼您錯了🙅‍♂️,您將不得不使用 setState()。

onTap(){
	setState({
		value="How are you?";
	});
}
複製代碼

添加 setState() 將重建小部件並顯示更改。

Adding interactivity to your Flutter app44

我建議您跟進有關開發的 Flutter 官方文檔

Development45

flutter 中的全部內容都是小部件,您能夠自行建立任何自定義小部件,可是已經有經過 flutter 定義的小部件。

Widget catalog46

[44]https://flutter.dev/docs/development/ui/interactive
[45]https://flutter.dev/docs/development
[46]https://flutter.dev/docs/development/ui/widgets

Flutter 中的 JSON 解析

JSON and serialization47

Parsing JSON in Flutter48

Parsing complex JSON in Flutter49

Working with APIs in Flutter50

Handling Network Calls like a Pro in Flutter51

Flutter - Build An App To Fetch Data Online Using HTTP GET | Android & iOS52

Testing, JSON serialization, and immutables (The Boring Flutter Development Show, Ep. 2)53

[47]https://flutter.dev/docs/development/data-and-backend/json
[48]https://medium.com/flutterdevs/parsing-complex-json-in-flutter-b7f991611d3e
[49]https://medium.com/flutter-community/parsing-complex-json-in-flutter-747c46655f51
[50]https://medium.com/flutter-community/working-with-apis-in-flutter-8745968103e9
[51]https://medium.com/flutter-community/handling-network-calls-like-a-pro-in-flutter-31bd30c86be1
[52]https://www.youtube.com/watch?list=PLR2qQy0Zxs_UdqAcaipPR3CG1Ly57UlhV&v=aIJU68Phi1w
[53]https://www.youtube.com/watch?v=TiCA0CEePyE

在 Flutter 中使用數據庫

SQLite

Persist data with SQLite54

Data Persistence with SQLite | Flutter55

4.1 Flutter SQFLite Database Tutorial: Implement SQLite database with example: Section Overview56

Moor (Room for Flutter) #1 – Tables & Queries – Fluent SQLite Database57

[54]https://flutter.dev/docs/cookbook/persistence/sqlite
[55]https://medium.com/flutterdevs/data-persistence-with-sqlite-flutter-47a6f67b973f
[56]https://www.youtube.com/watch?list=PLDQl6gZtjvFu5l20K5KTEBLCjfRjHowLj&v=1BwjNEKD8g8
[57]https://www.youtube.com/watch?v=zpWsedYMczM

SharedPreferences

Shared preferences plugin58

Using SharedPreferences in Flutter59

Store key-value data on disk60

Making use of Shared Preferences, Flex Widgets and Dismissibles with Dart's Flutter framework61

[58]https://pub.dev/packages/shared_preferences
[59]https://medium.com/flutterdevs/using-sharedpreferences-in-flutter-251755f07127
[60]https://flutter.dev/docs/cookbook/persistence/key-value
[61]https://www.youtube.com/watch?v=IvrAAMQnj4k

使用Firebase

將 Firebase 添加到您的 Flutter 應用62

Firebase for Flutter63

Flutter - Firestore introduction64

[62]https://firebase.google.com/docs/flutter/setup
[63]https://codelabs.developers.google.com/codelabs/flutter-firebase/#0
[64]https://www.youtube.com/watch?list=PLgGjX33Qsw-Ha_8ks9im86sLIihimuYrr&v=LzEbpALmRlc

其餘學習 Flutter 的資源

如下是其餘開發人員和Flutter團隊提供的一些資源:

Technical overview65

Resources to learn Flutter66

Free resources to learn and advance in Flutter67

Flutter Community68

My Favourite List of Flutter Resources69

awesome-flutter70

londonappbrewery/Flutter-Course-Resources71

A Searchable List of Flutter Resources72

FlutterDevs73

[65]https://flutter.dev/docs/resources/technical-overview
[66]https://medium.com/flutter-community/resources-to-learn-flutter-2ade7aa73305
[67]https://medium.com/flutter-community/free-resources-to-learn-and-advance-in-flutter-e07875ffc825
[68]https://medium.com/flutter-community
[69]https://medium.com/coding-with-flutter/my-favourite-list-of-flutter-resources-523adc611cbe
[70]https://github.com/Solido/awesome-flutter
[71]https://github.com/londonappbrewery/Flutter-Course-Resources
[72]https://flutterx.com/
[73]https://medium.com/flutterdevs

關於 Flutter 的問題

FAQ74

Answering Questions on Flutter App Development75

Flutter Vs. React Native: FAQs for Every Developer76

[74]https://flutter.dev/docs/resources/faq
[75]https://medium.com/@dev.n/answering-questions-on-flutter-app-development-6d50eb7223f3
[76]https://hackernoon.com/flutter-vs-react-native-faqs-for-every-developer-yjp329z

本文僅適用於初學者。

相關文章
相關標籤/搜索