I currently have a flutter app which displays clickable images within a gridview.
After selecting an image, it takes you to a detailed page which provides more info on the selected category:
I now need to build search functionality which would filter based on the Category Detail. So if I search for "Fishing", the gridview filters displaying "Agriculture" and whatever other Category detail contains that word.
I currently use Firebase to return the Category detail whenever a user selects the Category so I assume that the search would have to be linked to my firebase?
I've tried looking for answers on the web but none caters for my specific requirement.
UPDATE Included Gridview Page Code:
class _LevelPageState extends State<LevelPage> {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: AppBar(
backgroundColor: Colors.grey,
title: Text(widget.level.data["region"]),
centerTitle: true,
),
body: ListView(shrinkWrap: true, children: <Widget>[
Container(
child: ListTile(
title: Text(
'Current Level ' + widget.level.data["level"].toString(),
style: TextStyle(
color: widget.level.data["level"] == 5
? Colors.red[900]
: widget.level.data["level"] == 4
? Colors.orange[900]
: widget.level.data["level"] == 3
? Colors.brown[300]
: widget.level.data["level"] == 2
? Colors.blue[300]
: widget.level.data["level"] == 1
? Colors.green[300]
: Colors.black,
fontSize: 25,
fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
),
),
Container(
height: (MediaQuery.of(context).size.height),
padding: EdgeInsets.all(10),
child: GridView.count(
shrinkWrap: true,
physics: ScrollPhysics(),
mainAxisSpacing: 40,
crossAxisSpacing: 20,
crossAxisCount: 3,
childAspectRatio: MediaQuery.of(context).size.height / 400,
children: <Widget>[
ListTile(
title: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
color: Colors.grey,
),
child: InkWell(
enableFeedback: true,
child: Image.asset('assets/images/mediaicon.png'),
onTap: () => {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => CategoryPage(
text1: 'Media',
text2: widget.level.data["region"].toString(),
text3:
widget.level.data["level"].toString())))
},
splashColor: Colors.white,
borderRadius: BorderRadius.circular(20),
)),
subtitle: Text('Media',
style: TextStyle(
color: Colors.white,
fontSize: 10,
),
textAlign: TextAlign.center),
),
ListTile(
title: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
color: Colors.grey,
),
child: InkWell(
enableFeedback: true,
child: Image.asset('assets/images/mobileanditicon.png'),
onTap: () => {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => CategoryPage(
text1: 'Info and Comms',
text2: widget.level.data["region"].toString(),
text3:
widget.level.data["level"].toString())))
},
splashColor: Colors.white,
borderRadius: BorderRadius.circular(20),
)),
subtitle: Text('Info and Comms',
style: TextStyle(
color: Colors.white,
fontSize: 10,
),
textAlign: TextAlign.center),
),
ListTile(
title: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
color: Colors.grey,
),
child: InkWell(
enableFeedback: true,
child: Image.asset('assets/images/utilitiesicon.png'),
onTap: () => {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => CategoryPage(
text1: 'Utilities',
text2: widget.level.data["region"].toString(),
text3:
widget.level.data["level"].toString())))
},
splashColor: Colors.white,
borderRadius: BorderRadius.circular(20),
)),
subtitle: Text('Utilities',
style: TextStyle(
color: Colors.white,
fontSize: 10,
),
textAlign: TextAlign.center),
),
ListTile(
title: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
color: Colors.grey,
),
child: InkWell(
enableFeedback: true,
child: Image.asset('assets/images/educationicon.png'),
onTap: () => {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => CategoryPage(
text1: 'Education',
text2: widget.level.data["region"].toString(),
text3:
widget.level.data["level"].toString())))
},
splashColor: Colors.white,
borderRadius: BorderRadius.circular(20),
)),
subtitle: Text('Education',
style: TextStyle(
color: Colors.white,
fontSize: 10,
),
textAlign: TextAlign.center),
),
ListTile(
title: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
color: Colors.grey,
),
child: InkWell(
enableFeedback: true,
child: Image.asset('assets/images/repairsicon.png'),
onTap: () => {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => CategoryPage(
text1: 'Repairs',
text2: widget.level.data["region"].toString(),
text3:
widget.level.data["level"].toString())))
},
splashColor: Colors.white,
borderRadius: BorderRadius.circular(20),
)),
subtitle: Text('Repairs',
style: TextStyle(
color: Colors.white,
fontSize: 10,
),
textAlign: TextAlign.center),
),
ListTile(
title: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
color: Colors.grey,
),
child: InkWell(
enableFeedback: true,
child:
Image.asset('assets/images/domestichelpicon.png'),
onTap: () => {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => CategoryPage(
text1: 'Domestic Help',
text2: widget.level.data["region"].toString(),
text3:
widget.level.data["level"].toString())))
},
splashColor: Colors.white,
borderRadius: BorderRadius.circular(20),
)),
subtitle: Text('Domestic Help',
style: TextStyle(
color: Colors.white,
fontSize: 10,
),
textAlign: TextAlign.center),
),
],
),
),
]));
}
}
I have adjusted the above code to only include 6 of the gridview images to shorten the code.


