Last active
June 29, 2019 09:52
-
-
Save NishantDesai1306/db05ee055524db30af6855e56974b2c5 to your computer and use it in GitHub Desktop.
search bar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SearchBar extends StatefulWidget implements PreferredSizeWidget { | |
@override | |
Size get preferredSize => Size.fromHeight(56.0); | |
@override | |
_SearchBarState createState() => _SearchBarState(); | |
} | |
class _SearchBarState extends State<SearchBar> with SingleTickerProviderStateMixin { | |
String searchQuery = ''; | |
TextEditingController _searchFieldController = TextEditingController(); | |
@override | |
Widget build(BuildContext context) { | |
// to handle notches properly | |
return SafeArea( | |
top: true, | |
child: Container( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
Row( | |
crossAxisAlignment: CrossAxisAlignment.center, | |
children: <Widget>[ | |
IconButton( | |
icon: Icon(Icons.arrow_back, color: Colors.white), | |
), | |
Expanded( | |
child: TextField( | |
controller: _searchFieldController, | |
cursorColor: Colors.white, | |
style: TextStyle(color: Colors.white), | |
decoration: InputDecoration( | |
border: InputBorder.none, | |
prefixIcon: Icon(Icons.search, color: Colors.white), | |
hintText: "Search...", | |
hintStyle: TextStyle(color: Colors.white), | |
suffixIcon: InkWell( | |
child: Icon(Icons.close, color: Colors.white), | |
onTap: () {}, | |
), | |
), | |
), | |
) | |
], | |
), | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment