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

  • 相关阅读:
    MySQL 5.7 多主一从实现
    从 MySQL 全备的 SQL 文件中抽离出某张表的数据
    KUBERNETES 03:Pod 资源清单
    KUBERNETES 02:基本操作命令
    KUBERNETES 01:说明与安装
    DOCKER 08:搭建本地镜像仓库 Harbor
    DOCKER 07:docker swarm
    DOCKER 06:docker compose
    DOCKER 05:数据持久化
    DOCKER 04:容器资源限制和网络原理
  • 原文地址:https://www.cnblogs.com/hllxy/p/10605455.html
Copyright © 2020-2023  润新知