Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // SearchForm Implementation
- class _SearchBar extends StatefulWidget {
- final GithubSearchBloc githubSearchBloc;
- _SearchBar({Key key, this.githubSearchBloc}) : super(key: key);
- @override
- State<_SearchBar> createState() => _SearchBarState();
- }
- class _SearchBarState extends State<_SearchBar> {
- final _textController = TextEditingController();
- GithubSearchBloc get githubSearchBloc => widget.githubSearchBloc;
- @override
- Widget build(BuildContext context) {
- return TextField(
- controller: _textController,
- autocorrect: false,
- onChanged: (text) {
- githubSearchBloc.dispatch(
- TextChanged(text: text),
- );
- },
- decoration: InputDecoration(
- prefixIcon: Icon(Icons.search),
- suffixIcon: GestureDetector(
- child: Icon(Icons.clear),
- onTap: _onClearTapped,
- ),
- border: InputBorder.none,
- hintText: 'Enter a search term',
- ),
- );
- }
- void _onClearTapped() {
- _textController.text = '';
- githubSearchBloc.dispatch(TextChanged(text: ''));
- }
- }
Add Comment
Please, Sign In to add comment