HIIII! I have this problem where I need to display items, but I cant. I don't know where i should put the FutureBuilder. It's supposed to display thisenter image description here
Widget build(BuildContext context) {
return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
Column(
children: [
HomeAppBar(),
PointShopInfo(),
Text(
"Items",
style: TextStyle(
fontFamily: 'Inter-bold',
fontSize: 23,
),
),
],
),
FutureBuilder(
future: _getRedeemShop(),
builder: (BuildContext context, AsyncSnapshot snapshot3) {
if (snapshot3.data == null) {
return Center(
child: Text(
"Nothing to see here...",
style: TextStyle(
color: Color.fromARGB(255, 150, 150, 150),
fontSize: 16,
fontFamily: 'Inter',
),
),
);
} else {
return ListView.builder(
itemCount: snapshot3.data.length,
itemBuilder: (BuildContext context, int index) {
PointShopData data = snapshot3.data[index];
return Card(
color: Colors.white,
margin:
EdgeInsets.symmetric(horizontal: 10, vertical: 5),
child: ListTile(
title: Text(
snapshot3.data[index].points_name,
style: TextStyle(
fontFamily: 'Inter-bold',
fontSize: 18,
),
),
subtitle: Text(
snapshot3.data[index].points.toString(),
style: TextStyle(
fontFamily: 'Inter-semibold',
fontSize: 12,
),
),
),
);
},
);
}
},
),
],
),
],
),
);
}
I've tried putting it in the same column as other elements and it still looks like thisenter image description here
CodePudding user response:
try this
if (snapshot3.connectionState == ConnectionState.done && snapshot3.data == null) {
return Center(
child: Text(
"Nothing to see here...",
style: TextStyle(
color: Color.fromARGB(255, 150, 150, 150),
fontSize: 16,
fontFamily: 'Inter',
),
),
);
}
for checking if the data is null and successfully connect so show the message otherwise you'll show your list
if this not working what your debug say ?