【问题标题】:Need help solving Flutter pixels assetion error需要帮助解决 Flutter 像素断言错误
【发布时间】:2019-02-28 06:37:02
【问题描述】:

我不断从流构建器 if 语句中收到此断言错误 pixel!=null,它不会从 if 中返回任何内容,只会从 else 中返回。谢谢。很迷茫

  Widget build(BuildContext context) {
    print("ffff23223r");
    return new StreamBuilder(
        stream: FirebaseAuth.instance.currentUser().asStream(),
        builder: (context, theuser) {
                   {
            if(theuser.hasData && theuser.data.isEmailVerified){
            return  Container(color:Colors.red
            );//always gives me error
          }
          else{return intro(theuser);//works fine no matter whats here  }
          }
        });  
  }

错误:

发生了异常。 'package:flutter/src/widgets/scroll_position.dart':断言失败: 第 661 行 pos 12: 'pixels != null': is not true.

静态 _doThrowNew(int assertionStart, int assertionEnd, Object 消息)本机“AssertionError_throwNew”;

【问题讨论】:

  • 你需要给你的容器一个高度
  • 刚刚尝试过并添加了宽度,没有运气。

标签: dart flutter flutter-layout


【解决方案1】:

发现需要放到tabbar视图中:

 return new StreamBuilder(
    stream: FirebaseAuth.instance.currentUser().asStream(),
    builder: (context, theuser) {
      {
        return Scaffold(
          body: new TabBarView(controller: controller, children: <Widget>[
            theuser.hasData && theuser.data.isEmailVerified
                ? main2MapPage(theuser)
                : new intro(theuser),
          ]),
          backgroundColor: Colors.redAccent,
        );
      }
    });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-09
    • 1970-01-01
    • 1970-01-01
    • 2021-09-10
    • 2021-12-11
    相关资源
    最近更新 更多