diff --git a/dev/devicelab/bin/tasks/gradle_plugin_test.dart b/dev/devicelab/bin/tasks/gradle_plugin_test.dart index 8521314ea7..a2b2545732 100644 --- a/dev/devicelab/bin/tasks/gradle_plugin_test.dart +++ b/dev/devicelab/bin/tasks/gradle_plugin_test.dart @@ -281,8 +281,6 @@ Future _resultOfGradleTask({String workingDirectory, String task, } class _Dependencies { - String target; - Set dependencies; _Dependencies(String depfilePath) { final RegExp _separatorExpr = RegExp(r'([^\\]) '); final RegExp _escapeExpr = RegExp(r'\\(.)'); @@ -301,6 +299,9 @@ class _Dependencies { .where((String path) => path.isNotEmpty) .toSet(); } + + String target; + Set dependencies; } /// Returns [null] if target matches [expectedTarget], otherwise returns an error message. diff --git a/dev/devicelab/lib/framework/adb.dart b/dev/devicelab/lib/framework/adb.dart index 2ea21c8c4a..bcee6a4f35 100644 --- a/dev/devicelab/lib/framework/adb.dart +++ b/dev/devicelab/lib/framework/adb.dart @@ -100,6 +100,12 @@ abstract class Device { } class AndroidDeviceDiscovery implements DeviceDiscovery { + factory AndroidDeviceDiscovery() { + return _instance ??= AndroidDeviceDiscovery._(); + } + + AndroidDeviceDiscovery._(); + // Parses information about a device. Example: // // 015d172c98400a03 device usb:340787200X product:nakasi model:Nexus_7 device:grouper @@ -107,12 +113,6 @@ class AndroidDeviceDiscovery implements DeviceDiscovery { static AndroidDeviceDiscovery _instance; - factory AndroidDeviceDiscovery() { - return _instance ??= AndroidDeviceDiscovery._(); - } - - AndroidDeviceDiscovery._(); - AndroidDevice _workingDevice; @override @@ -349,15 +349,14 @@ class AndroidDevice implements Device { } class IosDeviceDiscovery implements DeviceDiscovery { - - static IosDeviceDiscovery _instance; - factory IosDeviceDiscovery() { return _instance ??= IosDeviceDiscovery._(); } IosDeviceDiscovery._(); + static IosDeviceDiscovery _instance; + IosDevice _workingDevice; @override diff --git a/dev/devicelab/lib/framework/framework.dart b/dev/devicelab/lib/framework/framework.dart index 7bc0b648e6..b3063a54e6 100644 --- a/dev/devicelab/lib/framework/framework.dart +++ b/dev/devicelab/lib/framework/framework.dart @@ -49,17 +49,6 @@ Future task(TaskFunction task) { } class _TaskRunner { - static final Logger logger = Logger('TaskRunner'); - - final TaskFunction task; - - // TODO(ianh): workaround for https://github.com/dart-lang/sdk/issues/23797 - RawReceivePort _keepAlivePort; - Timer _startTaskTimeout; - bool _taskStarted = false; - - final Completer _completer = Completer(); - _TaskRunner(this.task) { registerExtension('ext.cocoonRunTask', (String method, Map parameters) async { @@ -75,6 +64,17 @@ class _TaskRunner { }); } + final TaskFunction task; + + // TODO(ianh): workaround for https://github.com/dart-lang/sdk/issues/23797 + RawReceivePort _keepAlivePort; + Timer _startTaskTimeout; + bool _taskStarted = false; + + final Completer _completer = Completer(); + + static final Logger logger = Logger('TaskRunner'); + /// Signals that this task runner finished running the task. Future get whenDone => _completer.future; diff --git a/dev/devicelab/lib/tasks/plugin_tests.dart b/dev/devicelab/lib/tasks/plugin_tests.dart index e0bd265c76..3a70f733b0 100644 --- a/dev/devicelab/lib/tasks/plugin_tests.dart +++ b/dev/devicelab/lib/tasks/plugin_tests.dart @@ -26,11 +26,11 @@ TaskFunction combine(List tasks) { /// Defines task that creates new Flutter project, adds a plugin, and then /// builds the specified [buildTarget]. class PluginTest { + PluginTest(this.buildTarget, this.options); + final String buildTarget; final List options; - PluginTest(this.buildTarget, this.options); - Future call() async { section('Create Flutter project'); final Directory tempDir = Directory.systemTemp.createTempSync('flutter_devicelab_plugin_test.'); diff --git a/dev/integration_tests/channels/lib/src/pair.dart b/dev/integration_tests/channels/lib/src/pair.dart index 907d104d24..52dc3f2385 100644 --- a/dev/integration_tests/channels/lib/src/pair.dart +++ b/dev/integration_tests/channels/lib/src/pair.dart @@ -4,11 +4,11 @@ /// A pair of values. Used for testing custom codecs. class Pair { + Pair(this.left, this.right); + final dynamic left; final dynamic right; - Pair(this.left, this.right); - @override String toString() => 'Pair[$left, $right]'; } diff --git a/dev/integration_tests/channels/lib/src/test_step.dart b/dev/integration_tests/channels/lib/src/test_step.dart index 39caab24b8..3806ecf76e 100644 --- a/dev/integration_tests/channels/lib/src/test_step.dart +++ b/dev/integration_tests/channels/lib/src/test_step.dart @@ -25,13 +25,6 @@ const String nothing = '-'; /// - The Flutter app records the incoming reply echo. /// - The platform finally replies to the original message with another echo. class TestStepResult { - static const TextStyle bold = TextStyle(fontWeight: FontWeight.bold); - static const TestStepResult complete = TestStepResult( - 'Test complete', - nothing, - TestStatus.complete, - ); - const TestStepResult( this.name, this.description, @@ -71,6 +64,13 @@ class TestStepResult { final dynamic replyEcho; final dynamic error; + static const TextStyle bold = TextStyle(fontWeight: FontWeight.bold); + static const TestStepResult complete = TestStepResult( + 'Test complete', + nothing, + TestStatus.complete, + ); + Widget asWidget(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.start, diff --git a/dev/integration_tests/platform_interaction/lib/src/test_step.dart b/dev/integration_tests/platform_interaction/lib/src/test_step.dart index 1da476624d..48077d2a07 100644 --- a/dev/integration_tests/platform_interaction/lib/src/test_step.dart +++ b/dev/integration_tests/platform_interaction/lib/src/test_step.dart @@ -13,13 +13,6 @@ typedef TestStep = Future Function(); const String nothing = '-'; class TestStepResult { - static const TextStyle bold = TextStyle(fontWeight: FontWeight.bold); - static const TestStepResult complete = TestStepResult( - 'Test complete', - nothing, - TestStatus.complete, - ); - const TestStepResult(this.name, this.description, this.status); factory TestStepResult.fromSnapshot(AsyncSnapshot snapshot) { @@ -45,6 +38,13 @@ class TestStepResult { final String description; final TestStatus status; + static const TextStyle bold = TextStyle(fontWeight: FontWeight.bold); + static const TestStepResult complete = TestStepResult( + 'Test complete', + nothing, + TestStatus.complete, + ); + Widget asWidget(BuildContext context) { return Column( crossAxisAlignment: CrossAxisAlignment.start, diff --git a/examples/flutter_gallery/lib/demo/animation/widgets.dart b/examples/flutter_gallery/lib/demo/animation/widgets.dart index 6c82ec25fd..60583d3e62 100644 --- a/examples/flutter_gallery/lib/demo/animation/widgets.dart +++ b/examples/flutter_gallery/lib/demo/animation/widgets.dart @@ -47,19 +47,6 @@ class SectionCard extends StatelessWidget { // The title is rendered with two overlapping text widgets that are vertically // offset a little. It's supposed to look sort-of 3D. class SectionTitle extends StatelessWidget { - static const TextStyle sectionTitleStyle = TextStyle( - fontFamily: 'Raleway', - inherit: false, - fontSize: 24.0, - fontWeight: FontWeight.w500, - color: Colors.white, - textBaseline: TextBaseline.alphabetic, - ); - - static final TextStyle sectionTitleShadowStyle = sectionTitleStyle.copyWith( - color: const Color(0x19000000), - ); - const SectionTitle({ Key key, @required this.section, @@ -74,6 +61,19 @@ class SectionTitle extends StatelessWidget { final double scale; final double opacity; + static const TextStyle sectionTitleStyle = TextStyle( + fontFamily: 'Raleway', + inherit: false, + fontSize: 24.0, + fontWeight: FontWeight.w500, + color: Colors.white, + textBaseline: TextBaseline.alphabetic, + ); + + static final TextStyle sectionTitleShadowStyle = sectionTitleStyle.copyWith( + color: const Color(0x19000000), + ); + @override Widget build(BuildContext context) { return IgnorePointer( diff --git a/examples/flutter_gallery/lib/demo/colors_demo.dart b/examples/flutter_gallery/lib/demo/colors_demo.dart index 59a94274f8..9ac109e17e 100644 --- a/examples/flutter_gallery/lib/demo/colors_demo.dart +++ b/examples/flutter_gallery/lib/demo/colors_demo.dart @@ -83,9 +83,6 @@ class ColorItem extends StatelessWidget { } class PaletteTabView extends StatelessWidget { - static const List primaryKeys = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900]; - static const List accentKeys = [100, 200, 400, 700]; - PaletteTabView({ Key key, @required this.colors, @@ -94,6 +91,9 @@ class PaletteTabView extends StatelessWidget { final Palette colors; + static const List primaryKeys = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900]; + static const List accentKeys = [100, 200, 400, 700]; + @override Widget build(BuildContext context) { final TextTheme textTheme = Theme.of(context).textTheme; diff --git a/examples/flutter_gallery/lib/demo/pesto_demo.dart b/examples/flutter_gallery/lib/demo/pesto_demo.dart index 8683c33975..d738d8b844 100644 --- a/examples/flutter_gallery/lib/demo/pesto_demo.dart +++ b/examples/flutter_gallery/lib/demo/pesto_demo.dart @@ -432,14 +432,14 @@ class _RecipePageState extends State { /// Displays the recipe's name and instructions. class RecipeSheet extends StatelessWidget { + RecipeSheet({ Key key, this.recipe }) : super(key: key); + final TextStyle titleStyle = const PestoStyle(fontSize: 34.0); final TextStyle descriptionStyle = const PestoStyle(fontSize: 15.0, color: Colors.black54, height: 24.0/15.0); final TextStyle itemStyle = const PestoStyle(fontSize: 15.0, height: 24.0/15.0); final TextStyle itemAmountStyle = PestoStyle(fontSize: 15.0, color: _kTheme.primaryColor, height: 24.0/15.0); final TextStyle headingStyle = const PestoStyle(fontSize: 16.0, fontWeight: FontWeight.bold, height: 24.0/15.0); - RecipeSheet({ Key key, this.recipe }) : super(key: key); - final Recipe recipe; @override diff --git a/examples/flutter_gallery/lib/demo/video_demo.dart b/examples/flutter_gallery/lib/demo/video_demo.dart index 59bbc1cece..a100591ade 100644 --- a/examples/flutter_gallery/lib/demo/video_demo.dart +++ b/examples/flutter_gallery/lib/demo/video_demo.dart @@ -14,13 +14,13 @@ const String beeUri = 'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4'; class VideoCard extends StatelessWidget { + const VideoCard({Key key, this.controller, this.title, this.subtitle}) + : super(key: key); + final VideoPlayerController controller; final String title; final String subtitle; - const VideoCard({Key key, this.controller, this.title, this.subtitle}) - : super(key: key); - Widget _buildInlineVideo() { return Padding( padding: const EdgeInsets.symmetric(vertical: 10.0, horizontal: 30.0), @@ -93,10 +93,10 @@ class VideoCard extends StatelessWidget { } class VideoPlayerLoading extends StatefulWidget { - final VideoPlayerController controller; - const VideoPlayerLoading(this.controller); + final VideoPlayerController controller; + @override _VideoPlayerLoadingState createState() => _VideoPlayerLoadingState(); } @@ -137,18 +137,15 @@ class _VideoPlayerLoadingState extends State { } class VideoPlayPause extends StatefulWidget { - final VideoPlayerController controller; - const VideoPlayPause(this.controller); + final VideoPlayerController controller; + @override State createState() => _VideoPlayPauseState(); } class _VideoPlayPauseState extends State { - FadeAnimation imageFadeAnimation; - VoidCallback listener; - _VideoPlayPauseState() { listener = () { if (mounted) @@ -156,6 +153,9 @@ class _VideoPlayPauseState extends State { }; } + FadeAnimation imageFadeAnimation; + VoidCallback listener; + VideoPlayerController get controller => widget.controller; @override @@ -202,14 +202,14 @@ class _VideoPlayPauseState extends State { } class FadeAnimation extends StatefulWidget { - final Widget child; - final Duration duration; - const FadeAnimation({ this.child, this.duration = const Duration(milliseconds: 500), }); + final Widget child; + final Duration duration; + @override _FadeAnimationState createState() => _FadeAnimationState(); } @@ -265,16 +265,16 @@ class _FadeAnimationState extends State } class ConnectivityOverlay extends StatefulWidget { - final Widget child; - final Completer connectedCompleter; - final GlobalKey scaffoldKey; - const ConnectivityOverlay({ this.child, this.connectedCompleter, this.scaffoldKey, }); + final Widget child; + final Completer connectedCompleter; + final GlobalKey scaffoldKey; + @override _ConnectivityOverlayState createState() => _ConnectivityOverlayState(); } diff --git a/examples/flutter_gallery/lib/gallery/home.dart b/examples/flutter_gallery/lib/gallery/home.dart index 8d156f2070..13bc8bb078 100644 --- a/examples/flutter_gallery/lib/gallery/home.dart +++ b/examples/flutter_gallery/lib/gallery/home.dart @@ -268,10 +268,6 @@ class _DemosPage extends StatelessWidget { } class GalleryHome extends StatefulWidget { - // In checked mode our MaterialApp will show the default "debug" banner. - // Otherwise show the "preview" banner. - static bool showPreviewBanner = true; - const GalleryHome({ Key key, this.testMode = false, @@ -281,6 +277,10 @@ class GalleryHome extends StatefulWidget { final Widget optionsPage; final bool testMode; + // In checked mode our MaterialApp will show the default "debug" banner. + // Otherwise show the "preview" banner. + static bool showPreviewBanner = true; + @override _GalleryHomeState createState() => _GalleryHomeState(); } diff --git a/examples/layers/rendering/src/solid_color_box.dart b/examples/layers/rendering/src/solid_color_box.dart index 419d181273..9e4660d871 100644 --- a/examples/layers/rendering/src/solid_color_box.dart +++ b/examples/layers/rendering/src/solid_color_box.dart @@ -6,12 +6,12 @@ import 'package:flutter/rendering.dart'; import 'package:flutter/gestures.dart'; class RenderSolidColorBox extends RenderDecoratedBox { - final Size desiredSize; - final Color backgroundColor; - RenderSolidColorBox(this.backgroundColor, { this.desiredSize = Size.infinite }) : super(decoration: BoxDecoration(color: backgroundColor)); + final Size desiredSize; + final Color backgroundColor; + @override double computeMinIntrinsicWidth(double height) { return desiredSize.width == double.infinity ? 0.0 : desiredSize.width; diff --git a/examples/stocks/lib/stock_data.dart b/examples/stocks/lib/stock_data.dart index be28ad1efb..e8d98dbb07 100644 --- a/examples/stocks/lib/stock_data.dart +++ b/examples/stocks/lib/stock_data.dart @@ -16,12 +16,6 @@ import 'package:http/http.dart' as http; final math.Random _rng = math.Random(); class Stock { - String symbol; - String name; - double lastSale; - String marketCap; - double percentChange; - Stock(this.symbol, this.name, this.lastSale, this.marketCap, this.percentChange); Stock.fromFields(List fields) { @@ -36,6 +30,12 @@ class Stock { marketCap = fields[4]; percentChange = (_rng.nextDouble() * 20) - 10; } + + String symbol; + String name; + double lastSale; + String marketCap; + double percentChange; } class StockData extends ChangeNotifier { diff --git a/packages/flutter/lib/src/foundation/basic_types.dart b/packages/flutter/lib/src/foundation/basic_types.dart index dcc4faea40..f4dfe93477 100644 --- a/packages/flutter/lib/src/foundation/basic_types.dart +++ b/packages/flutter/lib/src/foundation/basic_types.dart @@ -77,10 +77,6 @@ const int kMaxUnsignedSMI = 0x3FFFFFFFFFFFFFFF; /// A BitField over an enum (or other class whose values implement "index"). /// Only the first 62 values of the enum can be used as indices. class BitField { - static const int _smiBits = 62; // see https://www.dartlang.org/articles/numeric-computation/#smis-and-mints - static const int _allZeros = 0; - static const int _allOnes = kMaxUnsignedSMI; // 2^(_kSMIBits+1)-1 - /// Creates a bit field of all zeros. /// /// The given length must be at most 62. @@ -101,6 +97,10 @@ class BitField { final int _length; int _bits; + static const int _smiBits = 62; // see https://www.dartlang.org/articles/numeric-computation/#smis-and-mints + static const int _allZeros = 0; + static const int _allOnes = kMaxUnsignedSMI; // 2^(_kSMIBits+1)-1 + /// Returns whether the bit with the given index is set to one. bool operator [](T index) { assert(index.index < _length); diff --git a/packages/flutter/lib/src/material/date_picker.dart b/packages/flutter/lib/src/material/date_picker.dart index 602b9bd90b..53b172cdf9 100644 --- a/packages/flutter/lib/src/material/date_picker.dart +++ b/packages/flutter/lib/src/material/date_picker.dart @@ -720,11 +720,11 @@ class _MonthPickerState extends State with SingleTickerProviderStat // Defines semantic traversal order of the top-level widgets inside the month // picker. class _MonthPickerSortKey extends OrdinalSortKey { + const _MonthPickerSortKey(double order) : super(order); + static const _MonthPickerSortKey previousMonth = _MonthPickerSortKey(1.0); static const _MonthPickerSortKey nextMonth = _MonthPickerSortKey(2.0); static const _MonthPickerSortKey calendar = _MonthPickerSortKey(3.0); - - const _MonthPickerSortKey(double order) : super(order); } /// A scrollable list of years to allow picking a year. diff --git a/packages/flutter/lib/src/material/ink_ripple.dart b/packages/flutter/lib/src/material/ink_ripple.dart index b42f90ece2..457eaf4762 100644 --- a/packages/flutter/lib/src/material/ink_ripple.dart +++ b/packages/flutter/lib/src/material/ink_ripple.dart @@ -92,13 +92,6 @@ class _InkRippleFactory extends InteractiveInkFeatureFactory { /// * [InkHighlight], which is an ink feature that emphasizes a part of a /// [Material]. class InkRipple extends InteractiveInkFeature { - /// Used to specify this type of ink splash for an [InkWell], [InkResponse] - /// or material [Theme]. - static const InteractiveInkFeatureFactory splashFactory = _InkRippleFactory(); - - static final Animatable _easeCurveTween = CurveTween(curve: Curves.ease); - static final Animatable _fadeOutIntervalTween = CurveTween(curve: const Interval(_kFadeOutIntervalStart, 1.0)); - /// Begin a ripple, centered at [position] relative to [referenceBox]. /// /// The [controller] argument is typically obtained via @@ -192,6 +185,13 @@ class InkRipple extends InteractiveInkFeature { Animation _fadeOut; AnimationController _fadeOutController; + /// Used to specify this type of ink splash for an [InkWell], [InkResponse] + /// or material [Theme]. + static const InteractiveInkFeatureFactory splashFactory = _InkRippleFactory(); + + static final Animatable _easeCurveTween = CurveTween(curve: Curves.ease); + static final Animatable _fadeOutIntervalTween = CurveTween(curve: const Interval(_kFadeOutIntervalStart, 1.0)); + @override void confirm() { _radiusController diff --git a/packages/flutter/lib/src/material/ink_splash.dart b/packages/flutter/lib/src/material/ink_splash.dart index 96482f8743..c65a38613f 100644 --- a/packages/flutter/lib/src/material/ink_splash.dart +++ b/packages/flutter/lib/src/material/ink_splash.dart @@ -96,10 +96,6 @@ class _InkSplashFactory extends InteractiveInkFeatureFactory { /// * [InkHighlight], which is an ink feature that emphasizes a part of a /// [Material]. class InkSplash extends InteractiveInkFeature { - /// Used to specify this type of ink splash for an [InkWell], [InkResponse] - /// or material [Theme]. - static const InteractiveInkFeatureFactory splashFactory = _InkSplashFactory(); - /// Begin a splash, centered at position relative to [referenceBox]. /// /// The [controller] argument is typically obtained via @@ -169,6 +165,10 @@ class InkSplash extends InteractiveInkFeature { Animation _alpha; AnimationController _alphaController; + /// Used to specify this type of ink splash for an [InkWell], [InkResponse] + /// or material [Theme]. + static const InteractiveInkFeatureFactory splashFactory = _InkSplashFactory(); + @override void confirm() { final int duration = (_targetRadius / _kSplashConfirmedVelocity).floor(); diff --git a/packages/flutter/lib/src/material/input_border.dart b/packages/flutter/lib/src/material/input_border.dart index 33d828bc5d..6709d16851 100644 --- a/packages/flutter/lib/src/material/input_border.dart +++ b/packages/flutter/lib/src/material/input_border.dart @@ -28,13 +28,6 @@ import 'package:flutter/widgets.dart'; /// rounded rectangle around the input decorator's container. /// * [InputDecoration], which is used to configure an [InputDecorator]. abstract class InputBorder extends ShapeBorder { - /// No input border. - /// - /// Use this value with [InputDecoration.border] to specify that no border - /// should be drawn. The [InputDecoration.shrinkWrap] constructor sets - /// its border to this value. - static const InputBorder none = _NoInputBorder(); - /// Creates a border for an [InputDecorator]. /// /// The [borderSide] parameter must not be null. Applications typically do @@ -45,6 +38,13 @@ abstract class InputBorder extends ShapeBorder { this.borderSide = BorderSide.none, }) : assert(borderSide != null); + /// No input border. + /// + /// Use this value with [InputDecoration.border] to specify that no border + /// should be drawn. The [InputDecoration.shrinkWrap] constructor sets + /// its border to this value. + static const InputBorder none = _NoInputBorder(); + /// Defines the border line's color and weight. /// /// The [InputDecorator] creates copies of its input border, using [copyWith], diff --git a/packages/flutter/lib/src/material/progress_indicator.dart b/packages/flutter/lib/src/material/progress_indicator.dart index 4c0480c3db..86bea891bf 100644 --- a/packages/flutter/lib/src/material/progress_indicator.dart +++ b/packages/flutter/lib/src/material/progress_indicator.dart @@ -69,6 +69,20 @@ abstract class ProgressIndicator extends StatefulWidget { } class _LinearProgressIndicatorPainter extends CustomPainter { + const _LinearProgressIndicatorPainter({ + this.backgroundColor, + this.valueColor, + this.value, + this.animationValue, + @required this.textDirection, + }) : assert(textDirection != null); + + final Color backgroundColor; + final Color valueColor; + final double value; + final double animationValue; + final TextDirection textDirection; + // The indeterminate progress animation displays two lines whose leading (head) // and trailing (tail) endpoints are defined by the following four curves. static const Curve line1Head = Interval( @@ -92,20 +106,6 @@ class _LinearProgressIndicatorPainter extends CustomPainter { curve: Cubic(0.10, 0.0, 0.45, 1.0), ); - const _LinearProgressIndicatorPainter({ - this.backgroundColor, - this.valueColor, - this.value, - this.animationValue, - @required this.textDirection, - }) : assert(textDirection != null); - - final Color backgroundColor; - final Color valueColor; - final double value; - final double animationValue; - final TextDirection textDirection; - @override void paint(Canvas canvas, Size size) { final Paint paint = Paint() @@ -254,12 +254,6 @@ class _LinearProgressIndicatorState extends State with } class _CircularProgressIndicatorPainter extends CustomPainter { - static const double _twoPi = math.pi * 2.0; - static const double _epsilon = .001; - // Canvas.drawArc(r, 0, 2*PI) doesn't draw anything, so just get close. - static const double _sweep = _twoPi - _epsilon; - static const double _startAngle = -math.pi / 2.0; - _CircularProgressIndicatorPainter({ this.valueColor, this.value, @@ -285,6 +279,12 @@ class _CircularProgressIndicatorPainter extends CustomPainter { final double arcStart; final double arcSweep; + static const double _twoPi = math.pi * 2.0; + static const double _epsilon = .001; + // Canvas.drawArc(r, 0, 2*PI) doesn't draw anything, so just get close. + static const double _sweep = _twoPi - _epsilon; + static const double _startAngle = -math.pi / 2.0; + @override void paint(Canvas canvas, Size size) { final Paint paint = Paint() diff --git a/packages/flutter/lib/src/material/time.dart b/packages/flutter/lib/src/material/time.dart index 11216a5ad0..2dbf8f8d61 100644 --- a/packages/flutter/lib/src/material/time.dart +++ b/packages/flutter/lib/src/material/time.dart @@ -30,15 +30,6 @@ enum DayPeriod { /// time zones. @immutable class TimeOfDay { - /// The number of hours in one day, i.e. 24. - static const int hoursPerDay = 24; - - /// The number of hours in one day period (see also [DayPeriod]), i.e. 12. - static const int hoursPerPeriod = 12; - - /// The number of minutes in one hour, i.e. 60. - static const int minutesPerHour = 60; - /// Creates a time of day. /// /// The [hour] argument must be between 0 and 23, inclusive. The [minute] @@ -57,6 +48,15 @@ class TimeOfDay { /// current minute in the local time zone. factory TimeOfDay.now() { return TimeOfDay.fromDateTime(DateTime.now()); } + /// The number of hours in one day, i.e. 24. + static const int hoursPerDay = 24; + + /// The number of hours in one day period (see also [DayPeriod]), i.e. 12. + static const int hoursPerPeriod = 12; + + /// The number of minutes in one hour, i.e. 60. + static const int minutesPerHour = 60; + /// Returns a new TimeOfDay with the hour and/or minute replaced. TimeOfDay replacing({ int hour, int minute }) { assert(hour == null || (hour >= 0 && hour < hoursPerDay)); diff --git a/packages/flutter/lib/src/rendering/box.dart b/packages/flutter/lib/src/rendering/box.dart index a3dac1a311..c6d699d6db 100644 --- a/packages/flutter/lib/src/rendering/box.dart +++ b/packages/flutter/lib/src/rendering/box.dart @@ -92,22 +92,6 @@ class BoxConstraints extends Constraints { this.maxHeight = double.infinity }); - /// The minimum width that satisfies the constraints. - final double minWidth; - - /// The maximum width that satisfies the constraints. - /// - /// Might be [double.infinity]. - final double maxWidth; - - /// The minimum height that satisfies the constraints. - final double minHeight; - - /// The maximum height that satisfies the constraints. - /// - /// Might be [double.infinity]. - final double maxHeight; - /// Creates box constraints that is respected only by the given size. BoxConstraints.tight(Size size) : minWidth = size.width, @@ -164,6 +148,22 @@ class BoxConstraints extends Constraints { minHeight = height != null ? height : double.infinity, maxHeight = height != null ? height : double.infinity; + /// The minimum width that satisfies the constraints. + final double minWidth; + + /// The maximum width that satisfies the constraints. + /// + /// Might be [double.infinity]. + final double maxWidth; + + /// The minimum height that satisfies the constraints. + final double minHeight; + + /// The maximum height that satisfies the constraints. + /// + /// Might be [double.infinity]. + final double maxHeight; + /// Creates a copy of this box constraints but with the given fields replaced with the new values. BoxConstraints copyWith({ double minWidth, diff --git a/packages/flutter/lib/src/services/message_codecs.dart b/packages/flutter/lib/src/services/message_codecs.dart index 88ed29e613..1492c2ce3b 100644 --- a/packages/flutter/lib/src/services/message_codecs.dart +++ b/packages/flutter/lib/src/services/message_codecs.dart @@ -212,6 +212,9 @@ class JSONMethodCodec implements MethodCodec { /// The codec is extensible by subclasses overriding [writeValue] and /// [readValueOfType]. class StandardMessageCodec implements MessageCodec { + /// Creates a [MessageCodec] using the Flutter standard binary encoding. + const StandardMessageCodec(); + // The codec serializes messages as outlined below. This format must // match the Android and iOS counterparts. // @@ -264,9 +267,6 @@ class StandardMessageCodec implements MessageCodec { static const int _valueList = 12; static const int _valueMap = 13; - /// Creates a [MessageCodec] using the Flutter standard binary encoding. - const StandardMessageCodec(); - @override ByteData encodeMessage(dynamic message) { if (message == null) diff --git a/packages/flutter/lib/src/services/platform_views.dart b/packages/flutter/lib/src/services/platform_views.dart index 0efb9c4bc8..b32f182fe6 100644 --- a/packages/flutter/lib/src/services/platform_views.dart +++ b/packages/flutter/lib/src/services/platform_views.dart @@ -97,21 +97,6 @@ class PlatformViewsService { /// /// A Dart version of Android's [MotionEvent.PointerProperties](https://developer.android.com/reference/android/view/MotionEvent.PointerProperties). class AndroidPointerProperties { - /// Value for `toolType` when the tool type is unknown. - static const int kToolTypeUnknown = 0; - - /// Value for `toolType` when the tool type is a finger. - static const int kToolTypeFinger = 1; - - /// Value for `toolType` when the tool type is a stylus. - static const int kToolTypeStylus = 2; - - /// Value for `toolType` when the tool type is a mouse. - static const int kToolTypeMouse = 3; - - /// Value for `toolType` when the tool type is an eraser. - static const int kToolTypeEraser = 4; - /// Creates an AndroidPointerProperties. /// /// All parameters must not be null. @@ -128,6 +113,21 @@ class AndroidPointerProperties { /// See Android's [MotionEvent.PointerProperties#toolType](https://developer.android.com/reference/android/view/MotionEvent.PointerProperties.html#toolType). final int toolType; + /// Value for `toolType` when the tool type is unknown. + static const int kToolTypeUnknown = 0; + + /// Value for `toolType` when the tool type is a finger. + static const int kToolTypeFinger = 1; + + /// Value for `toolType` when the tool type is a stylus. + static const int kToolTypeStylus = 2; + + /// Value for `toolType` when the tool type is a mouse. + static const int kToolTypeMouse = 3; + + /// Value for `toolType` when the tool type is an eraser. + static const int kToolTypeEraser = 4; + List _asList() => [id, toolType]; @override diff --git a/packages/flutter/lib/src/services/system_chrome.dart b/packages/flutter/lib/src/services/system_chrome.dart index d3e2f12210..1bafea4388 100644 --- a/packages/flutter/lib/src/services/system_chrome.dart +++ b/packages/flutter/lib/src/services/system_chrome.dart @@ -97,28 +97,6 @@ enum Brightness { /// /// Used by [SystemChrome.setSystemUIOverlayStyle]. class SystemUiOverlayStyle { - /// System overlays should be drawn with a light color. Intended for - /// applications with a dark background. - static const SystemUiOverlayStyle light = SystemUiOverlayStyle( - systemNavigationBarColor: Color(0xFF000000), - systemNavigationBarDividerColor: null, - statusBarColor: null, - systemNavigationBarIconBrightness: Brightness.light, - statusBarIconBrightness: Brightness.light, - statusBarBrightness: Brightness.dark, - ); - - /// System overlays should be drawn with a dark color. Intended for - /// applications with a light background. - static const SystemUiOverlayStyle dark = SystemUiOverlayStyle( - systemNavigationBarColor: Color(0xFF000000), - systemNavigationBarDividerColor: null, - statusBarColor: null, - systemNavigationBarIconBrightness: Brightness.light, - statusBarIconBrightness: Brightness.dark, - statusBarBrightness: Brightness.light, - ); - /// Creates a new [SystemUiOverlayStyle]. const SystemUiOverlayStyle({ this.systemNavigationBarColor, @@ -159,6 +137,28 @@ class SystemUiOverlayStyle { /// Only honored in Android version M and greater. final Brightness statusBarIconBrightness; + /// System overlays should be drawn with a light color. Intended for + /// applications with a dark background. + static const SystemUiOverlayStyle light = SystemUiOverlayStyle( + systemNavigationBarColor: Color(0xFF000000), + systemNavigationBarDividerColor: null, + statusBarColor: null, + systemNavigationBarIconBrightness: Brightness.light, + statusBarIconBrightness: Brightness.light, + statusBarBrightness: Brightness.dark, + ); + + /// System overlays should be drawn with a dark color. Intended for + /// applications with a light background. + static const SystemUiOverlayStyle dark = SystemUiOverlayStyle( + systemNavigationBarColor: Color(0xFF000000), + systemNavigationBarDividerColor: null, + statusBarColor: null, + systemNavigationBarIconBrightness: Brightness.light, + statusBarIconBrightness: Brightness.dark, + statusBarBrightness: Brightness.light, + ); + /// Convert this event to a map for serialization. Map _toMap() { return { diff --git a/packages/flutter/lib/src/services/text_input.dart b/packages/flutter/lib/src/services/text_input.dart index 13c4d16cba..36b7d81a45 100644 --- a/packages/flutter/lib/src/services/text_input.dart +++ b/packages/flutter/lib/src/services/text_input.dart @@ -698,6 +698,8 @@ final _TextInputClientHandler _clientHandler = _TextInputClientHandler(); /// An interface to the system's text input control. class TextInput { + TextInput._(); + static const List _androidSupportedInputActions = [ TextInputAction.none, TextInputAction.unspecified, @@ -724,8 +726,6 @@ class TextInput { TextInputAction.emergencyCall, ]; - TextInput._(); - /// Begin interacting with the text input control. /// /// Calling this function helps multiple clients coordinate about which one is diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index 24c0d8f76a..29d1ee5d99 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -5564,17 +5564,17 @@ class KeyedSubtree extends StatelessWidget { }) : assert(child != null), super(key: key); - /// The widget below this widget in the tree. - /// - /// {@macro flutter.widgets.child} - final Widget child; - /// Creates a KeyedSubtree for child with a key that's based on the child's existing key or childIndex. factory KeyedSubtree.wrap(Widget child, int childIndex) { final Key key = child.key != null ? ValueKey(child.key) : ValueKey(childIndex); return KeyedSubtree(key: key, child: child); } + /// The widget below this widget in the tree. + /// + /// {@macro flutter.widgets.child} + final Widget child; + /// Wrap each item in a KeyedSubtree whose key is based on the item's existing key or /// the sum of its list index and `baseIndex`. static List ensureUniqueKeysForList(Iterable items, { int baseIndex = 0 }) { diff --git a/packages/flutter/lib/src/widgets/widget_inspector.dart b/packages/flutter/lib/src/widgets/widget_inspector.dart index 941de322b3..0df0634aab 100644 --- a/packages/flutter/lib/src/widgets/widget_inspector.dart +++ b/packages/flutter/lib/src/widgets/widget_inspector.dart @@ -49,10 +49,10 @@ typedef _RegisterServiceExtensionCallback = void Function({ /// A proxy layer is used for cases where a layer needs to be placed into /// multiple trees of layers. class _ProxyLayer extends Layer { - final Layer _layer; - _ProxyLayer(this._layer); + final Layer _layer; + @override void addToScene(ui.SceneBuilder builder, [Offset layerOffset = Offset.zero]) { _layer.addToScene(builder, layerOffset); @@ -66,9 +66,6 @@ class _ProxyLayer extends Layer { /// secondary screenshot canvas so that a screenshot can be recorded at the same /// time as performing a normal paint. class _MulticastCanvas implements Canvas { - final Canvas _main; - final Canvas _screenshot; - _MulticastCanvas({ @required Canvas main, @required Canvas screenshot, @@ -77,6 +74,9 @@ class _MulticastCanvas implements Canvas { _main = main, _screenshot = screenshot; + final Canvas _main; + final Canvas _screenshot; + @override void clipPath(Path path, {bool doAntiAlias = true}) { _main.clipPath(path, doAntiAlias: doAntiAlias); diff --git a/packages/flutter/test/material/time_picker_test.dart b/packages/flutter/test/material/time_picker_test.dart index f3b79e54ad..daca36d98e 100644 --- a/packages/flutter/test/material/time_picker_test.dart +++ b/packages/flutter/test/material/time_picker_test.dart @@ -513,13 +513,13 @@ final Finder findDialPaint = find.descendant( ); class _SemanticsNodeExpectation { + _SemanticsNodeExpectation(this.label, this.left, this.top, this.right, this.bottom); + final String label; final double left; final double top; final double right; final double bottom; - - _SemanticsNodeExpectation(this.label, this.left, this.top, this.right, this.bottom); } class _CustomPainterSemanticsTester { diff --git a/packages/flutter/test/painting/fake_codec.dart b/packages/flutter/test/painting/fake_codec.dart index 3ea014bb82..17e433dcb4 100644 --- a/packages/flutter/test/painting/fake_codec.dart +++ b/packages/flutter/test/painting/fake_codec.dart @@ -14,13 +14,13 @@ import 'package:flutter/foundation.dart'; /// This is useful for running in the test Zone, where it is tricky to receive /// callbacks originating from the IO thread. class FakeCodec implements ui.Codec { + FakeCodec._(this._frameCount, this._repetitionCount, this._frameInfos); + final int _frameCount; final int _repetitionCount; final List _frameInfos; int _nextFrame = 0; - FakeCodec._(this._frameCount, this._repetitionCount, this._frameInfos); - /// Creates a FakeCodec from encoded image data. /// /// Only call this method outside of the test zone. diff --git a/packages/flutter/test/painting/image_resolution_test.dart b/packages/flutter/test/painting/image_resolution_test.dart index 9099ae9974..75a62c7f6c 100644 --- a/packages/flutter/test/painting/image_resolution_test.dart +++ b/packages/flutter/test/painting/image_resolution_test.dart @@ -13,11 +13,10 @@ import 'package:flutter_test/flutter_test.dart'; class TestAssetBundle extends CachingAssetBundle { + TestAssetBundle(this._assetBundleMap); Map> _assetBundleMap; - TestAssetBundle(this._assetBundleMap); - Map loadCallCount = {}; String get _assetBundleContents { diff --git a/packages/flutter/test/painting/image_stream_test.dart b/packages/flutter/test/painting/image_stream_test.dart index 6c54351843..40c89a46f1 100644 --- a/packages/flutter/test/painting/image_stream_test.dart +++ b/packages/flutter/test/painting/image_stream_test.dart @@ -11,12 +11,12 @@ import 'package:flutter/scheduler.dart' show timeDilation; import 'package:flutter_test/flutter_test.dart'; class FakeFrameInfo implements FrameInfo { - final Duration _duration; - final Image _image; - FakeFrameInfo(int width, int height, this._duration) : _image = FakeImage(width, height); + final Duration _duration; + final Image _image; + @override Duration get duration => _duration; @@ -25,11 +25,11 @@ class FakeFrameInfo implements FrameInfo { } class FakeImage implements Image { + FakeImage(this._width, this._height); + final int _width; final int _height; - FakeImage(this._width, this._height); - @override int get width => _width; diff --git a/packages/flutter/test/rendering/mock_canvas.dart b/packages/flutter/test/rendering/mock_canvas.dart index 5dc2cac01f..172801f784 100644 --- a/packages/flutter/test/rendering/mock_canvas.dart +++ b/packages/flutter/test/rendering/mock_canvas.dart @@ -558,12 +558,12 @@ abstract class _TestRecordingCanvasMatcher extends Matcher { } class _TestRecordingCanvasPaintsCountMatcher extends _TestRecordingCanvasMatcher { - final Symbol _methodName; - final int _count; - _TestRecordingCanvasPaintsCountMatcher(Symbol methodName, int count) : _methodName = methodName, _count = count; + final Symbol _methodName; + final int _count; + @override Description describe(Description description) { return description.add('Object or closure painting $_methodName exactly $_count times'); diff --git a/packages/flutter/test/widgets/image_test.dart b/packages/flutter/test/widgets/image_test.dart index 513b3304a5..04fd69e0b6 100644 --- a/packages/flutter/test/widgets/image_test.dart +++ b/packages/flutter/test/widgets/image_test.dart @@ -792,15 +792,15 @@ void main() { } class TestImageProvider extends ImageProvider { - final Completer _completer = Completer(); - ImageStreamCompleter _streamCompleter; - ImageConfiguration _lastResolvedConfiguration; - TestImageProvider({ImageStreamCompleter streamCompleter}) { _streamCompleter = streamCompleter ?? OneFrameImageStreamCompleter(_completer.future); } + final Completer _completer = Completer(); + ImageStreamCompleter _streamCompleter; + ImageConfiguration _lastResolvedConfiguration; + @override Future obtainKey(ImageConfiguration configuration) { return SynchronousFuture(this); diff --git a/packages/flutter_driver/lib/src/common/text.dart b/packages/flutter_driver/lib/src/common/text.dart index c0d70b829b..328c92d0c3 100644 --- a/packages/flutter_driver/lib/src/common/text.dart +++ b/packages/flutter_driver/lib/src/common/text.dart @@ -41,14 +41,14 @@ class EnterText extends Command { /// Creates a command that enters text into the currently focused widget. EnterText(this.text, { Duration timeout }) : super(timeout: timeout); - /// The text extracted by the [GetText] command. - final String text; - /// Deserializes this command from the value generated by [serialize]. EnterText.deserialize(Map json) : text = json['text'], super.deserialize(json); + /// The text extracted by the [GetText] command. + final String text; + @override final String kind = 'enter_text'; @@ -77,14 +77,14 @@ class SetTextEntryEmulation extends Command { /// Creates a command that enables and disables text entry emulation. SetTextEntryEmulation(this.enabled, { Duration timeout }) : super(timeout: timeout); - /// Whether text entry emulation should be enabled. - final bool enabled; - /// Deserializes this command from the value generated by [serialize]. SetTextEntryEmulation.deserialize(Map json) : enabled = json['enabled'] == 'true', super.deserialize(json); + /// Whether text entry emulation should be enabled. + final bool enabled; + @override final String kind = 'set_text_entry_emulation'; diff --git a/packages/flutter_driver/lib/src/driver/driver.dart b/packages/flutter_driver/lib/src/driver/driver.dart index 5aa1e47dc9..c4ab1b68d4 100644 --- a/packages/flutter_driver/lib/src/driver/driver.dart +++ b/packages/flutter_driver/lib/src/driver/driver.dart @@ -770,6 +770,9 @@ class FlutterDriver { /// Encapsulates connection information to an instance of a Flutter application. @visibleForTesting class VMServiceClientConnection { + /// Creates an instance of this class given a [client] and a [peer]. + VMServiceClientConnection(this.client, this.peer); + /// Use this for structured access to the VM service's public APIs. final VMServiceClient client; @@ -778,9 +781,6 @@ class VMServiceClientConnection { /// This object allows reaching into private VM service APIs. Use with /// caution. final rpc.Peer peer; - - /// Creates an instance of this class given a [client] and a [peer]. - VMServiceClientConnection(this.client, this.peer); } /// A function that connects to a Dart VM service given the [url]. diff --git a/packages/flutter_driver/lib/src/extension/extension.dart b/packages/flutter_driver/lib/src/extension/extension.dart index 3adb1d512a..cc3f0a8696 100644 --- a/packages/flutter_driver/lib/src/extension/extension.dart +++ b/packages/flutter_driver/lib/src/extension/extension.dart @@ -92,8 +92,6 @@ typedef FinderConstructor = Finder Function(SerializableFinder finder); /// calling [enableFlutterDriverExtension]. @visibleForTesting class FlutterDriverExtension { - final TestTextInput _testTextInput = TestTextInput(); - /// Creates an object to manage a Flutter Driver connection. FlutterDriverExtension(this._requestDataHandler, this._silenceErrors) { _testTextInput.register(); @@ -143,6 +141,8 @@ class FlutterDriverExtension { }); } + final TestTextInput _testTextInput = TestTextInput(); + final DataHandler _requestDataHandler; final bool _silenceErrors; diff --git a/packages/flutter_tools/lib/src/android/android_studio.dart b/packages/flutter_tools/lib/src/android/android_studio.dart index 932433bfae..00f0ddad28 100644 --- a/packages/flutter_tools/lib/src/android/android_studio.dart +++ b/packages/flutter_tools/lib/src/android/android_studio.dart @@ -36,16 +36,6 @@ class AndroidStudio implements Comparable { _init(); } - final String directory; - final String studioAppName; - final Version version; - final String configured; - - String _pluginsPath; - String _javaPath; - bool _isValid = false; - final List _validationMessages = []; - factory AndroidStudio.fromMacOSBundle(String bundlePath) { final String studioPath = fs.path.join(bundlePath, 'Contents'); final String plistFile = fs.path.join(studioPath, 'Info.plist'); @@ -89,6 +79,16 @@ class AndroidStudio implements Comparable { return null; } + final String directory; + final String studioAppName; + final Version version; + final String configured; + + String _pluginsPath; + String _javaPath; + bool _isValid = false; + final List _validationMessages = []; + String get javaPath => _javaPath; bool get isValid => _isValid; diff --git a/packages/flutter_tools/lib/src/android/android_studio_validator.dart b/packages/flutter_tools/lib/src/android/android_studio_validator.dart index 3302e94309..b12d33887d 100644 --- a/packages/flutter_tools/lib/src/android/android_studio_validator.dart +++ b/packages/flutter_tools/lib/src/android/android_studio_validator.dart @@ -11,10 +11,10 @@ import '../intellij/intellij.dart'; import 'android_studio.dart'; class AndroidStudioValidator extends DoctorValidator { - final AndroidStudio _studio; - AndroidStudioValidator(this._studio) : super('Android Studio'); + final AndroidStudio _studio; + static List get allValidators { final List validators = []; final List studios = AndroidStudio.allInstalled(); diff --git a/packages/flutter_tools/lib/src/application_package.dart b/packages/flutter_tools/lib/src/application_package.dart index 03fbd9b0c5..fc168971ef 100644 --- a/packages/flutter_tools/lib/src/application_package.dart +++ b/packages/flutter_tools/lib/src/application_package.dart @@ -21,12 +21,12 @@ import 'project.dart'; import 'tester/flutter_tester.dart'; abstract class ApplicationPackage { - /// Package ID from the Android Manifest or equivalent. - final String id; - ApplicationPackage({ @required this.id }) : assert(id != null); + /// Package ID from the Android Manifest or equivalent. + final String id; + String get name; String get displayName => name; @@ -38,12 +38,6 @@ abstract class ApplicationPackage { } class AndroidApk extends ApplicationPackage { - /// Path to the actual apk file. - final File file; - - /// The path to the activity that should be launched. - final String launchActivity; - AndroidApk({ String id, @required this.file, @@ -88,6 +82,12 @@ class AndroidApk extends ApplicationPackage { ); } + /// Path to the actual apk file. + final File file; + + /// The path to the activity that should be launched. + final String launchActivity; + /// Creates a new AndroidApk based on the information in the Android manifest. static Future fromAndroidProject(AndroidProject androidProject) async { File apkFile; @@ -250,15 +250,15 @@ class BuildableIOSApp extends IOSApp { } class PrebuiltIOSApp extends IOSApp { - final Directory bundleDir; - final String bundleName; - PrebuiltIOSApp({ this.bundleDir, this.bundleName, @required String projectBundleId, }) : super(projectBundleId: projectBundleId); + final Directory bundleDir; + final String bundleName; + @override String get name => bundleName; @@ -299,11 +299,11 @@ Future getApplicationPackageForPlatform( } class ApplicationPackageStore { + ApplicationPackageStore({ this.android, this.iOS }); + AndroidApk android; IOSApp iOS; - ApplicationPackageStore({ this.android, this.iOS }); - Future getPackageForPlatform(TargetPlatform platform) async { switch (platform) { case TargetPlatform.android_arm: @@ -332,9 +332,6 @@ class _Entry { } class _Element extends _Entry { - List<_Entry> children; - String name; - _Element.fromLine(String line, _Element parent) { // E: application (line=29) final List parts = line.trimLeft().split(' '); @@ -344,6 +341,9 @@ class _Element extends _Entry { children = <_Entry>[]; } + List<_Entry> children; + String name; + void addChild(_Entry child) { children.add(child); } @@ -369,9 +369,6 @@ class _Element extends _Entry { } class _Attribute extends _Entry { - String key; - String value; - _Attribute.fromLine(String line, _Element parent) { // A: android:label(0x01010001)="hello_world" (Raw: "hello_world") const String attributePrefix = 'A: '; @@ -383,6 +380,9 @@ class _Attribute extends _Entry { level = line.length - line.trimLeft().length; this.parent = parent; } + + String key; + String value; } class ApkManifestData { diff --git a/packages/flutter_tools/lib/src/artifacts.dart b/packages/flutter_tools/lib/src/artifacts.dart index 9ad2d9b6ae..59c20c757f 100644 --- a/packages/flutter_tools/lib/src/artifacts.dart +++ b/packages/flutter_tools/lib/src/artifacts.dart @@ -231,12 +231,12 @@ class CachedArtifacts extends Artifacts { /// Manages the artifacts of a locally built engine. class LocalEngineArtifacts extends Artifacts { + LocalEngineArtifacts(this._engineSrcPath, this.engineOutPath, this._hostEngineOutPath); + final String _engineSrcPath; final String engineOutPath; // TODO(goderbauer): This should be private. String _hostEngineOutPath; - LocalEngineArtifacts(this._engineSrcPath, this.engineOutPath, this._hostEngineOutPath); - @override String getArtifactPath(Artifact artifact, [TargetPlatform platform, BuildMode mode]) { switch (artifact) { diff --git a/packages/flutter_tools/lib/src/asset.dart b/packages/flutter_tools/lib/src/asset.dart index 5052e5de1f..871c882ee9 100644 --- a/packages/flutter_tools/lib/src/asset.dart +++ b/packages/flutter_tools/lib/src/asset.dart @@ -56,21 +56,21 @@ class _ManifestAssetBundleFactory implements AssetBundleFactory { } class _ManifestAssetBundle implements AssetBundle { + /// Constructs an [_ManifestAssetBundle] that gathers the set of assets from the + /// pubspec.yaml manifest. + _ManifestAssetBundle(); + @override final Map entries = {}; + DateTime _lastBuildTimestamp; + static const String defaultManifestPath = 'pubspec.yaml'; static const String _assetManifestJson = 'AssetManifest.json'; static const String _fontManifestJson = 'FontManifest.json'; static const String _fontSetMaterial = 'material'; static const String _license = 'LICENSE'; - DateTime _lastBuildTimestamp; - - /// Constructs an [_ManifestAssetBundle] that gathers the set of assets from the - /// pubspec.yaml manifest. - _ManifestAssetBundle(); - @override bool wasBuiltOnce() => _lastBuildTimestamp != null; diff --git a/packages/flutter_tools/lib/src/base/version.dart b/packages/flutter_tools/lib/src/base/version.dart index 663c43e073..80ad3f0335 100644 --- a/packages/flutter_tools/lib/src/base/version.dart +++ b/packages/flutter_tools/lib/src/base/version.dart @@ -3,24 +3,6 @@ // found in the LICENSE file. class Version implements Comparable { - static final RegExp versionPattern = - RegExp(r'^(\d+)(\.(\d+)(\.(\d+))?)?'); - - /// The major version number: "1" in "1.2.3". - final int major; - - /// The minor version number: "2" in "1.2.3". - final int minor; - - /// The patch version number: "3" in "1.2.3". - final int patch; - - /// The original string representation of the version number. - /// - /// This preserves textual artifacts like leading zeros that may be left out - /// of the parsed version. - final String _text; - /// Creates a new [Version] object. factory Version(int major, int minor, int patch, {String text}) { if (text == null) { @@ -76,6 +58,24 @@ class Version implements Comparable { static Version get unknown => Version(0, 0, 0, text: 'unknown'); + /// The major version number: "1" in "1.2.3". + final int major; + + /// The minor version number: "2" in "1.2.3". + final int minor; + + /// The patch version number: "3" in "1.2.3". + final int patch; + + /// The original string representation of the version number. + /// + /// This preserves textual artifacts like leading zeros that may be left out + /// of the parsed version. + final String _text; + + static final RegExp versionPattern = + RegExp(r'^(\d+)(\.(\d+)(\.(\d+))?)?'); + /// Two [Version]s are equal if their version numbers are. The version text /// is ignored. @override diff --git a/packages/flutter_tools/lib/src/commands/analyze_base.dart b/packages/flutter_tools/lib/src/commands/analyze_base.dart index 04547d28fb..e10f96ffb2 100644 --- a/packages/flutter_tools/lib/src/commands/analyze_base.dart +++ b/packages/flutter_tools/lib/src/commands/analyze_base.dart @@ -15,11 +15,11 @@ import '../globals.dart'; /// Common behavior for `flutter analyze` and `flutter analyze --watch` abstract class AnalyzeBase { + AnalyzeBase(this.argResults); + /// The parsed argument results for execution. final ArgResults argResults; - AnalyzeBase(this.argResults); - /// Called by [AnalyzeCommand] to start the analysis process. Future analyze(); diff --git a/packages/flutter_tools/lib/src/commands/daemon.dart b/packages/flutter_tools/lib/src/commands/daemon.dart index 18d38bcd62..de16efbcf4 100644 --- a/packages/flutter_tools/lib/src/commands/daemon.dart +++ b/packages/flutter_tools/lib/src/commands/daemon.dart @@ -819,14 +819,14 @@ class AppInstance { /// This domain responds to methods like [getEmulators] and [launch]. class EmulatorDomain extends Domain { - EmulatorManager emulators = EmulatorManager(); - EmulatorDomain(Daemon daemon) : super(daemon, 'emulator') { registerHandler('getEmulators', getEmulators); registerHandler('launch', launch); registerHandler('create', create); } + EmulatorManager emulators = EmulatorManager(); + Future>> getEmulators([Map args]) async { final List list = await emulators.getAllAvailableEmulators(); return list.map>(_emulatorToMap).toList(); @@ -971,9 +971,9 @@ class _AppRunLogger extends Logger { } class LogMessage { + LogMessage(this.level, this.message, [this.stackTrace]); + final String level; final String message; final StackTrace stackTrace; - - LogMessage(this.level, this.message, [this.stackTrace]); } diff --git a/packages/flutter_tools/lib/src/commands/fuchsia_reload.dart b/packages/flutter_tools/lib/src/commands/fuchsia_reload.dart index 3979beb967..9bb14cf1e2 100644 --- a/packages/flutter_tools/lib/src/commands/fuchsia_reload.dart +++ b/packages/flutter_tools/lib/src/commands/fuchsia_reload.dart @@ -444,18 +444,18 @@ class FuchsiaReloadCommand extends FlutterCommand { // VM service running on a Fuchsia device. [process] is the ssh process running // the tunnel and [port] is the local port. class _PortForwarder { - final String _remoteAddress; - final int _remotePort; - final int _localPort; - final Process _process; - final String _sshConfig; - _PortForwarder._(this._remoteAddress, this._remotePort, this._localPort, this._process, this._sshConfig); + final String _remoteAddress; + final int _remotePort; + final int _localPort; + final Process _process; + final String _sshConfig; + int get port => _localPort; static Future<_PortForwarder> start(String sshConfig, @@ -519,11 +519,11 @@ class _PortForwarder { } class FuchsiaDeviceCommandRunner { + FuchsiaDeviceCommandRunner(this._address, this._sshConfig); + final String _address; final String _sshConfig; - FuchsiaDeviceCommandRunner(this._address, this._sshConfig); - Future> run(String command) async { final List args = ['ssh', '-F', _sshConfig, _address, command]; printTrace(args.join(' ')); diff --git a/packages/flutter_tools/lib/src/commands/run.dart b/packages/flutter_tools/lib/src/commands/run.dart index 36efd98b78..40c35489a3 100644 --- a/packages/flutter_tools/lib/src/commands/run.dart +++ b/packages/flutter_tools/lib/src/commands/run.dart @@ -72,12 +72,6 @@ abstract class RunCommandBase extends FlutterCommand { } class RunCommand extends RunCommandBase { - @override - final String name = 'run'; - - @override - final String description = 'Run your Flutter app on an attached device.'; - RunCommand({ bool verboseHelp = false }) : super(verboseHelp: verboseHelp) { requiresPubspecYaml(); usesFilesystemOptions(hide: !verboseHelp); @@ -179,6 +173,12 @@ class RunCommand extends RunCommandBase { ..addOption(FlutterOptions.kExtraGenSnapshotOptions, hide: true); } + @override + final String name = 'run'; + + @override + final String description = 'Run your Flutter app on an attached device.'; + List devices; @override diff --git a/packages/flutter_tools/lib/src/compile.dart b/packages/flutter_tools/lib/src/compile.dart index a3c6930e94..9ae07787e0 100644 --- a/packages/flutter_tools/lib/src/compile.dart +++ b/packages/flutter_tools/lib/src/compile.dart @@ -21,10 +21,10 @@ KernelCompiler get kernelCompiler => context[KernelCompiler]; typedef CompilerMessageConsumer = void Function(String message, {bool emphasis, TerminalColor color}); class CompilerOutput { + const CompilerOutput(this.outputFilename, this.errorCount); + final String outputFilename; final int errorCount; - - const CompilerOutput(this.outputFilename, this.errorCount); } class _StdoutHandler { @@ -198,10 +198,10 @@ class KernelCompiler { /// Class that allows to serialize compilation requests to the compiler. abstract class _CompilationRequest { - Completer completer; - _CompilationRequest(this.completer); + Completer completer; + Future _run(ResidentCompiler compiler); Future run(ResidentCompiler compiler) async { diff --git a/packages/flutter_tools/lib/src/crash_reporting.dart b/packages/flutter_tools/lib/src/crash_reporting.dart index 9018ceed72..b353780fc4 100644 --- a/packages/flutter_tools/lib/src/crash_reporting.dart +++ b/packages/flutter_tools/lib/src/crash_reporting.dart @@ -48,10 +48,10 @@ const String _kStackTraceFilename = 'stacktrace_file'; /// * In tests call [initializeWith] and provide a mock implementation of /// [http.Client]. class CrashReportSender { - static CrashReportSender _instance; - CrashReportSender._(this._client); + static CrashReportSender _instance; + static CrashReportSender get instance => _instance ?? CrashReportSender._(http.Client()); /// Overrides the default [http.Client] with [client] for testing purposes. diff --git a/packages/flutter_tools/lib/src/dart/pub.dart b/packages/flutter_tools/lib/src/dart/pub.dart index b4b6e6b8d8..b318302c1b 100644 --- a/packages/flutter_tools/lib/src/dart/pub.dart +++ b/packages/flutter_tools/lib/src/dart/pub.dart @@ -23,7 +23,17 @@ import 'sdk.dart'; // DO NOT update without contacting kevmoo. // We have server-side tooling that assumes the values are consistent. class PubContext { - static final RegExp _validContext = RegExp('[a-z][a-z_]*[a-z]'); + PubContext._(this._values) { + for (String item in _values) { + if (!_validContext.hasMatch(item)) { + throw ArgumentError.value( + _values, 'value', 'Must match RegExp ${_validContext.pattern}'); + } + } + } + + static PubContext getVerifyContext(String commandName) => + PubContext._(['verify', commandName.replaceAll('-', '_')]); static final PubContext create = PubContext._(['create']); static final PubContext createPackage = PubContext._(['create_pkg']); @@ -38,17 +48,7 @@ class PubContext { final List _values; - PubContext._(this._values) { - for (String item in _values) { - if (!_validContext.hasMatch(item)) { - throw ArgumentError.value( - _values, 'value', 'Must match RegExp ${_validContext.pattern}'); - } - } - } - - static PubContext getVerifyContext(String commandName) => - PubContext._(['verify', commandName.replaceAll('-', '_')]); + static final RegExp _validContext = RegExp('[a-z][a-z_]*[a-z]'); @override String toString() => 'PubContext: ${_values.join(':')}'; diff --git a/packages/flutter_tools/lib/src/dependency_checker.dart b/packages/flutter_tools/lib/src/dependency_checker.dart index 8316443fdd..bcc9407d11 100644 --- a/packages/flutter_tools/lib/src/dependency_checker.dart +++ b/packages/flutter_tools/lib/src/dependency_checker.dart @@ -8,10 +8,11 @@ import 'dart/dependencies.dart'; import 'globals.dart'; class DependencyChecker { + DependencyChecker(this.builder, this.assets); + final DartDependencySetBuilder builder; final Set _dependencies = Set(); final AssetBundle assets; - DependencyChecker(this.builder, this.assets); /// Returns [true] if any components have been modified after [threshold] or /// if it cannot be determined. diff --git a/packages/flutter_tools/lib/src/devfs.dart b/packages/flutter_tools/lib/src/devfs.dart index 3dd881943c..54b7107e76 100644 --- a/packages/flutter_tools/lib/src/devfs.dart +++ b/packages/flutter_tools/lib/src/devfs.dart @@ -201,10 +201,10 @@ abstract class DevFSOperations { /// An implementation of [DevFSOperations] that speaks to the /// vm service. class ServiceProtocolDevFSOperations implements DevFSOperations { - final VMService vmService; - ServiceProtocolDevFSOperations(this.vmService); + final VMService vmService; + @override Future create(String fsName) async { final Map response = await vmService.vm.createDevFS(fsName); diff --git a/packages/flutter_tools/lib/src/doctor.dart b/packages/flutter_tools/lib/src/doctor.dart index d0fcf2f693..ca10b6ea4a 100644 --- a/packages/flutter_tools/lib/src/doctor.dart +++ b/packages/flutter_tools/lib/src/doctor.dart @@ -420,10 +420,10 @@ class NoIdeValidator extends DoctorValidator { } abstract class IntelliJValidator extends DoctorValidator { - final String installPath; - IntelliJValidator(String title, this.installPath) : super(title); + final String installPath; + String get version; String get pluginsPath; @@ -644,10 +644,10 @@ class DeviceValidator extends DoctorValidator { } class ValidatorWithResult extends DoctorValidator { - final ValidationResult result; - ValidatorWithResult(String title, this.result) : super(title); + final ValidationResult result; + @override Future validate() async => result; } diff --git a/packages/flutter_tools/lib/src/emulator.dart b/packages/flutter_tools/lib/src/emulator.dart index 42e63fe303..51d0706d74 100644 --- a/packages/flutter_tools/lib/src/emulator.dart +++ b/packages/flutter_tools/lib/src/emulator.dart @@ -277,10 +277,10 @@ abstract class Emulator { } class CreateEmulatorResult { + CreateEmulatorResult(this.emulatorName, {this.success, this.output, this.error}); + final bool success; final String emulatorName; final String output; final String error; - - CreateEmulatorResult(this.emulatorName, {this.success, this.output, this.error}); } diff --git a/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart b/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart index 0c02bcc412..76099799c1 100644 --- a/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart +++ b/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart @@ -10,10 +10,10 @@ import '../device.dart'; /// Read the log for a particular device. class _FuchsiaLogReader extends DeviceLogReader { - FuchsiaDevice _device; - _FuchsiaLogReader(this._device); + FuchsiaDevice _device; + @override String get name => _device.name; Stream _logLines; diff --git a/packages/flutter_tools/lib/src/intellij/intellij.dart b/packages/flutter_tools/lib/src/intellij/intellij.dart index 03f2d0f7ed..46278ba54c 100644 --- a/packages/flutter_tools/lib/src/intellij/intellij.dart +++ b/packages/flutter_tools/lib/src/intellij/intellij.dart @@ -11,11 +11,11 @@ import '../base/version.dart'; import '../doctor.dart'; class IntelliJPlugins { - static final Version kMinFlutterPluginVersion = Version(16, 0, 0); + IntelliJPlugins(this.pluginsPath); final String pluginsPath; - IntelliJPlugins(this.pluginsPath); + static final Version kMinFlutterPluginVersion = Version(16, 0, 0); void validatePackage( List messages, List packageNames, String title, diff --git a/packages/flutter_tools/lib/src/ios/devices.dart b/packages/flutter_tools/lib/src/ios/devices.dart index d9f4e2677c..f567692eab 100644 --- a/packages/flutter_tools/lib/src/ios/devices.dart +++ b/packages/flutter_tools/lib/src/ios/devices.dart @@ -440,11 +440,6 @@ String decodeSyslog(String line) { } class _IOSDeviceLogReader extends DeviceLogReader { - // Matches a syslog line from the runner. - RegExp _runnerLineRegex; - // Matches a syslog line from any app. - RegExp _anyLineRegex; - _IOSDeviceLogReader(this.device, ApplicationPackage app) { _linesController = StreamController.broadcast( onListen: _start, @@ -465,6 +460,11 @@ class _IOSDeviceLogReader extends DeviceLogReader { final IOSDevice device; + // Matches a syslog line from the runner. + RegExp _runnerLineRegex; + // Matches a syslog line from any app. + RegExp _anyLineRegex; + StreamController _linesController; Process _process; diff --git a/packages/flutter_tools/lib/src/ios/simulators.dart b/packages/flutter_tools/lib/src/ios/simulators.dart index 77dd9d4663..ea830e3eef 100644 --- a/packages/flutter_tools/lib/src/ios/simulators.dart +++ b/packages/flutter_tools/lib/src/ios/simulators.dart @@ -482,8 +482,6 @@ Future launchSystemLogTool(IOSSimulator device) async { } class _IOSSimulatorLogReader extends DeviceLogReader { - String _appName; - _IOSSimulatorLogReader(this.device, IOSApp app) { _linesController = StreamController.broadcast( onListen: _start, @@ -494,6 +492,8 @@ class _IOSSimulatorLogReader extends DeviceLogReader { final IOSSimulator device; + String _appName; + StreamController _linesController; // We log from two files: the device and the system log. diff --git a/packages/flutter_tools/lib/src/plugins.dart b/packages/flutter_tools/lib/src/plugins.dart index 2b959c794a..cd4827b43a 100644 --- a/packages/flutter_tools/lib/src/plugins.dart +++ b/packages/flutter_tools/lib/src/plugins.dart @@ -22,12 +22,6 @@ void _renderTemplateToFile(String template, dynamic context, String filePath) { } class Plugin { - final String name; - final String path; - final String androidPackage; - final String iosPrefix; - final String pluginClass; - Plugin({ this.name, this.path, @@ -53,6 +47,12 @@ class Plugin { pluginClass: pluginClass, ); } + + final String name; + final String path; + final String androidPackage; + final String iosPrefix; + final String pluginClass; } Plugin _pluginFromPubspec(String name, Uri packageRoot) { diff --git a/packages/flutter_tools/lib/src/project.dart b/packages/flutter_tools/lib/src/project.dart index 065461158f..3f94c80b78 100644 --- a/packages/flutter_tools/lib/src/project.dart +++ b/packages/flutter_tools/lib/src/project.dart @@ -148,15 +148,15 @@ class FlutterProject { /// Instances will reflect the contents of the `ios/` sub-folder of /// Flutter applications and the `.ios/` sub-folder of Flutter modules. class IosProject { - static final RegExp _productBundleIdPattern = RegExp(r'^\s*PRODUCT_BUNDLE_IDENTIFIER\s*=\s*(.*);\s*$'); - static const String _productBundleIdVariable = r'$(PRODUCT_BUNDLE_IDENTIFIER)'; - static const String _hostAppBundleName = 'Runner'; - IosProject._(this.parent); /// The parent of this project. final FlutterProject parent; + static final RegExp _productBundleIdPattern = RegExp(r'^\s*PRODUCT_BUNDLE_IDENTIFIER\s*=\s*(.*);\s*$'); + static const String _productBundleIdVariable = r'$(PRODUCT_BUNDLE_IDENTIFIER)'; + static const String _hostAppBundleName = 'Runner'; + Directory get _ephemeralDirectory => parent.directory.childDirectory('.ios'); Directory get _editableDirectory => parent.directory.childDirectory('ios'); @@ -321,14 +321,14 @@ class IosProject { /// Instances will reflect the contents of the `android/` sub-folder of /// Flutter applications and the `.android/` sub-folder of Flutter modules. class AndroidProject { - static final RegExp _applicationIdPattern = RegExp('^\\s*applicationId\\s+[\'\"](.*)[\'\"]\\s*\$'); - static final RegExp _groupPattern = RegExp('^\\s*group\\s+[\'\"](.*)[\'\"]\\s*\$'); - AndroidProject._(this.parent); /// The parent of this project. final FlutterProject parent; + static final RegExp _applicationIdPattern = RegExp('^\\s*applicationId\\s+[\'\"](.*)[\'\"]\\s*\$'); + static final RegExp _groupPattern = RegExp('^\\s*group\\s+[\'\"](.*)[\'\"]\\s*\$'); + /// The Gradle root directory of the Android host app. This is the directory /// containing the `app/` subdirectory and the `settings.gradle` file that /// includes it in the overall Gradle project. diff --git a/packages/flutter_tools/lib/src/tester/flutter_tester.dart b/packages/flutter_tools/lib/src/tester/flutter_tester.dart index 4e5ff5ff57..219d46b78e 100644 --- a/packages/flutter_tools/lib/src/tester/flutter_tester.dart +++ b/packages/flutter_tools/lib/src/tester/flutter_tester.dart @@ -22,8 +22,6 @@ import '../protocol_discovery.dart'; import '../version.dart'; class FlutterTesterApp extends ApplicationPackage { - final Directory _directory; - factory FlutterTesterApp.fromCurrentDirectory() { return FlutterTesterApp._(fs.currentDirectory); } @@ -32,6 +30,8 @@ class FlutterTesterApp extends ApplicationPackage { : _directory = directory, super(id: directory.path); + final Directory _directory; + @override String get name => _directory.basename; diff --git a/packages/flutter_tools/lib/src/version.dart b/packages/flutter_tools/lib/src/version.dart index 98612c0d19..da54493c87 100644 --- a/packages/flutter_tools/lib/src/version.dart +++ b/packages/flutter_tools/lib/src/version.dart @@ -368,10 +368,6 @@ class FlutterVersion { /// Contains data and load/save logic pertaining to Flutter version checks. @visibleForTesting class VersionCheckStamp { - /// The prefix of the stamp file where we cache Flutter version check data. - @visibleForTesting - static const String kFlutterVersionCheckStampFile = 'flutter_version_check'; - const VersionCheckStamp({ this.lastTimeVersionWasChecked, this.lastKnownRemoteVersion, @@ -382,6 +378,10 @@ class VersionCheckStamp { final DateTime lastKnownRemoteVersion; final DateTime lastTimeWarningWasPrinted; + /// The prefix of the stamp file where we cache Flutter version check data. + @visibleForTesting + static const String kFlutterVersionCheckStampFile = 'flutter_version_check'; + static Future load() async { final String versionCheckStamp = Cache.instance.getStampFor(kFlutterVersionCheckStampFile); diff --git a/packages/flutter_tools/lib/src/vmservice.dart b/packages/flutter_tools/lib/src/vmservice.dart index 0fa50cbccc..e76b963f6e 100644 --- a/packages/flutter_tools/lib/src/vmservice.dart +++ b/packages/flutter_tools/lib/src/vmservice.dart @@ -559,7 +559,20 @@ abstract class ServiceObject { } class ServiceEvent extends ServiceObject { - /// The possible 'kind' values. + ServiceEvent._empty(ServiceObjectOwner owner) : super._empty(owner); + + String _kind; + String get kind => _kind; + DateTime _timestamp; + DateTime get timestamp => _timestamp; + String _extensionKind; + String get extensionKind => _extensionKind; + Map _extensionData; + Map get extensionData => _extensionData; + List> _timelineEvents; + List> get timelineEvents => _timelineEvents; + + // The possible 'kind' values. static const String kVMUpdate = 'VMUpdate'; static const String kIsolateStart = 'IsolateStart'; static const String kIsolateRunnable = 'IsolateRunnable'; @@ -587,19 +600,6 @@ class ServiceEvent extends ServiceObject { static const String kLogging = '_Logging'; static const String kExtension = 'Extension'; - ServiceEvent._empty(ServiceObjectOwner owner) : super._empty(owner); - - String _kind; - String get kind => _kind; - DateTime _timestamp; - DateTime get timestamp => _timestamp; - String _extensionKind; - String get extensionKind => _extensionKind; - Map _extensionData; - Map get extensionData => _extensionData; - List> _timelineEvents; - List> get timelineEvents => _timelineEvents; - @override void _update(Map map, bool mapIsRef) { _loaded = true; diff --git a/packages/flutter_tools/lib/src/vmservice_record_replay.dart b/packages/flutter_tools/lib/src/vmservice_record_replay.dart index 49dd7c3c5a..0126f87b65 100644 --- a/packages/flutter_tools/lib/src/vmservice_record_replay.dart +++ b/packages/flutter_tools/lib/src/vmservice_record_replay.dart @@ -22,11 +22,6 @@ const String _kData = 'data'; /// A [StreamChannel] that expects VM service (JSON-rpc) protocol messages and /// serializes all such messages to the file system for later playback. class RecordingVMServiceChannel extends DelegatingStreamChannel { - final List<_Message> _messages = <_Message>[]; - - _RecordingStream _streamRecorder; - _RecordingSink _sinkRecorder; - RecordingVMServiceChannel(StreamChannel delegate, Directory location) : super(delegate) { addShutdownHook(() async { @@ -41,6 +36,11 @@ class RecordingVMServiceChannel extends DelegatingStreamChannel { }, ShutdownStage.SERIALIZE_RECORDING); } + final List<_Message> _messages = <_Message>[]; + + _RecordingStream _streamRecorder; + _RecordingSink _sinkRecorder; + @override Stream get stream { _streamRecorder ??= _RecordingStream(super.stream, _messages); @@ -53,9 +53,6 @@ class RecordingVMServiceChannel extends DelegatingStreamChannel { /// Base class for request and response JSON-rpc messages. abstract class _Message implements Comparable<_Message> { - final String type; - final Map data; - _Message(this.type, this.data); factory _Message.fromRecording(Map recordingData) { @@ -64,6 +61,9 @@ abstract class _Message implements Comparable<_Message> { : _Response(recordingData[_kData]); } + final String type; + final Map data; + int get id => data[_kId]; /// Allows [JsonEncoder] to properly encode objects of this type. @@ -115,11 +115,6 @@ class _Transaction { /// A helper class that monitors a [Stream] of VM service JSON-rpc responses /// and saves the responses to a recording. class _RecordingStream { - final Stream _delegate; - final StreamController _controller; - final List<_Message> _recording; - StreamSubscription _subscription; - _RecordingStream(Stream stream, this._recording) : _delegate = stream, _controller = stream.isBroadcast @@ -144,6 +139,11 @@ class _RecordingStream { }; } + final Stream _delegate; + final StreamController _controller; + final List<_Message> _recording; + StreamSubscription _subscription; + StreamSubscription _listenToStream() { return _delegate.listen( (String element) { @@ -162,11 +162,11 @@ class _RecordingStream { /// A [StreamSink] that monitors VM service JSON-rpc requests and saves the /// requests to a recording. class _RecordingSink implements StreamSink { + _RecordingSink(this._delegate, this._recording); + final StreamSink _delegate; final List<_Message> _recording; - _RecordingSink(this._delegate, this._recording); - @override Future close() => _delegate.close(); @@ -194,13 +194,13 @@ class _RecordingSink implements StreamSink { /// to its [StreamChannel.sink], looks up those requests in a recording, and /// replays the corresponding responses back from the recording. class ReplayVMServiceChannel extends StreamChannelMixin { + ReplayVMServiceChannel(Directory location) + : _transactions = _loadTransactions(location); + final Map _transactions; final StreamController _controller = StreamController(); _ReplaySink _replaySink; - ReplayVMServiceChannel(Directory location) - : _transactions = _loadTransactions(location); - static Map _loadTransactions(Directory location) { final File file = _getManifest(location); final String jsonData = file.readAsStringSync(); @@ -250,11 +250,11 @@ class ReplayVMServiceChannel extends StreamChannelMixin { } class _ReplaySink implements StreamSink { + _ReplaySink(this.channel); + final ReplayVMServiceChannel channel; final Completer _completer = Completer(); - _ReplaySink(this.channel); - @override Future close() { _completer.complete(); diff --git a/packages/flutter_tools/lib/src/vscode/vscode.dart b/packages/flutter_tools/lib/src/vscode/vscode.dart index e92b9e3d1d..3ed7586d39 100644 --- a/packages/flutter_tools/lib/src/vscode/vscode.dart +++ b/packages/flutter_tools/lib/src/vscode/vscode.dart @@ -45,17 +45,6 @@ class VsCode { } } - final String directory; - final String extensionDirectory; - final Version version; - final String edition; - - static const String extensionIdentifier = 'Dart-Code.flutter'; - - bool _isValid = false; - Version _extensionVersion; - final List _validationMessages = []; - factory VsCode.fromDirectory(String installPath, String extensionDirectory, { String edition }) { final String packageJsonPath = @@ -67,6 +56,17 @@ class VsCode { return VsCode._(installPath, extensionDirectory, version: version, edition: edition); } + final String directory; + final String extensionDirectory; + final Version version; + final String edition; + + static const String extensionIdentifier = 'Dart-Code.flutter'; + + bool _isValid = false; + Version _extensionVersion; + final List _validationMessages = []; + bool get isValid => _isValid; String get productName => 'VS Code' + (edition != null ? ', $edition' : ''); diff --git a/packages/flutter_tools/lib/src/vscode/vscode_validator.dart b/packages/flutter_tools/lib/src/vscode/vscode_validator.dart index b93e1d0298..3d95170a00 100644 --- a/packages/flutter_tools/lib/src/vscode/vscode_validator.dart +++ b/packages/flutter_tools/lib/src/vscode/vscode_validator.dart @@ -9,11 +9,12 @@ import '../doctor.dart'; import 'vscode.dart'; class VsCodeValidator extends DoctorValidator { - static const String extensionMarketplaceUrl = - 'https://marketplace.visualstudio.com/items?itemName=${VsCode.extensionIdentifier}'; + VsCodeValidator(this._vsCode) : super(_vsCode.productName); + final VsCode _vsCode; - VsCodeValidator(this._vsCode) : super(_vsCode.productName); + static const String extensionMarketplaceUrl = + 'https://marketplace.visualstudio.com/items?itemName=${VsCode.extensionIdentifier}'; static Iterable get installedValidators { return VsCode diff --git a/packages/flutter_tools/test/commands/doctor_test.dart b/packages/flutter_tools/test/commands/doctor_test.dart index 7e3746369d..ea49e34e21 100644 --- a/packages/flutter_tools/test/commands/doctor_test.dart +++ b/packages/flutter_tools/test/commands/doctor_test.dart @@ -510,18 +510,17 @@ class FakeGroupedDoctorWithStatus extends Doctor { /// A doctor that takes any two validators. Used to check behavior when /// merging ValidationTypes (installed, missing, partial). class FakeSmallGroupDoctor extends Doctor { - List _validators; FakeSmallGroupDoctor(DoctorValidator val1, DoctorValidator val2) { _validators = [GroupedValidator([val1, val2])]; } + + List _validators; + @override List get validators => _validators; } class VsCodeValidatorTestTargets extends VsCodeValidator { - static final String validInstall = fs.path.join('test', 'data', 'vscode', 'application'); - static final String validExtensions = fs.path.join('test', 'data', 'vscode', 'extensions'); - static final String missingExtensions = fs.path.join('test', 'data', 'vscode', 'notExtensions'); VsCodeValidatorTestTargets._(String installDirectory, String extensionDirectory, {String edition}) : super(VsCode.fromDirectory(installDirectory, extensionDirectory, edition: edition)); @@ -533,4 +532,8 @@ class VsCodeValidatorTestTargets extends VsCodeValidator { static VsCodeValidatorTestTargets get installedWithoutExtension => VsCodeValidatorTestTargets._(validInstall, missingExtensions); + + static final String validInstall = fs.path.join('test', 'data', 'vscode', 'application'); + static final String validExtensions = fs.path.join('test', 'data', 'vscode', 'extensions'); + static final String missingExtensions = fs.path.join('test', 'data', 'vscode', 'notExtensions'); } diff --git a/packages/flutter_tools/test/dart/pub_get_test.dart b/packages/flutter_tools/test/dart/pub_get_test.dart index 16e23f3a9d..ec4773f8ef 100644 --- a/packages/flutter_tools/test/dart/pub_get_test.dart +++ b/packages/flutter_tools/test/dart/pub_get_test.dart @@ -251,13 +251,13 @@ class MockFile implements File { } class MockDirectory implements Directory { - static bool findCache = false; - MockDirectory(this.path); @override final String path; + static bool findCache = false; + @override bool existsSync() => findCache && path.endsWith('.pub-cache'); diff --git a/packages/flutter_tools/test/devfs_test.dart b/packages/flutter_tools/test/devfs_test.dart index c834d02b72..d3c72bca4a 100644 --- a/packages/flutter_tools/test/devfs_test.dart +++ b/packages/flutter_tools/test/devfs_test.dart @@ -424,14 +424,14 @@ void main() { } class MockVMService extends BasicMock implements VMService { - Uri _httpAddress; - HttpServer _server; - MockVM _vm; - MockVMService() { _vm = MockVM(this); } + Uri _httpAddress; + HttpServer _server; + MockVM _vm; + @override Uri get httpAddress => _httpAddress; @@ -468,14 +468,14 @@ class MockVMService extends BasicMock implements VMService { } class MockVM implements VM { + MockVM(this._service); + final MockVMService _service; final Uri _baseUri = Uri.parse('file:///tmp/devfs/test'); bool _devFSExists = false; static const int kFileSystemAlreadyExists = 1001; - MockVM(this._service); - @override Future> createDevFS(String fsName) async { _service.messages.add('create $fsName'); diff --git a/packages/flutter_tools/test/device_test.dart b/packages/flutter_tools/test/device_test.dart index 286ee49348..db32c3d727 100644 --- a/packages/flutter_tools/test/device_test.dart +++ b/packages/flutter_tools/test/device_test.dart @@ -39,10 +39,10 @@ void main() { } class TestDeviceManager extends DeviceManager { - final List allDevices; - TestDeviceManager(this.allDevices); + final List allDevices; + @override Stream getAllConnectedDevices() { return Stream.fromIterable(allDevices); @@ -50,11 +50,11 @@ class TestDeviceManager extends DeviceManager { } class _MockDevice extends Device { + _MockDevice(this.name, String id) : super(id); + @override final String name; - _MockDevice(this.name, String id) : super(id); - @override void noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); } diff --git a/packages/flutter_tools/test/emulator_test.dart b/packages/flutter_tools/test/emulator_test.dart index 01c7d4ce76..0bb149985b 100644 --- a/packages/flutter_tools/test/emulator_test.dart +++ b/packages/flutter_tools/test/emulator_test.dart @@ -152,10 +152,10 @@ void main() { } class TestEmulatorManager extends EmulatorManager { - final List allEmulators; - TestEmulatorManager(this.allEmulators); + final List allEmulators; + @override Future> getAllAvailableEmulators() { return Future>.value(allEmulators); diff --git a/packages/flutter_tools/test/hot_test.dart b/packages/flutter_tools/test/hot_test.dart index 9d92cd2d8a..0094422574 100644 --- a/packages/flutter_tools/test/hot_test.dart +++ b/packages/flutter_tools/test/hot_test.dart @@ -135,10 +135,10 @@ class MockDevice extends Mock implements Device { } class TestHotRunnerConfig extends HotRunnerConfig { - bool successfulSetup; - TestHotRunnerConfig({@required this.successfulSetup}); + bool successfulSetup; + @override Future setupHotRestart() async { return successfulSetup; diff --git a/packages/flutter_tools/test/protocol_discovery_test.dart b/packages/flutter_tools/test/protocol_discovery_test.dart index 0bd6606f60..d8499f2dbf 100644 --- a/packages/flutter_tools/test/protocol_discovery_test.dart +++ b/packages/flutter_tools/test/protocol_discovery_test.dart @@ -223,9 +223,10 @@ void main() { } class MockPortForwarder extends DevicePortForwarder { - final int availablePort; MockPortForwarder([this.availablePort]); + final int availablePort; + @override Future forward(int devicePort, {int hostPort}) async { hostPort ??= 0; diff --git a/packages/flutter_tools/test/src/mocks.dart b/packages/flutter_tools/test/src/mocks.dart index 5bcb4bcce9..eec77f162d 100644 --- a/packages/flutter_tools/test/src/mocks.dart +++ b/packages/flutter_tools/test/src/mocks.dart @@ -308,12 +308,12 @@ class MockStdio extends Stdio { } class MockPollingDeviceDiscovery extends PollingDeviceDiscovery { + MockPollingDeviceDiscovery() : super('mock'); + final List _devices = []; final StreamController _onAddedController = StreamController.broadcast(); final StreamController _onRemovedController = StreamController.broadcast(); - MockPollingDeviceDiscovery() : super('mock'); - @override Future> pollingGetDevices() async => _devices;