---
# System prepended metadata

title: Dart & Flutter

---

Dart & Flutter
===
References:  
Dart: https://book.flutterchina.club/chapter1/dart.html
Flutter: 
https://appcoda.com.tw/flutter-introduction/
https://flutter.dev/docs/get-started/install/macos

Dart
===
- var
    - `var t;`
        - `t = 1000;`  // not able to change var type anymore
- dynamic
    - `dynamic t;`
        - `t = 1000;` 
        - `t = "Hello";` // still can change var type
    - `.lenth`
- Object
    - `Object t;`
        - `t = 1000;`
        - `t = "Hello";` // still can change var type
- const
    - `const PI = 3.14`
    - run while compiling
- final
    - `final PI = 3.141592653589`
    - run when it needed
- (function)
    - ![](https://i.imgur.com/J8abdGH.png)
    - ![](https://i.imgur.com/8sulHnR.png)
    - ![](https://i.imgur.com/rxiTJwh.png)
    - ![](https://i.imgur.com/2PtbMRG.png)
- Future
    - `.then`
        - ![](https://i.imgur.com/R3XPOIw.png)
    - `.catchError`
        - ![](https://i.imgur.com/mKa4Fog.png)
    - `.whenComplete`
        - ![](https://i.imgur.com/nSmvtMa.png)
    - `.wait`
        - ![](https://i.imgur.com/2URvBFb.png)

> avoid "Callback Hell":
> - future
> - async/await
  ![](https://i.imgur.com/cGSaVYY.png)

- async/await  *//語法糖*
    - ![](https://i.imgur.com/HQdiKTR.png)
- Stream
    - ![](https://i.imgur.com/DShPAoY.png)



Flutter
===

- installation: https://flutter.dev/docs/get-started/install
- check: `flutter doctor`

> It doesn't matter if you already installed flutter plug-in in your Android Studio but `flutter doctor` didn't detect correctly.


> Or you can try this: `ln -s ~/Library/Application\ Support/Google/AndroidStudio4.1/plugins ~/Library/Application\ Support/AndroidStudio4.1`



