Dart 颤振无法从StreamBuilder加载小部件
我正在使用BLoC调用API。成功响应后,我需要调用名为 _移动到主屏幕() 。 下面是我的代码Dart 颤振无法从StreamBuilder加载小部件,dart,flutter,Dart,Flutter,我正在使用BLoC调用API。成功响应后,我需要调用名为 _移动到主屏幕() 。 下面是我的代码 @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( // Here we take the value from the MyHomePage object that was created by // the App.build meth
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
//body: UserDetail(),
body: new Container(
padding: EdgeInsets.all(16.0),
child:StreamBuilder(
stream: bloc.validateUser,
builder: (BuildContext context, snapshot) {
if(snapshot.hasData){
_moveToHomeScreen();
}
return Column(
children: <Widget>[
_createInputFields(),
_createRegisterButton(),
],
);
}
),
);
}
控件进入小部件,但我无法看到小部件所需的输出。您的Streambuilder永远不会返回\u moveToHomeScreen()强>
override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
//body: UserDetail(),
body: new Container(
padding: EdgeInsets.all(16.0),
child:StreamBuilder(
stream: bloc.validateUser,
builder: (BuildContext context, snapshot) {
if(snapshot.hasData){
return _moveToHomeScreen();
}
return Column(
children: <Widget>[
_createInputFields(),
_createRegisterButton(),
],
);
}
),
);
}
覆盖
小部件构建(构建上下文){
返回脚手架(
appBar:appBar(
//在这里,我们从MyHomePage对象中获取由创建的值
//使用App.build方法,并使用它设置appbar标题。
标题:文本(widget.title),
),
//正文:UserDetail(),
主体:新容器(
填充:所有边缘设置(16.0),
孩子:StreamBuilder(
流:bloc.euser,
生成器:(BuildContext上下文,快照){
if(snapshot.hasData){
返回_moveToHomeScreen();
}
返回列(
儿童:[
_createInputFields(),
_createRegisterButton(),
],
);
}
),
);
}
刚刚在
\u moveto homescreen();
之前添加了return,您的StreamBuilder
始终返回返回列(
override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
//body: UserDetail(),
body: new Container(
padding: EdgeInsets.all(16.0),
child:StreamBuilder(
stream: bloc.validateUser,
builder: (BuildContext context, snapshot) {
if(snapshot.hasData){
return _moveToHomeScreen();
}
return Column(
children: <Widget>[
_createInputFields(),
_createRegisterButton(),
],
);
}
),
);
}