I’m making an app to search courses on firebase. The app bar shows a text: "Home", and it has a search button at the rigth side of the screen:
I want to hide that "Home" text from de app bar at moment to click the search button, and show the field to type the query.
this is my code, i dont know how to implement that.
appBar: AppBar(
title: Text(
"Home",
style: TextStyle(
fontSize: 16.0, /*fontWeight: FontWeight.bold*/
),
),
centerTitle: true,
//search icon
actions: [
IconButton(
icon: Icon(Icons.search),
onPressed: () {
//i want to change the text of the app bar:"Home" to a TextField to type
AppBar(
title: TextField(
style: TextStyle(color: Colors.white),
decoration: InputDecoration(
hintText: 'Search Courses',
hintStyle: TextStyle(color: Colors.white)),
controller: searchController,
),
);
},
),
],
),
2
Answers
I think you want something like this:
You can use a boolean variable that tells is searching or not.