Flutter知識(shí)點(diǎn)一

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".

如上就說(shuō)明連接成功,只要有改動(dòng),鍵盤敲擊R或者r 即可看到更改
如果你運(yùn)行命令后一直在waiting,可嘗試殺死該應(yīng)用進(jìn)程后再重啟,進(jìn)入相關(guān)Flutter頁(yè)面就可連接上了

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());
}

  1. DropdownButton的默認(rèn)值要包含在它的items里,不然會(huì)報(bào)錯(cuò)。

4.所有名字以下劃線開頭的變量,Dart 的編譯器都會(huì)將其強(qiáng)制標(biāo)記為私有的。

5.Dart是單線程編程語(yǔ)言,如果任何代碼阻塞線程執(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.itdecent.cn/p/0ce74751d970

10.關(guān)于無(wú)法更新listview的視圖:https://juejin.im/post/5ca2152f6fb9a05e1a7a9a26

  1. flutter_rounded_date_picker: 1.0.0

12.不同開發(fā)環(huán)境配置:http://www.itdecent.cn/p/b9e7c00075e1

13.Platform Channel:http://www.itdecent.cn/p/22939eaa47b1

  1. flutter clean之后,需要flutter create .

15.https://blog.csdn.net/yu75567218/article/details/104590574 gradle版本沖突問(wèn)題。

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.

  1. 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"),
    ),
    ),
  2. 如果要設(shè)置button的背景色 用flatButton, outlineButton設(shè)置Color無(wú)效。
    5.當(dāng)listview沒(méi)有設(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

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容