1. The getter 'xxx' was called on null.
String判斷空值時,null寫在前面。 好吧,如果寫過Android的同學應該是沒問題,但是作為C#的童鞋來講,真的是不知道
如:
var image="12345";
if(null != image && image.isNotEmpty)
2.獲取本地圖片,網絡圖片
需要區分本地,網絡
本地圖片
Image.asset(
proImage,//圖片地址。如:"images/error_head.png"
width: 80.0,
height: 80.0,
);
網絡圖片
Image.network(
proImage,//圖片網絡地址鏈接
width: 80.0,
height: 80.0,
);
3.彈框返回,報 Looking up a deactivated widget's ancestor is unsafe 錯
將彈框單獨寫,然后再在需要的地方調用,如:
Future<AlertDialog> myDialog(BuildContext context) { return showDialog<AlertDialog>( context: context, builder: (BuildContext context) { return AlertDialog( title: new Text('提示'), content: new Text('你確定要退出嗎?'), actions: <Widget>[ OutlineButton( child: new Text('取消'), onPressed: () { Navigator.of(context).pop(); }, ), OutlineButton( child: new Text('確定'), onPressed: () async { //todo 清除更新登陸狀態 }, ) ], ); }); }
調用:
4.[ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: 'package:flutter/src/widgets/scroll_controller.dart': Failed assertion: line 110 pos 12: '_positions.isNotEmpty': ScrollController not attached to any scroll views.
5.在報 空值錯誤 的時候,不一定是你加的值是空的 有可能是你使用的對象沒有聲明
6.Execution failed for task ':app:processDebugResources'.
看到這句話,先將項目中的build文件夾刪除,重新編譯
7.ios的權限,Info.plist 添加權限時,加到</true>節點的后面