I am trying to build a list using future builder in flutter, which i succeeded in. but now the list is not scrolling, when we scroll through little space around sides (dark complexion shown in image), it scrolls and show full list bul it does not scrolls from anywhere else.
as seen in the screenshot, when you try to scroll down, it will do nothing but when i place mouse at sides of sides of container (darker complexion of white) it scrolls through all list.
Complete code.
Scaffold(
backgroundColor: Color.fromRGBO(242, 242, 242, 1),
appBar: AppBar(
backgroundColor: Color(0xFF000080),
title: Text(
'Medication List',
style: TextStyle(
fontSize: 20,
color: Colors.grey[100],
fontWeight: FontWeight.w600),
),
leading: IconButton(
onPressed: () {
Navigator.pop(context);
},
icon: Icon(
Icons.arrow_back_ios,
color: Colors.grey[100],
),
),
actions: [
FlatButton(
onPressed: () {
vari.medication = Medication();
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ListNew(
decision: widget.decison,
))).then((value) {
if (widget.decison == false) {
setState(() {
medicationList = vari.database.listFromAllMedication();
});
} else {
setState(() {
medicationList =
vari.database.listFromMedication(vari.member);
});
}
});
},
child: Text(
'NEW',
style: TextStyle(fontSize: 16, color: Colors.grey[100]),
),
),
PopupMenuButton<String>(
itemBuilder: (context) => [
PopupMenuItem(
value: '1',
child: Text("List by Physician"),
),
PopupMenuItem(
value: '2',
child: Text("List all Meds"),
),
PopupMenuItem(
value: '3',
child: Text("Send List"),
),
],
onSelected: (value) async => {
if (value == '1')
{
Navigator.push(context,
MaterialPageRoute(builder: (context) => PhysicianList()))
}
else if (value == '2')
{
if (widget.decison == false)
{
setState(() {
medicationList = vari.database.listFromAllMedication();
})
}
else
{
setState(() {
medicationList =
vari.database.listFromMedication(vari.member);
})
}
}
else if (value == '3')
{writeMedication()}
},
),
],
),
body: SingleChildScrollView(
child: Container(
child: widget.decison == true
? Column(
children: [
Center(
child: Padding(
padding: EdgeInsets.only(
top: 10,
),
child: Text(
familymember,
style: TextStyle(
fontSize: 28,
color: Colors.grey[700],
),
),
),
),
Container(
margin: EdgeInsets.symmetric(
vertical: 10,
horizontal: w * 0.07,
),
child: Divider(
color: Color(0xFF000080),
thickness: 2,
)),
SizedBox(
height: 20,
),
Container(
width: MediaQuery.of(context).size.width * 0.9,
margin: EdgeInsets.only(top: 20),
child: FutureBuilder(
future: medicationList,
builder: (BuildContext context,
AsyncSnapshot<List> snapshot) {
if (!snapshot.hasData) return Text("");
return Container(
//height: 225 * snapshot.data.length.toDouble(),
child: ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: snapshot.data.length,
itemBuilder: (context, index) {
return Container(
child: InkWell(
onTap: () {
vari.medication =
snapshot.data[index];
if (vari.medication.medImage == '') {
vari.medication.medImage = null;
}
if (vari.medication.presImage == '') {
vari.medication.presImage = null;
}
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ListNew(
decision:
widget.decison,
))).then((value) {
if (widget.decison == false) {
setState(() {
medicationList = vari.database
.listFromAllMedication();
});
} else {
setState(() {
medicationList = vari.database
.listFromMedication(
vari.member);
});
}
});
},
child: Card(
child: Padding(
padding: const EdgeInsets.all(15),
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Text('Generic: '),
Text(
'${snapshot.data[index].genName}',
style: TextStyle(
fontSize: 16,
color: Color(
0xff031e41)),
),
],
),
SizedBox(
height: 5,
),
Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Text('Brand: '),
Text(
'${snapshot.data[index].mfgName}',
style: TextStyle(
fontSize: 16,
color: Color(
0xff031e41)),
),
],
),
SizedBox(
height: 5,
),
Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Text('Strength: '),
Text(
'${snapshot.data[index].strength} ${snapshot.data[index].unit}',
style: TextStyle(
fontSize: 16,
color: Color(
0xff031e41)),
),
],
),
SizedBox(
height: 5,
),
Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Text('Qty: '),
Text(
'${snapshot.data[index].quantity}',
style: TextStyle(
fontSize: 16,
color: Color(
0xff031e41)),
),
],
),
SizedBox(
height: 5,
),
Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Text('Route: '),
Text(
'${snapshot.data[index].route}',
style: TextStyle(
fontSize: 16,
color: Color(
0xff031e41)),
),
],
),
SizedBox(
height: 5,
),
Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Text('Form: '),
Text(
'${snapshot.data[index].form}',
style: TextStyle(
fontSize: 16,
color: Color(
0xff031e41)),
),
],
),
SizedBox(
height: 5,
),
Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Text('Family Member: '),
AutoSizeText(
'${snapshot.data[index].memberStr}',
maxLines: 1,
style: TextStyle(
fontSize: 16,
color: Color(
0xff031e41)),
),
],
),
Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Text('Physician: '),
AutoSizeText(
'${snapshot.data[index].physicianStr}',
maxLines: 1,
style: TextStyle(
fontSize: 16,
color: Color(
0xff031e41)),
),
],
),
],
),
),
),
),
);
}),
);
}),
),
],
)
: Center(
child: Container(
width: MediaQuery.of(context).size.width * 0.9,
margin: EdgeInsets.only(top: 20),
child: FutureBuilder(
future: medicationList,
builder: (BuildContext context,
AsyncSnapshot<List> snapshot) {
if (!snapshot.hasData) return Text("");
return Container(
//height: 225 * snapshot.data.length.toDouble(),
child: ListView.builder(
shrinkWrap: true,
scrollDirection: Axis.vertical,
itemCount: snapshot.data.length,
itemBuilder: (context, index) {
return InkWell(
onTap: () {
vari.medication = snapshot.data[index];
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ListNew(
decision: widget.decison,
))).then((value) {
if (widget.decison == false) {
setState(() {
medicationList = vari.database
.listFromAllMedication();
});
} else {
setState(() {
medicationList = vari.database
.listFromMedication(
vari.member);
});
}
});
},
child: Card(
child: Padding(
padding: const EdgeInsets.all(15),
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Text('Generic: '),
Text(
'${snapshot.data[index].genName}',
style: TextStyle(
fontSize: 16,
color: Color(0xff031e41)),
),
],
),
SizedBox(
height: 5,
),
Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Text('Brand: '),
Text(
'${snapshot.data[index].mfgName}',
style: TextStyle(
fontSize: 16,
color: Color(0xff031e41)),
),
],
),
SizedBox(
height: 5,
),
Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Text('Strength: '),
Text(
'${snapshot.data[index].strength} ${snapshot.data[index].unit}',
style: TextStyle(
fontSize: 16,
color: Color(0xff031e41)),
),
],
),
SizedBox(
height: 5,
),
Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Text('Qty: '),
Text(
'${snapshot.data[index].quantity}',
style: TextStyle(
fontSize: 16,
color: Color(0xff031e41)),
),
],
),
SizedBox(
height: 5,
),
Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Text('Route: '),
Text(
'${snapshot.data[index].route}',
style: TextStyle(
fontSize: 16,
color: Color(0xff031e41)),
),
],
),
SizedBox(
height: 5,
),
Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Text('Form: '),
Text(
'${snapshot.data[index].form}',
style: TextStyle(
fontSize: 16,
color: Color(0xff031e41)),
),
],
),
SizedBox(
height: 5,
),
Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Text('Family Member: '),
AutoSizeText(
'${snapshot.data[index].memberStr}',
maxLines: 1,
style: TextStyle(
fontSize: 16,
color: Color(0xff031e41)),
),
],
),
Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: [
Text('Physician: '),
AutoSizeText(
'${snapshot.data[index].physicianStr}',
maxLines: 1,
style: TextStyle(
fontSize: 16,
color: Color(0xff031e41)),
),
],
),
],
),
),
),
);
}),
);
}),
),
),
),
),
);