import 'package:flutter/material.dart';
void main() => runApp(new MaterialApp(
home: new ContactPage(),
));
class ContactPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Center(
child: new Text("Using SnackBar"),
)),
body: new Center(
child: new MyButton(),
),
);
}
}
class MyButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new RaisedButton(
child: new Text("Show SnackBar"),
onPressed: () {
Scaffold.of(context).showSnackBar(new SnackBar(
content: new Text("Hello! I am SnackBar:"),
duration: new Duration(seconds: 2),
action: new SnackBarAction(
label: "Hit Me",
onPressed: () {
Scaffold.of(context).showSnackBar(new SnackBar(
content:
new Text("Hello! I am shown becoz you pressed Action:"),
));
},
),
));
},
);
}
}
网友评论