You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: manuscript/chapter_1.1.md
+37-37
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ In this section, I'll explain the evolution of mobile development technologies.
8
8
9
9
Native development refers to the mobile application development using development tools, SDKs, and languages supported by a particular operating system such as iOS or Android. For example, a native Android app refers to an application developed by using Java or Kotlin using the Android SDK directly; while a native iOS app refers to an application developed by directly using the iOS SDK using languages like Objective-C or Swift.
10
10
11
-
Advantages of Native Development:
11
+
Advantages of Native Development:
12
12
13
13
- Access to all features of the platform (GPS,Camera,Microphone).
14
14
- Flawless performance.
@@ -23,7 +23,7 @@ Disadvantages of Native Development:
23
23
24
24
In the early days of mobile development, app development for businesses was not complicated, and native development could cope with product demand iterations. However, in recent years, with the advent of the Internet of Things and the rapid advancement of the Internet, in many business scenarios, traditional pure native development can no longer meet the growing needs of businesses.
25
25
26
-
Mainly manifested in:
26
+
Mainly manifested in:
27
27
28
28
- As the demand for dynamic content surges, when the demand changes, native applications need to update the app through version updates which involve pushing updated build to the play store or app store and going through all the review and release process. Which is difficult to deal with in this fast-changing Internet era. So the necessity of dynamic application updates (application content can be updated without publishing a version) becomes crucial.
29
29
- Business requirement changes rapidly, and development cost becomes lofty. As native development requires maintaining two codebases and two development teams for Android and iOS, when the app is updated then both the labor cost and development time increases..
@@ -57,40 +57,40 @@ As mentioned earlier, native development can access all the functions of the pla
57
57
Let's take Android as an example to implement a native API for obtaining the phone model for JavaScript calls. In this example, the process of calling native API by JavaScript will be shown. Readers can intuitively experience the process of calling. We use the wendux's open source dsBridge on Github as JsBridge for communication. dsBridge is a cross-platform JsBridge that supports synchronous calling. In this example, only the synchronous calling function is used.
58
58
59
59
1. First implement the API to get the phone model in the native `getPhoneModel`
60
-
61
-
```
62
-
class JSAPI {
63
-
@JavascriptInterface
64
-
public Object getPhoneModel(Object msg) {
65
-
return Build.MODEL;
66
-
}
60
+
61
+
```dart
62
+
class JSAPI {
63
+
@JavascriptInterface
64
+
public Object getPhoneModel(Object msg) {
65
+
return Build.MODEL;
67
66
}
68
-
69
-
```
70
-
67
+
}
68
+
69
+
```
70
+
71
71
2. Register native API to JsBridge through WebView
72
-
73
-
```
74
-
import wendu.dsbridge.DWebView
75
-
...
76
-
//DWebView inherits from WebView, provided by dsBridge
The above example demonstrates the process of JavaScript calling native API. Similarly, in general, the excellent JsBridge also supports native calling JavaScript, and dsBridge also supports it. If you are interested, you can go to the github dsBridge project homepage to view.
96
96
@@ -170,12 +170,12 @@ Disadvantages:
170
170
171
171
In this article, we look at the last cross-platform technology: self-painted UI + native. The idea of this technology is to draw the UI by implementing a unified interface rendering engine on different platforms without relying on the system's native controls, so the consistency of the UI on different platforms can be achieved. Note that the self-drawing engine solves the cross-platform problem of the UI. If it involves calling other system capabilities, it still involves native development.
172
172
173
-
The advantages of this platform technology are as follows:
173
+
The advantages of this platform technology are as follows:
174
174
175
175
1. High performance; since the self-drawing engine directly calls the system API to draw the UI, the performance is close to that of native controls.
176
-
176
+
177
177
2. Flexible, easy to maintain the component library, high fidelity and consistency of UI appearance; since UI rendering does not rely on native controls, there is no need to maintain a set of component libraries separately for controls of different platforms, so the code is easy to maintain. Since the component library is the same set of code and the same rendering engine, the display appearance of the component can achieve high fidelity and high consistency on different platforms; in addition, because it does not rely on native controls, it will not be restricted by the native layout system. This layout system will be very flexible.
178
-
178
+
179
179
180
180
Disadvantages:
181
181
@@ -194,7 +194,7 @@ Main resons behing QT's Failure :
194
194
- The official promotion is not good and the support is not enough.
195
195
- QT was late as the market has been occupied by other dynamic frameworks (Hybrid and RN)
196
196
- In mobile development, C++ development has inherent disadvantages compared to Web development stacks, and the direct result is that QT development efficiency is too low.
197
-
197
+
198
198
199
199
Based on these four points, although QT is a pioneer in the development of cross-platform self-drawing engines on mobile, it has become a martyr.
Copy file name to clipboardExpand all lines: manuscript/chapter_1.2.md
+23-23
Original file line number
Diff line number
Diff line change
@@ -25,29 +25,29 @@ Currently, there are two main ways to run programs: compiling and interpreting c
25
25
Now let's see why Flutter chooses Dart language? The author summarizes the following points based on the official explanation and my own understanding of Flutter (because other cross-platform frameworks use JavaScript as their development language, we mainly compare Dart and JavaScript):
26
26
27
27
1.**High Development Efficiency**
28
-
29
-
The Dart runtime and compiler support a combination of two key features of Flutter:
30
-
31
-
**JIT-based rapid development cycle** : Flutter adopts the JIT mode in the development phase, which avoids the need to compile every change and greatly saves development time;
32
-
33
-
**AOT-based release package** : Flutter can generate efficient ARM code through AOT during release to ensure application performance. JavaScript does not have this capability.
34
-
28
+
29
+
The Dart runtime and compiler support a combination of two key features of Flutter:
30
+
31
+
**JIT-based rapid development cycle** : Flutter adopts the JIT mode in the development phase, which avoids the need to compile every change and greatly saves development time;
32
+
33
+
**AOT-based release package** : Flutter can generate efficient ARM code through AOT during release to ensure application performance. JavaScript does not have this capability.
34
+
35
35
2.**High Performance**
36
-
37
-
Flutter aims to provide a smooth, high-fidelity UI experience. In order to achieve this, Flutter needs to be able to run a large amount of code in each animation frame. This means that a language that can provide high performance without periodic pauses that will drop frames is needed. Dart supports AOT, which can do better than JavaScript at this point.
38
-
36
+
37
+
Flutter aims to provide a smooth, high-fidelity UI experience. In order to achieve this, Flutter needs to be able to run a large amount of code in each animation frame. This means that a language that can provide high performance without periodic pauses that will drop frames is needed. Dart supports AOT, which can do better than JavaScript at this point.
38
+
39
39
3.**Fast Memory Allocation**
40
-
41
-
The Flutter framework uses functional streams, which makes it largely dependent on the underlying memory allocator. Therefore, it is very important to have a memory allocator that can effectively handle trivial tasks. Flutter will not work effectively in languages lacking this feature. Of course, the JavaScript engine of Chrome V8 has also done a good job in memory allocation. In fact, many members of the Dart development team are from the Chrome team, so Dart cannot be used as an advantage over JavaScript in memory allocation, but for Flutter Say, it needs such features, and Dart just meets it.
42
-
40
+
41
+
The Flutter framework uses functional streams, which makes it largely dependent on the underlying memory allocator. Therefore, it is very important to have a memory allocator that can effectively handle trivial tasks. Flutter will not work effectively in languages lacking this feature. Of course, the JavaScript engine of Chrome V8 has also done a good job in memory allocation. In fact, many members of the Dart development team are from the Chrome team, so Dart cannot be used as an advantage over JavaScript in memory allocation, but for Flutter Say, it needs such features, and Dart just meets it.
42
+
43
43
4.**Type Safety**
44
-
45
-
Since Dart is a type-safe language and supports static type detection, some types of errors can be found before compilation and potential problems can be eliminated, which may be more attractive to front-end developers. In contrast, JavaScript is a weakly typed language, so many extension languages and tools that add static type detection to JavaScript code have appeared in the front-end community, such as Microsoft's TypeScript and Facebook's Flow. In contrast, Dart itself supports static typing, which is an important advantage of it.
46
-
44
+
45
+
Since Dart is a type-safe language and supports static type detection, some types of errors can be found before compilation and potential problems can be eliminated, which may be more attractive to front-end developers. In contrast, JavaScript is a weakly typed language, so many extension languages and tools that add static type detection to JavaScript code have appeared in the front-end community, such as Microsoft's TypeScript and Facebook's Flow. In contrast, Dart itself supports static typing, which is an important advantage of it.
46
+
47
47
5.**The Dart team is by your side**
48
-
49
-
It may seem inconspicuous, but it is very important. Thanks to the active investment of the Dart team, the Flutter team can get more and more convenient support. As stated on the Flutter official website, "We are working closely with the Dart community to improve the use of Dart in Flutter. For example, when we initially adopted Dart, the language did not provide a toolchain for generating native binary files (which helps to achieve high performance), but it is now implemented because the Dart team built it specifically for Flutter.
50
-
48
+
49
+
It may seem inconspicuous, but it is very important. Thanks to the active investment of the Dart team, the Flutter team can get more and more convenient support. As stated on the Flutter official website, "We are working closely with the Dart community to improve the use of Dart in Flutter. For example, when we initially adopted Dart, the language did not provide a toolchain for generating native binary files (which helps to achieve high performance), but it is now implemented because the Dart team built it specifically for Flutter.
50
+
51
51
52
52
#### to sum up
53
53
@@ -62,13 +62,13 @@ In this section, we first give an overall introduction to the Flutter framework,
62
62
### Flutter Framework
63
63
Flutter is designed as an extensible, layered system. It exists as a series of independent libraries that each depend on the underlying layer. No layer has privileged access to the layer below, and every part of the framework level is designed to be optional and replaceable.This is a pure Dart SDK, which implements a set of basic libraries.
64
64
65
-
From the bottom up, let's briefly introduce:
65
+
From the bottom up, let's briefly introduce:
66
66
67
67
- Basic foundational classes, and building block services such as animation, painting, and gestures that offer commonly used abstractions over the underlying foundation.
68
68
- The rendering layer provides an abstraction for dealing with layout. With this layer, you can build a tree of renderable objects. You can manipulate these objects dynamically, with the tree automatically updating the layout to reflect your changes.
69
69
- The widgets layer is a composition abstraction. Each render object in the rendering layer has a corresponding class in the widgets layer. In addition, the widgets layer allows you to define combinations of classes that you can reuse. This is the layer at which the reactive programming model is introduced.
70
70
- The Material and Cupertino libraries offer comprehensive sets of controls that use the widget layer’s composition primitives to implement the Material or iOS design languages.
71
-
71
+
72
72
73
73
### Flutter Engine
74
74
@@ -85,9 +85,9 @@ This section gives you some learning suggestions and shares some of the author's
85
85
### Resources
86
86
87
87
-**Official website** : Reading the resources of Flutter official website is the best way to get started quickly. At the same time, the official website is also a place to learn about the latest developments in Flutter. Since Flutter is still in the rapid development stage, readers are advised to go to the official website from time to time to see if there are any new trends. .
88
-
88
+
89
89
-**Source code and comments** : The source code comments should be used as the first document for learning Flutter. The source code of the Flutter SDK is open source, and the comments are very detailed. There are also many examples. In fact, the official Flutter SDK documentation is generated through comments. Source code combined with comments can help you solve most problems.
90
-
90
+
91
91
-**Github** : If the problem you encounter is not answered on StackOverflow, you can go to the flutter's github project to raise an issue.
92
92
-**Gallery source code** : Gallery is the official sample app of Flutter. There are rich examples in it. Readers can download and install it online. The source code of Gallery is in the "examples" directory of the Flutter source code.
0 commit comments