I want to display a simple disappearing error message above a button when certain conditions aren't met. It seems as if Flutter's Snackbar is well suited to this purpose.
However, I'm having difficulty changing the position of the Snackbar to be anything other than at the very bottom of the screen. Is this possible? If not, is there a Widget better suited for this purpose?
My current snackbar code:
class ContinueButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.only(
bottom: 24.0, top: 24.0),
child: Align(
alignment: FractionalOffset.bottomCenter,
child: MaterialButton(
onPressed: () {
final snackBar = SnackBar(
content: Text('Yay! A SnackBar!'),
);
Scaffold.of(context).showSnackBar(snackBar);
},
child: Text('Continue'),
height: 40.0,
minWidth: 300.0,
color: Colors.greenAccent,
),
),
);
}
}