Skip to content

Instantly share code, notes, and snippets.

@mhassanist
Created February 10, 2019 08:47
Show Gist options
  • Save mhassanist/5b03010b8fcb8309c98a4798ae9853dc to your computer and use it in GitHub Desktop.
Save mhassanist/5b03010b8fcb8309c98a4798ae9853dc to your computer and use it in GitHub Desktop.
Show Snackbar by clicking on a button
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