I want to show a SnackBar Widget when the bottom tab is clicked. I am trying to show it as:
Scaffold.of(context).showSnackBar(new SnackBar(
cont
Unfortunately I am not able to upgrade my Flutter version at the moment, However, from what I understand, you are trying to show a SnackBar
only when Live Icon
is pressed.
So you may want to make the Live Icon
into an IconButton
instead and use its onPressed
property on its own instead of using the onTap
property of the BottomNavigationBar
, then wrap the IconButton
within a Builder
, something similar to the following:
new BottomNavigationBar(
labels: [
new DestinationLabel(title: new Text("Live"),
icon: new Builder(builder: (BuildContext context) {
return new IconButton(icon: new Icon(Icons.live_tv),
onPressed: () {
Scaffold.of(context).showSnackBar(
new SnackBar(content: new Text("Live Clicked")));
});
}),
),
new DestinationLabel(icon: new Icon(Icons.date_range),
title: new Text("Matches"),)
],
)
I am not sure if this is the best practice, our Flutter gurus here always suggest to compose the more complex widgets from multiple classes.