Hello friends I am learning to build apps in Flutter. I have a FutureBuilder widget which retrieves Data from the server and displays them. Here is the code:
FutureBuilder(
future: fetchBoxes(),
builder: (BuildContext context,
AsyncSnapshot<List<Box>> snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.none:
return Text('no connection');
case ConnectionState.active:
case ConnectionState.waiting:
return Center(
child: CircularProgressIndicator(),
);
break;
case ConnectionState.done:
if (snapshot.hasError) {
return Text('error');
} else {
if (snapshot.hasData) {
return ListView.builder(
shrinkWrap: true,
itemCount: snapshot.data.length,
itemBuilder: (BuildContext context,
int position) {
/* String price =
snapshot.data[position]['price'];*/
/* print(snapshot
.data[1].user_id);*/
// inspect(snapshot.data);
return Card();
and I want to implement it inside this Widget for getting scrollable widget: My code :
@override
Widget build(BuildContext context) {
return SafeArea(
minimum: const EdgeInsets.only(
top: 20.0, right: 5.0, left: 5.0, bottom: 10.0),
child: Center(
child: Scaffold(
backgroundColor: Color(0xFFF6F7F8),
body: Stack(
children: [
Container(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(
padding: EdgeInsets.all(10),
child: ElevatedButton.icon(
style: ElevatedButton.styleFrom(
primary: KBlue,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(30))),
onPressed: () {
showDialog(
context: context,
builder: (BuildContext context) =>
_addNewBox(context),
);
},
label: Text(
'Ajouter un nouveau box',
style: TextStyle(color: Colors.white),
),
icon: Icon(
CommunityMaterialIcons.plus,
color: Colors.white,
),
),
);
How can I implement scrollable widget correctly?