Created
February 10, 2019 08:47
-
-
Save mhassanist/5b03010b8fcb8309c98a4798ae9853dc to your computer and use it in GitHub Desktop.
Show Snackbar by clicking on a button
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:fluttertoast/fluttertoast.dart'; | |
void main() { | |
runApp(new MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter layout demo', | |
home: new Scaffold( | |
appBar: AppBar( | |
title: Text('Flutter layout demo'), | |
), | |
body: new Body(), | |
)); | |
} | |
} | |
class Body extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Center( | |
child: RaisedButton( | |
child: Text('Hello World'), | |
onPressed:() { | |
Scaffold.of(context).showSnackBar(new SnackBar( | |
content: new Text("Wait a second ..."), | |
)); | |
}), | |
); | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment