3 minute read

Tags:

阿就 去年給自己目標 要寫一個

Flutter 的 賽 Project :sunglasses:

一直有點餛飩的 此時此刻的上半年

也把 Yuting Object Detection 用好 :soccer:

想說就把 東西 用 expo 搬到 react-native 丟上 app (ios, android) XDDD :star::star:

很聰明吧! 不用學新的 阿就這樣 XD :eyes::eyes:

阿現在八月中

作天回了一趟鄉下 :sunny:

看到小狐狸 撿來來阿嬤家也 10 多年了 :dog:

生老病死 春夏秋冬 東南西北 花開花落

也是時候督述自己拉! :bikini:

好就這樣 :mortar_board::mortar_board::mortar_board:

可以直接線上玩 Dart

官方土魠魚 :whale:

啊我就照著土魠魚 玩 XDD

A basic Dart porgram

// 簡簡單單 function
void printIntergert(int aNumber) {
    print('數字是 $aNumber');
}

void main() {
    var number = 1450;
    printIntergert(number);
  • //

    • Comment
  • void

    • 沒有回傳值拉!
  • int

  • '...' or "..."

    • 跟 python 一樣 "", '' 都可以!
  • $variableName or ${expression}

  • main()

    • 一定要有! 其始點!
    • main()

Built-in types

阿~ 你問我都看玩熟讀了嗎?

那五摳您~~ 當然是碰到後 速度來看! :snowman:

常保熱情! 終身學習ㄚㄚ!

Import concepts 精華重點! :mushroom:

As you learn about the Dart language, keep these facts and concepts in mind:

當你把玩 Dart 請把以下事項 牢記在心~

靠這文件寫得很好ㄟ!!! 學起來! 用在工作上! XDD

  • Everything you can place in a variable is an object, and every object is an instance of a class. Even numbers, functions, and null are objects. With the exception of null (if you enable sound null safety), all objects inherit from the Object class.

Version note: Null safety was introduced in Dart 2.12. Using null safety requires a language version of at least 2.12.

  • Although Dart is strongly typed, type annotations are optional because Dart can infer types. In the code above, number is inferred to be of type int.

  • If you enable null safety, variables can’t contain null unless you say they can. You can make a variable nullable by putting a question mark (?) at the end of its type. For example, a variable of type int? might be an integer, or it might be null. If you know that an expression never evaluates to null but Dart disagrees, you can add ! to assert that it isn’t null (and to throw an exception if it is). An example: int x = nullableButNotNullInt!

  • When you want to explicitly say that any type is allowed, use the type Object? (if you’ve enabled null safety), Object, or — if you must defer type checking until runtime — the special type dynamic.

  • Dart supports generic types, like List<int> (a list of integers) or List<Object> (a list of objects of any type).

  • Dart supports top-level functions (such as main()), as well as functions tied to a class or object (static and instance methods, respectively). You can also create functions within functions (nested or local functions).

  • Similarly, Dart supports top-level variables, as well as variables tied to a class or object (static and instance variables). Instance variables are sometimes known as fields or properties.

  • Unlike Java, Dart doesn’t have the keywords public, protected, and private. If an identifier starts with an underscore (_), it’s private to its library. For details, see Libraries and visibility.

  • Identifiers can start with a letter or underscore (_), followed by any combination of those characters plus digits.

  • Dart has both expressions (which have runtime values) and statements (which don’t). For example, the conditional expression condition ? expr1 : expr2 has a value of expr1 or expr2. Compare that to an if-else statement, which has no value. A statement often contains one or more expressions, but an expression can’t directly contain a statement.

  • Dart tools can report two kinds of problems: warnings and errors. Warnings are just indications that your code might not work, but they don’t prevent your program from executing. Errors can be either compile-time or run-time. A compile-time error prevents the code from executing at all; a run-time error results in an exception being raised while the code executes.

資源

Tags:

Updated: