Problemi cozduk. kodlar arkadaşın GitHub proje linkinde.
https://github.com/mirzaAli20/quran_app/blob/master/lib/ui/listpage/list_all_quran.dart
...
List<SurahInfo> allSurahInfos = new List();
List<SurahInfo> serachResultList = new List();
List<SurahInfo> viewSurahList = new List();
...
getSurahInfos() async {
allSurahInfos = await serviceData.loadInfo();
viewSurahList = allSurahInfos;
setState(() {});
}
@override
void initState() {
super.initState();
serviceData = ServiceData();
getSurahInfos(); // burada json i bir kez cektik
}
@override
Widget build(BuildContext context) {
return allSurahInfos.isNotEmpty
? SingleChildScrollView(
child: Column(
children: [
Container(
margin:
EdgeInsets.only(top: 15, left: 22, right: 22, bottom: 5),
child: TextField(
decoration: InputDecoration(
suffixIcon: Icon(Icons.search),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(50),
),
hintText: 'Search ',
alignLabelWithHint: false,
// filled: true
),
onChanged: (text) {
if (text == '') {
viewSurahList =
allSurahInfos; // buger arama bos ise tum listeyi alicak
} else {
serachResultList.clear();
allSurahInfos.forEach((e) {
if (e.latin.toLowerCase().contains(text.toLowerCase())) serachResultList.add(e);
});
viewSurahList =
serachResultList; // arama bos degilse kelimeye alacak
}
setState(() {});
},
textInputAction: TextInputAction.done,
keyboardType: TextInputType.text,
),
),
ListView(
physics: ScrollPhysics(),
shrinkWrap: true,
children: viewSurahList
.map((data) => CardSurah(
title: data.latin,
subtitle: data.translation,
surah: data.index.toString(),
ayah: data.ayahCount.toString(),
arabic: data.arabic.toString(),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => DetailSurah(
detail: data.latin,
index: data.index)));
},
))
.toList()),
],
),
)
: PKCardListSkeleton(
isCircularImage: true,
isBottomLinesActive: true,
length: 10,
);
}