mirror of
https://github.com/nisrulz/flutter-examples.git
synced 2025-09-27 01:55:21 +08:00
🚧 remove new keyword to get inline with dart 2 code standard.
This commit is contained in:
@ -1,18 +1,18 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() {
|
||||
runApp(new MaterialApp(home: new ContactPage(), debugShowCheckedModeBanner: false,));
|
||||
runApp(MaterialApp(home: ContactPage(), debugShowCheckedModeBanner: false,));
|
||||
}
|
||||
|
||||
class ContactPage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
title: new Text("Using SnackBar"),
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Using SnackBar"),
|
||||
),
|
||||
body: new Center(
|
||||
child: new MyButton(),
|
||||
body: Center(
|
||||
child: MyButton(),
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -21,23 +21,23 @@ class ContactPage extends StatelessWidget {
|
||||
class MyButton extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new RaisedButton(
|
||||
child: new Text('Show SnackBar'),
|
||||
return RaisedButton(
|
||||
child: Text('Show SnackBar'),
|
||||
// On pressing the raised button
|
||||
onPressed: () {
|
||||
// show snackbar
|
||||
Scaffold.of(context).showSnackBar(new SnackBar(
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
// set content of snackbar
|
||||
content: new Text("Hello! I am SnackBar :)"),
|
||||
content: Text("Hello! I am SnackBar :)"),
|
||||
// set duration
|
||||
duration: new Duration(seconds: 3),
|
||||
duration: Duration(seconds: 3),
|
||||
// set the action
|
||||
action: new SnackBarAction(
|
||||
action: SnackBarAction(
|
||||
label: "Hit Me (Action)",
|
||||
onPressed: () {
|
||||
// When action button is pressed, show another snackbar
|
||||
Scaffold.of(context).showSnackBar(new SnackBar(
|
||||
content: new Text(
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
content: Text(
|
||||
"Hello! I am shown becoz you pressed Action :)"),
|
||||
));
|
||||
}),
|
||||
|
Reference in New Issue
Block a user