Reputation: 199
I don't have trouble withdrawing data from Firestore on another page. I have received the following errors when I wrote the same codes on the profile page.
The following assertion was thrown building FutureBuilder<Object>(dirty, state: _FutureBuilderState<Object>#e4233)`:
A build function returned null.
The offending widget is: FutureBuilder<Object>
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<Object> file:///C:/Flutter%20calismalari/rehber_uygulmasi_staj/lib/sayfalar/profil.dart:91:19
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<Object>(
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<Object>(
future: FirestoreServisi()
.kullaniciGetir(widget.profilSahibiId),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Center(child: CircularProgressIndicator());
}
return _profilUsername(snapshot.data);
}),
SizedBox(
height: 10,
),
FutureBuilder<Object>(
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) => Text(
kullanici.userName,
style: TextStyle(
color: Colors.white, fontWeight: FontWeight.bold),
);
_profilMail(Kullanici kullanici) => Text(
kullanici.email,
style: TextStyle(
color: Colors.white, fontWeight: FontWeight.bold),
);
Upvotes: 0
Views: 64
Reputation: 5608
You forgot to return the widget in your _profilResim()
function:
Widget _profilResim(Kullanici kullanici) {
return CircleAvatar(
backgroundColor: Colors.grey[300],
radius: 50.0,
backgroundImage: NetworkImage(kullanici.fotoUrl),
);
}
Upvotes: 1
Reputation: 2714
I assume this is because of the Network Image
.
_profilResim(Kullanici kullanici) {
CircleAvatar(
backgroundColor: Colors.grey[300],
radius: 50.0,
backgroundImage: NetworkImage(kullanici.fotoUrl != null ? kullanici.fotoUrl : ''),
);
}
Upvotes: 0