Unverified Commit 5b0de6d6 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Update templates (#23698)

Removes some `new`s and other minor cleanup.
parent 3449edf2
...@@ -14,7 +14,7 @@ import 'package:{{projectName}}/main.dart'; ...@@ -14,7 +14,7 @@ import 'package:{{projectName}}/main.dart';
void main() { void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async { testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame. // Build our app and trigger a frame.
await tester.pumpWidget(new MyApp()); await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0. // Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget); expect(find.text('0'), findsOneWidget);
...@@ -34,15 +34,16 @@ void main() { ...@@ -34,15 +34,16 @@ void main() {
void main() { void main() {
testWidgets('Verify Platform version', (WidgetTester tester) async { testWidgets('Verify Platform version', (WidgetTester tester) async {
// Build our app and trigger a frame. // Build our app and trigger a frame.
await tester.pumpWidget(new MyApp()); await tester.pumpWidget(MyApp());
// Verify that platform version is retrieved. // Verify that platform version is retrieved.
expect( expect(
find.byWidgetPredicate( find.byWidgetPredicate(
(Widget widget) => (Widget widget) => widget is Text &&
widget is Text && widget.data.startsWith('Running on:'), widget.data.startsWith('Running on:'),
), ),
findsOneWidget); findsOneWidget,
);
}); });
} }
{{/withPluginHook}} {{/withPluginHook}}
...@@ -10,14 +10,14 @@ import 'package:{{pluginProjectName}}/{{pluginProjectName}}.dart'; ...@@ -10,14 +10,14 @@ import 'package:{{pluginProjectName}}/{{pluginProjectName}}.dart';
{{/withPluginHook}} {{/withPluginHook}}
{{^withDriverTest}} {{^withDriverTest}}
void main() => runApp(new MyApp()); void main() => runApp(MyApp());
{{/withDriverTest}} {{/withDriverTest}}
{{#withDriverTest}} {{#withDriverTest}}
void main() { void main() {
// Enable integration testing with the Flutter Driver extension. // Enable integration testing with the Flutter Driver extension.
// See https://flutter.io/testing/ for more info. // See https://flutter.io/testing/ for more info.
enableFlutterDriverExtension(); enableFlutterDriverExtension();
runApp(new MyApp()); runApp(MyApp());
} }
{{/withDriverTest}} {{/withDriverTest}}
...@@ -26,9 +26,9 @@ class MyApp extends StatelessWidget { ...@@ -26,9 +26,9 @@ class MyApp extends StatelessWidget {
// This widget is the root of your application. // This widget is the root of your application.
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new MaterialApp( return MaterialApp(
title: 'Flutter Demo', title: 'Flutter Demo',
theme: new ThemeData( theme: ThemeData(
// This is the theme of your application. // This is the theme of your application.
// //
// Try running your application with "flutter run". You'll see the // Try running your application with "flutter run". You'll see the
...@@ -39,7 +39,7 @@ class MyApp extends StatelessWidget { ...@@ -39,7 +39,7 @@ class MyApp extends StatelessWidget {
// counter didn't reset back to zero; the application is not restarted. // counter didn't reset back to zero; the application is not restarted.
primarySwatch: Colors.blue, primarySwatch: Colors.blue,
), ),
home: new MyHomePage(title: 'Flutter Demo Home Page'), home: MyHomePage(title: 'Flutter Demo Home Page'),
); );
} }
} }
...@@ -59,7 +59,7 @@ class MyHomePage extends StatefulWidget { ...@@ -59,7 +59,7 @@ class MyHomePage extends StatefulWidget {
final String title; final String title;
@override @override
_MyHomePageState createState() => new _MyHomePageState(); _MyHomePageState createState() => _MyHomePageState();
} }
class _MyHomePageState extends State<MyHomePage> { class _MyHomePageState extends State<MyHomePage> {
...@@ -84,16 +84,16 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -84,16 +84,16 @@ class _MyHomePageState extends State<MyHomePage> {
// The Flutter framework has been optimized to make rerunning build methods // The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather // fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets. // than having to individually change instances of widgets.
return new Scaffold( return Scaffold(
appBar: new AppBar( appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by // Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title. // the App.build method, and use it to set our appbar title.
title: new Text(widget.title), title: Text(widget.title),
), ),
body: new Center( body: Center(
// Center is a layout widget. It takes a single child and positions it // Center is a layout widget. It takes a single child and positions it
// in the middle of the parent. // in the middle of the parent.
child: new Column( child: Column(
// Column is also layout widget. It takes a list of children and // Column is also layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its // arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent. // children horizontally, and tries to be as tall as its parent.
...@@ -109,20 +109,20 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -109,20 +109,20 @@ class _MyHomePageState extends State<MyHomePage> {
// horizontal). // horizontal).
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
new Text( Text(
'You have pushed the button this many times:', 'You have pushed the button this many times:',
), ),
new Text( Text(
'$_counter', '$_counter',
style: Theme.of(context).textTheme.display1, style: Theme.of(context).textTheme.display1,
), ),
], ],
), ),
), ),
floatingActionButton: new FloatingActionButton( floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter, onPressed: _incrementCounter,
tooltip: 'Increment', tooltip: 'Increment',
child: new Icon(Icons.add), child: Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods. ), // This trailing comma makes auto-formatting nicer for build methods.
); );
} }
...@@ -131,7 +131,7 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -131,7 +131,7 @@ class _MyHomePageState extends State<MyHomePage> {
{{#withPluginHook}} {{#withPluginHook}}
class MyApp extends StatefulWidget { class MyApp extends StatefulWidget {
@override @override
_MyAppState createState() => new _MyAppState(); _MyAppState createState() => _MyAppState();
} }
class _MyAppState extends State<MyApp> { class _MyAppState extends State<MyApp> {
...@@ -165,13 +165,13 @@ class _MyAppState extends State<MyApp> { ...@@ -165,13 +165,13 @@ class _MyAppState extends State<MyApp> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new MaterialApp( return MaterialApp(
home: new Scaffold( home: Scaffold(
appBar: new AppBar( appBar: AppBar(
title: const Text('Plugin example app'), title: const Text('Plugin example app'),
), ),
body: new Center( body: Center(
child: new Text('Running on: $_platformVersion\n'), child: Text('Running on: $_platformVersion\n'),
), ),
), ),
); );
......
...@@ -14,7 +14,7 @@ import 'package:{{projectName}}/main.dart'; ...@@ -14,7 +14,7 @@ import 'package:{{projectName}}/main.dart';
void main() { void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async { testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame. // Build our app and trigger a frame.
await tester.pumpWidget(new MyApp()); await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0. // Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget); expect(find.text('0'), findsOneWidget);
...@@ -34,15 +34,16 @@ void main() { ...@@ -34,15 +34,16 @@ void main() {
void main() { void main() {
testWidgets('Verify Platform version', (WidgetTester tester) async { testWidgets('Verify Platform version', (WidgetTester tester) async {
// Build our app and trigger a frame. // Build our app and trigger a frame.
await tester.pumpWidget(new MyApp()); await tester.pumpWidget(MyApp());
// Verify that platform version is retrieved. // Verify that platform version is retrieved.
expect( expect(
find.byWidgetPredicate( find.byWidgetPredicate(
(Widget widget) => (Widget widget) => widget is Text &&
widget is Text && widget.data.startsWith('Running on:'), widget.data.startsWith('Running on:'),
), ),
findsOneWidget); findsOneWidget,
);
}); });
} }
{{/withPluginHook}} {{/withPluginHook}}
...@@ -4,7 +4,7 @@ import 'package:{{projectName}}/{{projectName}}.dart'; ...@@ -4,7 +4,7 @@ import 'package:{{projectName}}/{{projectName}}.dart';
void main() { void main() {
test('adds one to input values', () { test('adds one to input values', () {
final calculator = new Calculator(); final calculator = Calculator();
expect(calculator.addOne(2), 3); expect(calculator.addOne(2), 3);
expect(calculator.addOne(-7), -6); expect(calculator.addOne(-7), -6);
expect(calculator.addOne(0), 1); expect(calculator.addOne(0), 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment