Commit 46a0ba72 authored by Brian Egan's avatar Brian Egan

Improve the example to support back button actions more appropriately on Android

parent dca29b23
...@@ -35,26 +35,40 @@ class FontAwesomeGalleryHomeState extends State<FontAwesomeGalleryHome> { ...@@ -35,26 +35,40 @@ class FontAwesomeGalleryHomeState extends State<FontAwesomeGalleryHome> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Scaffold( return new Scaffold(
appBar: new AppBar( appBar: new AppBar(
leading: isSearching
? new IconButton(
icon: new Icon(FontAwesomeIcons.arrowLeft),
onPressed: () => setState(() {
isSearching = false;
searchTerm = "";
}))
: null,
title: isSearching title: isSearching
? new TextField( ? new TextField(
onChanged: (text) => setState(() => searchTerm = text), onChanged: (text) => setState(() => searchTerm = text),
autofocus: true, autofocus: true,
style: new TextStyle(fontSize: 18.0), style: new TextStyle(fontSize: 18.0),
decoration: new InputDecoration(hideDivider: true),
) )
: new Text("Font Awesome Flutter Gallery"), : new Text("Font Awesome Flutter Gallery"),
actions: isSearching actions: isSearching
? [ ? null
new IconButton(
icon: new Icon(FontAwesomeIcons.timesCircle),
onPressed: () => setState(() {
isSearching = false;
searchTerm = "";
}))
]
: [ : [
new IconButton( new IconButton(
icon: new Icon(FontAwesomeIcons.search), icon: new Icon(FontAwesomeIcons.search),
onPressed: () => setState(() => isSearching = true)) onPressed: () {
ModalRoute.of(context).addLocalHistoryEntry(
new LocalHistoryEntry(onRemove: () {
setState(() {
searchTerm = "";
isSearching = false;
});
}));
setState(() {
isSearching = true;
});
})
], ],
), ),
body: new GridView.count( body: new GridView.count(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment