Add full flutter samples to API tests (#592)

diff --git a/test/common_server_api_test.dart b/test/common_server_api_test.dart
index bd4d1b0..badb672 100644
--- a/test/common_server_api_test.dart
+++ b/test/common_server_api_test.dart
@@ -51,6 +51,191 @@
 }
 ''';
 
+const counterApp = r'''
+// Copyright (c) 2019, the Dart project authors.  Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:flutter/material.dart';
+
+void main() => runApp(MyApp());
+
+class MyApp extends StatelessWidget {
+  @override
+  Widget build(BuildContext context) {
+    return MaterialApp(
+      title: 'Flutter Demo',
+      debugShowCheckedModeBanner: false,
+      theme: ThemeData(
+        primarySwatch: Colors.blue,
+      ),
+      home: MyHomePage(title: 'Flutter Demo Home Page'),
+    );
+  }
+}
+
+class MyHomePage extends StatefulWidget {
+  MyHomePage({Key key, this.title}) : super(key: key);
+
+  final String title;
+
+  @override
+  _MyHomePageState createState() => _MyHomePageState();
+}
+
+class _MyHomePageState extends State<MyHomePage> {
+  int _counter = 0;
+
+  void _incrementCounter() {
+    setState(() {
+      _counter++;
+    });
+  }
+
+  @override
+  Widget build(BuildContext context) {
+    return Scaffold(
+      appBar: AppBar(
+        title: Text(widget.title),
+      ),
+      body: Center(
+        child: Column(
+          mainAxisAlignment: MainAxisAlignment.center,
+          children: <Widget>[
+            Text(
+              'You have pushed the button this many times:',
+            ),
+            Text(
+              '$_counter',
+              style: Theme.of(context).textTheme.headline4,
+            ),
+          ],
+        ),
+      ),
+      floatingActionButton: FloatingActionButton(
+        onPressed: _incrementCounter,
+        tooltip: 'Increment',
+        child: Icon(Icons.add),
+      ),
+    );
+  }
+}
+''';
+
+const draggableAndPhysicsApp = '''
+import 'package:flutter/material.dart';
+import 'package:flutter/physics.dart';
+
+main() {
+  runApp(
+    MaterialApp(
+      debugShowCheckedModeBanner: false,
+      home: PhysicsCardDragDemo(),
+    ),
+  );
+}
+
+class PhysicsCardDragDemo extends StatelessWidget {
+  @override
+  Widget build(BuildContext context) {
+    return Scaffold(
+      appBar: AppBar(
+        title: Text('A draggable card!'),
+      ),
+      body: DraggableCard(
+        child: FlutterLogo(
+          size: 128,
+        ),
+      ),
+    );
+  }
+}
+
+class DraggableCard extends StatefulWidget {
+  final Widget child;
+  DraggableCard({this.child});
+
+  @override
+  _DraggableCardState createState() => _DraggableCardState();
+}
+
+class _DraggableCardState extends State<DraggableCard>
+    with SingleTickerProviderStateMixin {
+  AnimationController _controller;
+  Alignment _dragAlignment = Alignment.center;
+  Animation<Alignment> _animation;
+
+  void _runAnimation(Offset pixelsPerSecond, Size size) {
+    _animation = _controller.drive(
+      AlignmentTween(
+        begin: _dragAlignment,
+        end: Alignment.center,
+      ),
+    );
+
+    final unitsPerSecondX = pixelsPerSecond.dx / size.width;
+    final unitsPerSecondY = pixelsPerSecond.dy / size.height;
+    final unitsPerSecond = Offset(unitsPerSecondX, unitsPerSecondY);
+    final unitVelocity = unitsPerSecond.distance;
+
+    const spring = SpringDescription(
+      mass: 30,
+      stiffness: 1,
+      damping: 1,
+    );
+
+    final simulation = SpringSimulation(spring, 0, 1, -unitVelocity);
+
+    _controller.animateWith(simulation);
+  }
+
+  @override
+  void initState() {
+    super.initState();
+    _controller = AnimationController(vsync: this);
+
+    _controller.addListener(() {
+      setState(() {
+        _dragAlignment = _animation.value;
+      });
+    });
+  }
+
+  @override
+  void dispose() {
+    _controller.dispose();
+    super.dispose();
+  }
+
+  @override
+  Widget build(BuildContext context) {
+    final size = MediaQuery.of(context).size;
+    return GestureDetector(
+      onPanDown: (details) {
+        _controller.stop();
+      },
+      onPanUpdate: (details) {
+        setState(() {
+          _dragAlignment += Alignment(
+            details.delta.dx / (size.width / 2),
+            details.delta.dy / (size.height / 2),
+          );
+        });
+      },
+      onPanEnd: (details) {
+        _runAnimation(details.velocity.pixelsPerSecond, size);
+      },
+      child: Align(
+        alignment: _dragAlignment,
+        child: Card(
+          child: widget.child,
+        ),
+      ),
+    );
+  }
+}
+''';
+
 void main() => defineTests();
 
 void defineTests() {
@@ -150,6 +335,32 @@
       }
     });
 
+    test('analyze counterApp', () async {
+      for (final version in versions) {
+        final jsonData = {'source': counterApp};
+        final response =
+            await _sendPostRequest('dartservices/$version/analyze', jsonData);
+        expect(response.statusCode, 200);
+        final data = await response.transform(utf8.decoder).join();
+        expect(json.decode(data), {
+          'packageImports': ['flutter']
+        });
+      }
+    });
+
+    test('analyze draggableAndPhysicsApp', () async {
+      for (final version in versions) {
+        final jsonData = {'source': draggableAndPhysicsApp};
+        final response =
+            await _sendPostRequest('dartservices/$version/analyze', jsonData);
+        expect(response.statusCode, 200);
+        final data = await response.transform(utf8.decoder).join();
+        expect(json.decode(data), {
+          'packageImports': ['flutter']
+        });
+      }
+    });
+
     test('analyze errors', () async {
       for (final version in versions) {
         final jsonData = {'source': sampleCodeError};
diff --git a/test/flutter_analysis_server_test.dart b/test/flutter_analysis_server_test.dart
index 6e551c7..198cbc2 100644
--- a/test/flutter_analysis_server_test.dart
+++ b/test/flutter_analysis_server_test.dart
@@ -15,7 +15,7 @@
 import 'package:dart_services/src/sdk_manager.dart';
 import 'package:test/test.dart';
 
-const counter = r'''
+const counterApp = r'''
 // Copyright (c) 2019, the Dart project authors.  Please see the AUTHORS file
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
@@ -86,7 +86,7 @@
 }
 ''';
 
-const draggableAndPhysics = '''
+const draggableAndPhysicsApp = '''
 import 'package:flutter/material.dart';
 import 'package:flutter/physics.dart';
 
@@ -222,12 +222,12 @@
     });
 
     test('analyze counter app', () async {
-      final results = await analysisServer.analyze(counter);
+      final results = await analysisServer.analyze(counterApp);
       expect(results.issues, isEmpty);
     });
 
     test('analyze Draggable Physics sample', () async {
-      final results = await analysisServer.analyze(draggableAndPhysics);
+      final results = await analysisServer.analyze(draggableAndPhysicsApp);
       expect(results.issues, isEmpty);
     });
   });
@@ -258,12 +258,12 @@
     });
 
     test('analyze counter app', () async {
-      final results = await analysisServer.analyze(counter);
+      final results = await analysisServer.analyze(counterApp);
       expect(results.issues, isEmpty);
     });
 
     test('analyze Draggable Physics sample', () async {
-      final results = await analysisServer.analyze(draggableAndPhysics);
+      final results = await analysisServer.analyze(draggableAndPhysicsApp);
       expect(results.issues, isEmpty);
     });
   });
@@ -294,12 +294,13 @@
     });
 
     test('analyze counter app', () async {
-      final results = await flutterAnalysisServer.analyze(counter);
+      final results = await flutterAnalysisServer.analyze(counterApp);
       expect(results.issues, isEmpty);
     });
 
     test('analyze Draggable Physics sample', () async {
-      final results = await flutterAnalysisServer.analyze(draggableAndPhysics);
+      final results =
+          await flutterAnalysisServer.analyze(draggableAndPhysicsApp);
       expect(results.issues, isEmpty);
     });
   });
@@ -324,13 +325,13 @@
 
     test('counter app', () async {
       final results =
-          await commonServerImpl.analyze(SourceRequest()..source = counter);
+          await commonServerImpl.analyze(SourceRequest()..source = counterApp);
       expect(results.issues, isEmpty);
     });
 
     test('Draggable Physics sample', () async {
       final results = await commonServerImpl
-          .analyze(SourceRequest()..source = draggableAndPhysics);
+          .analyze(SourceRequest()..source = draggableAndPhysicsApp);
       expect(results.issues, isEmpty);
     });
   });