Вот пример того, чего я хочу достичь:
bool showHorizontalBar = false;
Widget buildBarItem(IconData icon) {
return Container(
width: 100.0,
margin: EdgeInsets.all(4.0),
color: Colors.white,
child: Icon(icon),
);
}
Widget buildBar() {
return SizedBox(
height: 50.0,
child: ListView(
scrollDirection: Axis.horizontal,
children: <Widget>[
buildBarItem(Icons.directions_car),
buildBarItem(Icons.directions_bike),
buildBarItem(Icons.directions_bus),
buildBarItem(Icons.directions_run),
buildBarItem(Icons.directions_railway),
],
),
);
}
Widget buildMenuIcon() {
return IconButton(
icon: Icon(showHorizontalBar ? Icons.close : Icons.menu),
onPressed: () {
setState(() {
showHorizontalBar = !showHorizontalBar;
});
},
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Stack(
children: <Widget>[
showHorizontalBar ? buildBar() : SizedBox.shrink(),
Align(
alignment: Alignment.topRight,
child: buildMenuIcon(),
)
],
),
),
);
}