mirror of
https://github.com/nisrulz/flutter-examples.git
synced 2025-11-08 12:39:17 +00:00
🚧 remove new keyword to get inline with dart 2 code standard.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void main() {
|
||||
runApp(new MaterialApp(
|
||||
home: new MyApp(),
|
||||
runApp(MaterialApp(
|
||||
home: MyApp(),
|
||||
// Define the theme, set the primary swatch
|
||||
theme: new ThemeData(primarySwatch: Colors.green),
|
||||
theme: ThemeData(primarySwatch: Colors.green),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -15,53 +15,53 @@ class MyApp extends StatelessWidget {
|
||||
final double myTextSize = 30.0;
|
||||
final double myIconSize = 40.0;
|
||||
final TextStyle myTextStyle =
|
||||
new TextStyle(color: Colors.grey, fontSize: myTextSize);
|
||||
TextStyle(color: Colors.grey, fontSize: myTextSize);
|
||||
|
||||
var column = new Column(
|
||||
var column = Column(
|
||||
// Makes the cards stretch in horizontal axis
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
// Setup the card
|
||||
new MyCard(
|
||||
MyCard(
|
||||
// Setup the text
|
||||
title: new Text(
|
||||
title: Text(
|
||||
"Favorite",
|
||||
style: myTextStyle,
|
||||
),
|
||||
// Setup the icon
|
||||
icon:
|
||||
new Icon(Icons.favorite, size: myIconSize, color: Colors.red)),
|
||||
new MyCard(
|
||||
title: new Text(
|
||||
Icon(Icons.favorite, size: myIconSize, color: Colors.red)),
|
||||
MyCard(
|
||||
title: Text(
|
||||
"Alarm",
|
||||
style: myTextStyle,
|
||||
),
|
||||
icon: new Icon(Icons.alarm, size: myIconSize, color: Colors.blue)),
|
||||
new MyCard(
|
||||
title: new Text(
|
||||
icon: Icon(Icons.alarm, size: myIconSize, color: Colors.blue)),
|
||||
MyCard(
|
||||
title: Text(
|
||||
"Airport Shuttle",
|
||||
style: myTextStyle,
|
||||
),
|
||||
icon: new Icon(Icons.airport_shuttle,
|
||||
icon: Icon(Icons.airport_shuttle,
|
||||
size: myIconSize, color: Colors.amber)),
|
||||
new MyCard(
|
||||
title: new Text(
|
||||
MyCard(
|
||||
title: Text(
|
||||
"Done",
|
||||
style: myTextStyle,
|
||||
),
|
||||
icon: new Icon(Icons.done, size: myIconSize, color: Colors.green)),
|
||||
icon: Icon(Icons.done, size: myIconSize, color: Colors.green)),
|
||||
],
|
||||
);
|
||||
|
||||
return new Scaffold(
|
||||
appBar: new AppBar(
|
||||
title: new Text("Stateless Widget"),
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Stateless Widget"),
|
||||
),
|
||||
body: new Container(
|
||||
body: Container(
|
||||
// Sets the padding in the main container
|
||||
padding: const EdgeInsets.only(bottom: 2.0),
|
||||
child: new Center(
|
||||
child: new SingleChildScrollView(child: column),
|
||||
child: Center(
|
||||
child: SingleChildScrollView(child: column),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -74,17 +74,17 @@ class MyCard extends StatelessWidget {
|
||||
final Widget icon;
|
||||
final Widget title;
|
||||
|
||||
// Constructor. {} here denote that they are optional values i.e you can use as: new MyCard()
|
||||
// Constructor. {} here denote that they are optional values i.e you can use as: MyCard()
|
||||
MyCard({this.title, this.icon});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Container(
|
||||
return Container(
|
||||
padding: const EdgeInsets.only(bottom: 1.0),
|
||||
child: new Card(
|
||||
child: new Container(
|
||||
child: Card(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(20.0),
|
||||
child: new Column(
|
||||
child: Column(
|
||||
children: <Widget>[this.title, this.icon],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -12,7 +12,7 @@ import '../lib/main.dart';
|
||||
void main() {
|
||||
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
||||
// Build our app and trigger a frame.
|
||||
await tester.pumpWidget(new MyApp());
|
||||
await tester.pumpWidget(MyApp());
|
||||
|
||||
// Verify that our counter starts at 0.
|
||||
expect(find.text('0'), findsOneWidget);
|
||||
|
||||
Reference in New Issue
Block a user