Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Dart 颤振无法从StreamBuilder加载小部件_Dart_Flutter - Fatal编程技术网

Dart 颤振无法从StreamBuilder加载小部件

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

我正在使用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 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(),
          ],
        );
      }
    ),
 );
}