写flutter项目之一脚一个坑,持续踩坑中

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>节点的后面

转载于:https://www.cnblogs.com/hllxy/p/10605455.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值