1.Flutter module支持hot reload (熱重載)
進(jìn)入到flutter module目錄下
執(zhí)行命令 flutter attach 即可
Waiting for a connection from Flutter on SM N9600...
Syncing files to device SM N9600...
6,061ms (!)
? To hot reload changes while running, press "r". To hot restart (and rebuild state), press "R".
An Observatory debugger and profiler on SM N9600 is available at: http://127.0.0.1:61382/dcDqRpWTVVI=/
For a more detailed help message, press "h". To detach, press "d"; to quit, press "q".
如上就說明連接成功裳瘪,只要有改動(dòng)蔚出,鍵盤敲擊R或者r 即可看到更改
如果你運(yùn)行命令后一直在waiting笆凌,可嘗試殺死該應(yīng)用進(jìn)程后再重啟,進(jìn)入相關(guān)Flutter頁面就可連接上了
2.Handling errors in Flutter(https://flutter.dev/docs/testing/errors)
For example, to make your application quit immediately any time an error is shown in release mode, you could use the following handler:
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
void main() {
FlutterError.onError = (FlutterErrorDetails details) {
FlutterError.dumpErrorToConsole(details);
if (kReleaseMode)
exit(1);
};
runApp(MyApp());
}
- DropdownButton的默認(rèn)值要包含在它的items里,不然會(huì)報(bào)錯(cuò)祈噪。
4.所有名字以下劃線開頭的變量雕擂,Dart 的編譯器都會(huì)將其強(qiáng)制標(biāo)記為私有的踊东。
5.Dart是單線程編程語言,如果任何代碼阻塞線程執(zhí)行都會(huì)導(dǎo)致程序卡死(IO操作贰健、延時(shí)執(zhí)行等).異步編程防止出現(xiàn)阻塞操作.Dart使用Future對(duì)象表示異步操作.
6.值得注意的是如果你實(shí)現(xiàn)了一個(gè)類斤斧,那么必須實(shí)現(xiàn)該類所有的方法和成員屬性,即便它是私有的霎烙。
7.路由相關(guān):https://blog.csdn.net/yuzhiqiang_1993/article/details/89090742
8.網(wǎng)絡(luò)相關(guān):https://invoker.me/flutter-for-android-part-2/
9.column row布局詳解:http://www.reibang.com/p/0ce74751d970
10.關(guān)于無法更新listview的視圖:https://juejin.im/post/5ca2152f6fb9a05e1a7a9a26
- flutter_rounded_date_picker: 1.0.0
12.不同開發(fā)環(huán)境配置:http://www.reibang.com/p/b9e7c00075e1
13.Platform Channel:http://www.reibang.com/p/22939eaa47b1
- flutter clean之后,需要flutter create .
15.https://blog.csdn.net/yu75567218/article/details/104590574 gradle版本沖突問題蕊连。
16.BasicMessageChannel:傳遞字符串和半結(jié)構(gòu)化數(shù)據(jù)
MethodChannel:方法調(diào)用
EventChannel:數(shù)據(jù)流的通信
17.在編譯打包的時(shí)候出現(xiàn)了找不到相關(guān)的包,原因是flutter三個(gè)默認(rèn)配置的地方采用了Google路徑的包
19.執(zhí)行命令flutter packages pub run build_runner build lib進(jìn)行一次性構(gòu)建,效率比較低
執(zhí)行命令flutter packages pub run build_runner watch lib這個(gè)命令可以實(shí)時(shí)文件監(jiān)聽悬垃,自動(dòng)創(chuàng)建實(shí)體類生成對(duì)應(yīng)的.g.dart文件。
https://meandni.com/2019/03/04/flutter-route/#%E6%95%B0%E6%8D%AE%E4%BC%A0%E9%80%92
https://doc.xuwenliang.com/docs/dart-flutter/1365
https://blog.whezh.com/flutter-route-and-navigator/
https://hackernoon.com/flutter-pros-and-cons-for-seamless-cross-platform-development-c81bde5a4083
1.pub get failed (1; So, because flutter_gallery depends on test_api 0.2.15, version solving failed.)
2.Column or Row Contain a Listview, ListView don't scroll. ----resovled.
listView must has a father widget, which is Expanded.
- Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(
width: 40.0,
height: 40.0,
child: OutlineButton(
shape: CircleBorder(),
borderSide: const BorderSide(color: Color(0xFFE65400)),
onPressed: () {
_toggle(page_one);
},
child: new Text("1"),
),
), - 如果要設(shè)置button的背景色 用flatButton甘苍, outlineButton設(shè)置Color無效尝蠕。
5.當(dāng)listview沒有設(shè)置height時(shí),要設(shè)置shrinkWrap為true载庭,否則異常看彼。
6.Running "flutter pub get" in flutter_module...
OS Error: The semaphore timeout period has expired.
, errno = 121, address = storage.googleapis.com, port = 49561
7.Flutter app error - getter 'value' was called on null
answer:
If you have created and assigned value to the variable and still it shows getter 'value' was called on null, try to Run or Restart your app instead of Hot Reload. Because Hot Reload will not call initstate() (where variables assign their values) which will be only called by Restarting the app.
How to add a flutter module to android app.
link:https://blog.codemagic.io/flutter-module-android-yaml/s
flutter create -t module name_of_module