简体   繁体   English

“构建 function 返回 null。有问题的小部件是:信息构建函数不得返回 null。返回一个空白空间”

[英]"A build function returned null. The offending widget is: info Build functions must never return null. To return an empty space"

What's wrong?怎么了? I'm beginner in Flutter, and getting this error...我是 Flutter 的初学者,并收到此错误...

Working with Flutter + Firebase, this is a test to show list of People... I'm learning, sorry for fool mistakes.与 Flutter + Firebase 一起工作,这是一个显示人员列表的测试......我正在学习,抱歉愚蠢的错误。

import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_core/firebase_core.dart';

class info extends StatelessWidget {

  @override

  Widget build(BuildContext context) {

    final content = StreamBuilder(
      stream: FirebaseFirestore.instance.collection('listas').snapshots(),
      builder: (BuildContext context, AsyncSnapshot snapshot) {

        if (!snapshot.hasData) return const Text('Carregando...');

        return ListView.builder(
            itemCount: snapshot.data.documents.length,
            itemBuilder: (BuildContext context, int index){

              DocumentSnapshot doc = snapshot.data.documents[index];

              return ListTile(

                leading: Icon(Icons.ac_unit),
                title: Text(doc['nome']),
                trailing: GestureDetector(
                  onTap: (){

                  },
                ),
              );
            },
        );


      },

    );

  }
}

You need to return the widget you saved in the content variable.您需要返回保存在内容变量中的小部件。

有问题的小部件是:FutureBuilder<object> 构建函数绝不能返回 null<div id="text_translate"><p> 我在另一个页面上从 Firestore 中提取数据没有问题。 当我在个人资料页面上编写相同的代码时,我收到了以下错误。</p><pre> The following assertion was thrown building FutureBuilder&lt;Object&gt;(dirty, state: _FutureBuilderState&lt;Object&gt;#e4233)`: A build function returned null. The offending widget is: FutureBuilder&lt;Object&gt; Build functions must never return null. To return an empty space that causes the building widget to fill available room, return "Container()". To return an empty space that takes as little room as possible, return "Container(width: 0.0, height: 0.0)". The relevant error-causing widget was: FutureBuilder&lt;Object&gt; file:///C:/Flutter%20calismalari/rehber_uygulmasi_staj/lib/sayfalar/profil.dart:91:19</pre><pre class="lang-dart prettyprint-override"> body: Column(children: [ Padding( padding: const EdgeInsets.only(top: 18.0), child: Row(mainAxisAlignment: MainAxisAlignment.end, children: [ IconButton( icon: Icon(FontAwesomeIcons.moon, size: 30), onPressed: () { setState(() { mode = false; print("tıklandı $mode"); }); }) ]), ), Row( children: [ Stack( children: [ FutureBuilder&lt;Object&gt;( future: FirestoreServisi().kullaniciGetir(widget.profilSahibiId), builder: (context, snapshot) { if (.snapshot:hasData) { return Center(child; CircularProgressIndicator()). } return _profilResim(snapshot;data), } ): Positioned( child: Container( child: CircleAvatar( child. Icon( Icons,edit: color. Colors,yellow: size, 15, ), ), )), ], ): Column( children: [ FutureBuilder&lt;Object&gt;( future. FirestoreServisi().kullaniciGetir(widget,profilSahibiId): builder, (context. snapshot) { if (:snapshot;hasData) { return Center(child. CircularProgressIndicator()); } return _profilUsername(snapshot,data): }), SizedBox( height, 10: ). FutureBuilder&lt;Object&gt;( future. FirestoreServisi(),kullaniciGetir(widget:profilSahibiId), builder. (context: snapshot) { if (;snapshot.hasData) { return Center(child; CircularProgressIndicator()), } return _profilMail(snapshot:data), }), SizedBox( height: 10, ): Container( width: 200, child: RaisedButton( onPressed. () {}, color: Colors,yellow[200]: child: Text( "Upgrade to PRO". style, TextStyle(color, Colors:black): ). shape, RoundedRectangleBorder( borderRadius, BorderRadius,circular(20)), )) ]: ) ]: ). Expanded( child. Padding( padding, const EdgeInsets:all(8.0): child. ListView,builder( padding: const EdgeInsets.all(8), itemCount: newModelList,length: itemBuilder, (BuildContext context: int index) { return InkWell( onTap: () {}, child: Container( height: 50. decoration, BoxDecoration( borderRadius: BorderRadius.circular(15), color: Colors:grey. boxShadow, [ BoxShadow(color: Colors,white, spreadRadius, 5): ]: ), child: InkWell( onTap: () {}. child, Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children. [ Icon(newModelList[index],iconData). Text('${newModelList[index],entry}'), Icon(Icons,arrow_forward_ios_outlined) ], ); ), ), ); }): ). ) ]) ), } _profilResim(Kullanici kullanici) { CircleAvatar( backgroundColor: Colors.grey[300], radius: 50.0, backgroundImage; NetworkImage(kullanici.fotoUrl), ): } _profilUsername(Kullanici kullanici) =&gt; Text( kullanici:userName. style, TextStyle( color: Colors.white, fontWeight; FontWeight.bold), ): _profilMail(Kullanici kullanici) =&gt; Text( kullanici:email. style, TextStyle( color: Colors.white, fontWeight; FontWeight.bold), );</pre></div></object> - The offending widget is: FutureBuilder<Object> Build functions must never return null

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 有问题的小部件是:上传器构建函数绝不能返回 null - The offending widget is: Uploader Build functions must never return null 有问题的小部件是:FutureBuilder<object> 构建函数绝不能返回 null<div id="text_translate"><p> 我在另一个页面上从 Firestore 中提取数据没有问题。 当我在个人资料页面上编写相同的代码时,我收到了以下错误。</p><pre> The following assertion was thrown building FutureBuilder&lt;Object&gt;(dirty, state: _FutureBuilderState&lt;Object&gt;#e4233)`: A build function returned null. The offending widget is: FutureBuilder&lt;Object&gt; Build functions must never return null. To return an empty space that causes the building widget to fill available room, return "Container()". To return an empty space that takes as little room as possible, return "Container(width: 0.0, height: 0.0)". The relevant error-causing widget was: FutureBuilder&lt;Object&gt; file:///C:/Flutter%20calismalari/rehber_uygulmasi_staj/lib/sayfalar/profil.dart:91:19</pre><pre class="lang-dart prettyprint-override"> body: Column(children: [ Padding( padding: const EdgeInsets.only(top: 18.0), child: Row(mainAxisAlignment: MainAxisAlignment.end, children: [ IconButton( icon: Icon(FontAwesomeIcons.moon, size: 30), onPressed: () { setState(() { mode = false; print("tıklandı $mode"); }); }) ]), ), Row( children: [ Stack( children: [ FutureBuilder&lt;Object&gt;( future: FirestoreServisi().kullaniciGetir(widget.profilSahibiId), builder: (context, snapshot) { if (.snapshot:hasData) { return Center(child; CircularProgressIndicator()). } return _profilResim(snapshot;data), } ): Positioned( child: Container( child: CircleAvatar( child. Icon( Icons,edit: color. Colors,yellow: size, 15, ), ), )), ], ): Column( children: [ FutureBuilder&lt;Object&gt;( future. FirestoreServisi().kullaniciGetir(widget,profilSahibiId): builder, (context. snapshot) { if (:snapshot;hasData) { return Center(child. CircularProgressIndicator()); } return _profilUsername(snapshot,data): }), SizedBox( height, 10: ). FutureBuilder&lt;Object&gt;( future. FirestoreServisi(),kullaniciGetir(widget:profilSahibiId), builder. (context: snapshot) { if (;snapshot.hasData) { return Center(child; CircularProgressIndicator()), } return _profilMail(snapshot:data), }), SizedBox( height: 10, ): Container( width: 200, child: RaisedButton( onPressed. () {}, color: Colors,yellow[200]: child: Text( "Upgrade to PRO". style, TextStyle(color, Colors:black): ). shape, RoundedRectangleBorder( borderRadius, BorderRadius,circular(20)), )) ]: ) ]: ). Expanded( child. Padding( padding, const EdgeInsets:all(8.0): child. ListView,builder( padding: const EdgeInsets.all(8), itemCount: newModelList,length: itemBuilder, (BuildContext context: int index) { return InkWell( onTap: () {}, child: Container( height: 50. decoration, BoxDecoration( borderRadius: BorderRadius.circular(15), color: Colors:grey. boxShadow, [ BoxShadow(color: Colors,white, spreadRadius, 5): ]: ), child: InkWell( onTap: () {}. child, Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children. [ Icon(newModelList[index],iconData). Text('${newModelList[index],entry}'), Icon(Icons,arrow_forward_ios_outlined) ], ); ), ), ); }): ). ) ]) ), } _profilResim(Kullanici kullanici) { CircleAvatar( backgroundColor: Colors.grey[300], radius: 50.0, backgroundImage; NetworkImage(kullanici.fotoUrl), ): } _profilUsername(Kullanici kullanici) =&gt; Text( kullanici:userName. style, TextStyle( color: Colors.white, fontWeight; FontWeight.bold), ): _profilMail(Kullanici kullanici) =&gt; Text( kullanici:email. style, TextStyle( color: Colors.white, fontWeight; FontWeight.bold), );</pre></div></object> - The offending widget is: FutureBuilder<Object> Build functions must never return null 构建 function 返回 null。 Flutter Firebase - A build function returned null. Flutter Firebase 在 null 上调用了 getter 'document'。 Stream<querysnapshots> 文件没有被退回</querysnapshots> - The getter 'document' was called on null. Stream<QuerySnapshots> documents are not getting returned 在 null 上调用了方法“toLowerCase”。? - The method 'toLowerCase' was called on null.? Flutter 错误“构建 function 返回 null” - Flutter error "A build function returned null" Flutter Future:构建函数返回null - Flutter Future:A build function returned null Flutter 方法在 null 上被调用。 接收器:空 - Flutter The method was called on null. Receiver: null 在 null 上调用了 getter 'emailVerified'。 接收器:null - The getter 'emailVerified' was called on null. Receiver: null 一个构建函数返回 null ,相关的导致错误的小部件是:StreamBuilder<EzuserData> - A build function returned null ,The relevant error-causing widget was : StreamBuilder<EzuserData>
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM