zoukankan      html  css  js  c++  java
  • 写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"

      80.0,

     height: 80.0,

    );

    网络图片

    Image.network(

      proImage,//图片网络地址链接

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

  • 相关阅读:
    如何设计一个百万级用户的抽奖系统?
    服务注册发现
    消息列队7
    消息列队6
    bzoj 4771: 七彩树
    [SDOI2013]刺客信条
    bzoj 5291: [Bjoi2018]链上二次求和
    51nod 1245 Binomial Coefficients Revenge
    bzoj 5308: [Zjoi2018]胖
    bzoj 5294: [Bjoi2018]二进制
  • 原文地址:https://www.cnblogs.com/hllxy/p/10605455.html
Copyright © 2011-2022 走看看