學(xué)習(xí)網(wǎng)站
dart學(xué)習(xí)網(wǎng)站:dart.goodev.org
flutter中文網(wǎng):https://flutterchina.club/flutter-for-android/
基礎(chǔ)知識
- dart 是單線程;一般用aysn await 來處理異步操作 (futture)
- 界面基本上都是wighet
- 界面用代碼來編寫,嵌套層級有點(diǎn)多
插件
Flutter定義了三種不同類型的Channel,它們分別是
- BasicMessageChannel:用于傳遞字符串和半結(jié)構(gòu)化的信息。
- MethodChannel:用于傳遞方法調(diào)用(method invocation)。
- EventChannel: 用于數(shù)據(jù)流(event streams)的通信。
插件打包發(fā)布
運(yùn)行 dry-run 命令以查看是否都準(zhǔn)備OK了:
flutter packages pub publish --dry-run
運(yùn)行發(fā)布命令:
flutter packages pub publish
flutter plugin通信原理
flutter的dv層 和android的jvm層借助底層的c/c++來通信
官方類型對比
Dart | Android | iOS |
---|---|---|
null | null | nil (NSNull when nested) |
bool | java.lang.Boolean | NSNumber numberWithBool: |
int | java.lang.Integer | NSNumber numberWithInt: |
int, if 32 bits not enough | java.lang.Long | NSNumber numberWithLong: |
int, if 64 bits not enough | java.math.BigInteger | FlutterStandardBigInteger |
double | java.lang.Double | NSNumber numberWithDouble: |
String j | ava.lang.String | NSString |
Uint8List | byte[] | FlutterStandardTypedData typedDataWithBytes: |
Int32List | int[] | FlutterStandardTypedData typedDataWithInt32: |
Int64List | long[] | FlutterStandardTypedData typedDataWithInt64: |
Float64List | double[] | FlutterStandardTypedData typedDataWithFloat64: |
List | java.util.ArrayList | NSArray |
Map | java.util.HashMap | NSDictionary |
動畫
- AnimationController用于控制動畫,它包含動畫的啟動
forward()
、停止stop()
、反向播放reverse()
等方法 - Tween 類似android的補(bǔ)間動畫,可以通過lerp決定動畫的變化方式
- Curve 差值動畫,要變化不線性用這個,比如彈性Curves.bounceIn
- AnimatedWidget類系統(tǒng)封裝了調(diào)用
setState()
的細(xì)節(jié),只刷新部分用這個省事 - Hero 一個頁面切換另一個頁面,共享元素的時候,可以得到好看的效果
知識點(diǎn)
flutter 看不了 gradle執(zhí)行過程。