Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.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
Flutter 如何在小部件构建之前加载/填充对象?_Flutter_Dart - Fatal编程技术网

Flutter 如何在小部件构建之前加载/填充对象?

Flutter 如何在小部件构建之前加载/填充对象?,flutter,dart,Flutter,Dart,我有一个消息选项窗口来显示可用于聊天的用户,在这里我加载一个列表,并在initstate()中填写。我可以看到数据在调试器中被填充,但在第一次时并没有显示出来。当我做热装时,它能工作吗?我错过了什么 class _ChatwindowState extends State<Chatwindow> { List<ChatUsers> chatwithPeople=[]; @override void initState(){ super.initState(); se

我有一个消息选项窗口来显示可用于聊天的用户,在这里我加载一个列表,并在initstate()中填写。我可以看到数据在调试器中被填充,但在第一次时并没有显示出来。当我做热装时,它能工作吗?我错过了什么

class _ChatwindowState extends State<Chatwindow> { List<ChatUsers> chatwithPeople=[]; 
@override void initState(){  super.initState();  setState(() { this.chatwithPeople=peopletomessage(); });}
 @override void dispose() { super.dispose(); }

  @override
  Widget build(BuildContext context) {
  return Scaffold(
  appBar: AppBar(title: Text('Messages'),),
  body:databindUsers(context,widget.currentUser,this.chatwithPeople)
  );
  }
class_chatWindowsState扩展状态{List chatwithPeople=[];
@重写void initState(){super.initState();setState((){this.chatwithPeople=peopletomessage();});}
@重写void dispose(){super.dispose();}
@凌驾
小部件构建(构建上下文){
返回脚手架(
appBar:appBar(标题:文本('Messages'),),
正文:DataIndusers(上下文,widget.currentUser,this.chatwithPeople)
);
}

使用
FutureBuilder
类似

FutureBuilder(
      future: peopletomessage(),//it will return the future type result
      builder: (context, snapshot) {
        
        if(snapshot.connectionState == ConnectionState.done) {
          return databindUsers(context,widget.currentUser,this.chatwithPeople);
        }
        return _progress(); //show loading
      })