我一直从流生成器if语句中获取此断言错误像素!= 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”:不正确。
static _doThrowNew(int assertionStart,int assertionEnd,Object 消息)本地“ AssertionError_throwNew”;
答案 0 :(得分:0)
我发现需要将其放在选项卡视图中
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,
);
}
});