diff --git a/packages/flutter_tools/templates/create/lib/main.dart.tmpl b/packages/flutter_tools/templates/create/lib/main.dart.tmpl index 605697b9221..f33f5e0b1b1 100644 --- a/packages/flutter_tools/templates/create/lib/main.dart.tmpl +++ b/packages/flutter_tools/templates/create/lib/main.dart.tmpl @@ -21,7 +21,7 @@ void main() { } class FlutterDemo extends StatefulWidget { - FlutterDemo({ Key key }) : super(key: key); + FlutterDemo({Key key}) : super(key: key); @override _FlutterDemoState createState() => new _FlutterDemoState(); @@ -43,7 +43,8 @@ class _FlutterDemoState extends State { title: new Text('Flutter Demo'), ), body: new Center( - child: new Text('Button tapped $_counter time${ _counter == 1 ? '' : 's' }.'), + child: new Text( + 'Button tapped $_counter time${ _counter == 1 ? '' : 's' }.'), ), floatingActionButton: new FloatingActionButton( onPressed: _incrementCounter, diff --git a/packages/flutter_tools/test/create_test.dart b/packages/flutter_tools/test/create_test.dart index df9bfb6adce..f9b472bba93 100644 --- a/packages/flutter_tools/test/create_test.dart +++ b/packages/flutter_tools/test/create_test.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'dart:async'; +import 'dart:convert'; import 'dart:io'; import 'package:args/command_runner.dart'; @@ -36,6 +37,37 @@ void main() { return _createAndAnalyzeProject(temp, ['--with-driver-test']); }); + // Verify content and formatting + testUsingContext('content', () async { + Cache.flutterRoot = '../..'; + + CreateCommand command = new CreateCommand(); + CommandRunner runner = createTestCommandRunner(command); + + int code = await runner.run(['create', '--no-pub', temp.path]); + expect(code, 0); + + void expectExists(String relPath) { + expect(FileSystemEntity.isFileSync('${temp.path}/$relPath'), true); + } + expectExists('lib/main.dart'); + for (FileSystemEntity file in temp.listSync(recursive: true)) { + if (file is File && file.path.endsWith('.dart')) { + String original= file.readAsStringSync(); + + Process process = await Process.start( + sdkBinaryName('dartfmt'), + [file.path], + workingDirectory: temp.path, + ); + String formatted = + await process.stdout.transform(UTF8.decoder).join(); + + expect(original, formatted, reason: file.path); + } + } + }); + // Verify that we can regenerate over an existing project. testUsingContext('can re-gen over existing project', () async { Cache.flutterRoot = '../..';