I have a screen where I need to search for a term from the Appbar, and the area below shows a Card with selections from the displayed list, and the area below that will show all the results returned, within a scrollable list.
The problem is that although the items returned are placed in a ListView.builder and ScrollPhysics is on, the list is not scrollable. If I click on the Card and try to drag, it scrolls for a bit. But one cannot drag by clicking on the list, or items in it.
import '...';
class DiagnosisAdd extends StatefulWidget {
@override
_DiagnosisAddState createState() => _DiagnosisAddState();
}
class _DiagnosisAddState extends State<DiagnosisAdd> {
TextField searchBar;
TextEditingController searchTextController;
Network connection;
List<ICDCode> DiagnosisList;
List<ICDCode> selectedDiagnoses;
@override
void initState() {
connection = Network();
DiagnosisList = [];
selectedDiagnoses = [];
// searchBar = A widget
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: searchBar,
),
body: ListView(
physics: AlwaysScrollableScrollPhysics(),
shrinkWrap: true,
children: [
Card(
child: ListTile(
title: Text("Selected Diagnoses"),
subtitle: Wrap(
children: List.generate(
selectedDiagnoses.length,
(index) => Text(selectedDiagnoses[index].disease),
growable: true,
),
),
),
),
ListView.builder(
physics: AlwaysScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: DiagnosisList.length,
itemBuilder: (BuildContext context, int position) {
ICDCode codeDiagnosis = DiagnosisList[position];
return RaisedButton(
child:
Text('${codeDiagnosis.code}, ${codeDiagnosis.disease}'),
onPressed: () {});
},
)
],
),
);
}
Future searchDiagnosis(String text) async {
if (text.length < 3) {
return false;
}
var response = await connection.searchICDbyDisease(
searchString: text,
);
final jsonResponse = await json.decode(response);
List<ICDCode> diagnosis_list =
await jsonResponse.map<ICDCode>((i) => ICDCode.fromJson(i)).toList();
setState(() {
DiagnosisList = diagnosis_list;
});
}
}
