React Native

reactnative.dev

React Native is like React, but it uses native components instead of web components as building blocks.

History

版本 时间
v0.64 2021-05
v0.63 2020-07
v0.62 2020-05
v0.61 2019-08
v0.60 2019-07
v0.59 2019-05
v0.58 2019-02
v0.57 2018-09

A brief history of React Native

创建项目

Creating a new application

1
npx react-native init AwesomeProject [--version 0.57]

Starts Metro Bundler

1
npx react-native start

Start application

1
npx react-native run-android

Debug

  • Press the R key twice or select Reload from the Developer Menu (Ctrl + M) to see your changes!
  • Before enabling remote debugging on your emulator, open http://localhost:8081/debugger-ui in chrome.

Creating a release build in Android Studio

1
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/

Developing mobile apps with React Native in WebStorm

异常处理

YellowBoxList Error when starting

1
2
react-native start --reset-cache
react-native run-android

How to clear react-native cache?

编程术语

通用

名称 翻译
Throughput 吞吐量
class name collisions 命名冲突
handoff 交付
Epoch UNIX时间

Basic

Insert Cursor / Cursor blinking

caret-color CSS

Language

null safety

Null References: The Billion Dollar Mistake
Sound null safety in Flutter 2: Why embracing this feature is a major milestone?

Pyramid of doom

Null coalescing operator

语言 语法
Bash ${supplied_title:-'Default title'}
SQL NVL or ISNULL or COALESCE
Freemarker ${missingVariable!"defaultValue"}
Kotlin ?: (Elvis operator)
Swift ??
Dart ??
JavaScript ??
PHP ??

Tree shaking

tree shaking is a dead code elimination technique

Reflection

reflection is the ability of a process to examine, introspect, and modify its own structure and behavior.

HTTP Server

Virtual Host

The term Virtual Host refers to the practice of running more than one web site (such as company1.example.com and company2.example.com) on a single machine. Virtual hosts can be “IP-based“, meaning that you have a different IP address for every web site, or “name-based“, meaning that you have multiple names running on each IP address. The fact that they are running on the same physical server is not apparent to the end user.

Time

EDT 美国时间
CST 中国时间

Kotlin Language

  • Kotlin is designed to interoperate fully with Java.
  • Kotlin mainly targets the JVM, but also compiles to JavaScript or native code (via LLVM); e.g., for native iOS apps sharing business logic with Android apps.
  • On 7 May 2019, Google announced that the Kotlin programming language is now its preferred language for Android app developers.
  • https://kotlinlang.org/
  • https://github.com/JetBrains/kotlin

History

版本 时间
v1.0 2016-02
v1.2 2017-11
v1.3 2018-10
v1.4 2020-08
v1.5 2021-05
v1.6 2021-11

Language features

  • Type inference
  • Null safety
  • Semicolons optional
  • String interpolation
  • for in
  • Unpack arguments with spread operator
  • Destructuring declarations
  • Nested functions

Null safety

?. Safe navigation operator
?: null coalescing operator

Flutter

TOC

Intro

Flutter is Google’s UI toolkit for building beautiful, natively compiled applications for mobile, web, desktop, and embedded devices from a single codebase.

  • Dart platform: On Windows, macOS, and Linux Flutter runs in the Dart virtual machine.
  • Flutter engine: Flutter’s engine, written primarily in C++, provides low-level rendering support using Google’s Skia graphics library.
  • Foundation library: The Foundation library, written in Dart, provides basic classes and functions.
  • Design-specific widgets: The Flutter framework contains two sets of widgets that conform to specific design languages: Material Design and Cupertino.

History

版本 时间
1.0 2018-12-04
1.12 2019-12-11
1.17 2020-05-06
2.0 2021-03-03
2.5 2021-09-09
3.0 2022-05-11

Tutorial

Usage

Install

Dev

  • Flutter Outline顶部工具栏都是常用操作
  • 智能提示 Alt + Enter
  • 右键 > Refactor > Extract > Extract Flutter Widget
  • build_runner flutter pub run build_runner watch --delete-conflicting-outputs
  • JetBrains Flutter插件配置

Debug

  • 指定Android Studio目录flutter config --android-studio-dir="C:\Program Files\Android\Android Studio"
  • 关闭空检查参数 --no-sound-null-safety,启用Web renderers --web-renderer=html
  • 关闭Debug标识debugShowCheckedModeBanner: false,也可在Flutter inspector中临时关闭

Build

  • 生成apk flutter build apk --release --no-sound-null-safety
  • flutter build apk --release --no-sound-null-safety --target-platform android-arm64

Troubleshoot

Widgets

  • each widget is an immutable declaration of part of the user interface.
  • most widgets have a build() method
  • Row and Column are two of the most commonly used layout patterns.
  • Layouts in Flutter

Widget state

  • The framework introduces two major classes of widget: stateful and stateless widgets.
  • Many widgets have no mutable state: they don’t have any properties that change over time (for example, an icon or a label).
  • if the unique characteristics of a widget need to change based on user interaction or other factors, that widget is stateful
  • Having separate state and widget objects lets other widgets treat both stateless and stateful widgets in exactly the same way, without being concerned about losing state.

State management

  • InheritedWidget, provides an easy way to grab data from a shared ancestor.
  • Flutter itself uses InheritedWidget extensively as part of the framework for shared state, such as the application’s visual theme, which includes properties like color and type styles that are pervasive throughout an application. This approach is also used for Navigator, which provides page routing; and MediaQuery, which provides access to screen metrics such as orientation, dimensions, and brightness.
  • Many Flutter apps use utility packages like provider, which provides a wrapper around InheritedWidget.

Custom widget

Element

  • An instantiation of a Widget at a particular location in the tree.
  • Widgets describe how to configure a subtree but the same widget can be used to configure multiple subtrees simultaneously because widgets are immutable. An Element represents the use of a widget to configure a specific location in the tree. Over time, the widget associated with a given element can change, for example, if the parent widget rebuilds and creates a new widget for this location.

Rendering and layout

  • Skia, a graphics engine written in C/C++ that calls the CPU or GPU to complete the drawing on the device.

Q&A

Practice

  • Row and Column are basic primitive widgets for horizontal and vertical layouts—these low-level widgets allow for maximum customization. Flutter also offers specialized, higher level widgets that might be sufficient for your needs. For example, instead of Row you might prefer ListTile, an easy-to-use widget with properties for leading and trailing icons, and up to 3 lines of text. Instead of Column, you might prefer ListView, a column-like layout that automatically scrolls if its content is too long to fit the available space.
  • Introduction to widgets
  • Widget catalog
  • Material
  • Basic widgets
  • Scrolling widgets
  • Layout widgets
  • Async widgets
  • Styling widgets

官方视频介绍

Inheritance chain

Demo & Sample

Novice

Packages & plugins

Media

Network

UI

Tool

微信SDK

腾讯视频通话

腾讯即时通信

其他

参考

Comprehension

  • 类不是按照包管理。
  • Row、Column布局是优势。
  • 很多Widget又类似padding不知道这么才能去掉,比如 TextField, ElevatedButton
  • Container中的Container高度会填满
  • const EdgeInsets.all(10.0) 是否需要 const

Computer programmer

Known for Language

Gilad Bracha

  • he worked on the Dart programming language team.
  • He is a co-author of the second and third editions of the Java Language Specification, and a major contributor to the second edition of the Java Virtual Machine Specification.

Lars Bak

  • In 1994, he joined LongView Technologies LLC, where he designed and implemented high performance virtual machines for both Smalltalk and Java.
  • 1997, Bak became engineering manager and technical lead in the HotSpot team at Sun’s Java Software Division where he developed a high-performance Java virtual machine.
  • In 2004, Bak joined Google to work on the Chrome browser.
  • co-developed the Dart programming language presented at the 2011.
  • In 2017, Bak left Google and soon afterward co-founded a startup with Kasper Lund called Toitware, which is building a new programming language called Toit and a platform for Internet of Things systems.

Known for Open-source

Ryan Dahl

  • original developer of the Node.js JavaScript runtime and the Deno JavaScript and TypeScript runtime.
  • In 2018 he announced Deno, a JavaScript/TypeScript runtime built with V8.

Known for Commerical

Dmitry Jemero

Neha Narkhede

  • her first job at Oracle as a principal software engineer. After Oracle, she worked as the lead of streams infrastructure at LinkedIn.
  • While working at LinkedIn in 2011, Narkhede created the Platform Apache Kafka, along with Jun Rao and Jay Kreps.
  • In 2014 she founded Confluent, Confluent as a company has filed for an IPO on June 1, 2021 and was valued at $4.5 billion.

Known Computer Science

Tony Hoare

Alfred Aho (1941)

Known for Book

Gerald Weinberg