From e4546584d16b103c018a06027aaa02d9c43a2c7f Mon Sep 17 00:00:00 2001 From: Alexandre Ardhuin Date: Wed, 10 May 2017 08:45:36 +0200 Subject: [PATCH] enable always_require_non_null_named_parameters lint (#9948) * enable always_require_non_null_named_parameters lint * Update home.dart --- .analysis_options | 2 +- .analysis_options_repo | 2 +- examples/catalog/lib/animated_list.dart | 4 ++-- .../flutter_gallery/lib/demo/animation/home.dart | 8 +++++--- .../flutter/lib/src/gestures/velocity_tracker.dart | 14 +++++++++----- packages/flutter/lib/src/material/data_table.dart | 4 ++-- packages/flutter/lib/src/painting/box_painter.dart | 6 +++--- 7 files changed, 23 insertions(+), 17 deletions(-) diff --git a/.analysis_options b/.analysis_options index 0532ddc72b0..bd0b82261b2 100644 --- a/.analysis_options +++ b/.analysis_options @@ -67,7 +67,7 @@ linter: # === style rules === - always_declare_return_types # - always_put_control_body_on_new_line # not yet tested - # - always_require_non_null_named_parameters # not yet tested + - always_require_non_null_named_parameters - always_specify_types - annotate_overrides # - avoid_annotating_with_dynamic # not yet tested diff --git a/.analysis_options_repo b/.analysis_options_repo index b627cd69666..2b148ddd186 100644 --- a/.analysis_options_repo +++ b/.analysis_options_repo @@ -65,7 +65,7 @@ linter: # === style rules === - always_declare_return_types # - always_put_control_body_on_new_line # not yet tested - # - always_require_non_null_named_parameters # not yet tested + - always_require_non_null_named_parameters - always_specify_types - annotate_overrides # - avoid_annotating_with_dynamic # not yet tested diff --git a/examples/catalog/lib/animated_list.dart b/examples/catalog/lib/animated_list.dart index 1a71470859e..4cddd4284e3 100644 --- a/examples/catalog/lib/animated_list.dart +++ b/examples/catalog/lib/animated_list.dart @@ -20,9 +20,9 @@ import 'package:flutter/material.dart'; class CardItem extends StatelessWidget { CardItem({ Key key, - this.animation, + @required this.animation, this.onTap, - this.item, + @required this.item, this.selected: false }) : super(key: key) { assert(animation != null); diff --git a/examples/flutter_gallery/lib/demo/animation/home.dart b/examples/flutter_gallery/lib/demo/animation/home.dart index 698704692a8..e617c8411d5 100644 --- a/examples/flutter_gallery/lib/demo/animation/home.dart +++ b/examples/flutter_gallery/lib/demo/animation/home.dart @@ -371,9 +371,11 @@ class _AllSectionsView extends AnimatedWidget { // app bar's height is _kAppBarMidHeight and only one section heading is // visible. class _SnappingScrollPhysics extends ClampingScrollPhysics { - _SnappingScrollPhysics({ ScrollPhysics parent, this.midScrollOffset }) : super(parent: parent) { - assert(midScrollOffset != null); - } + _SnappingScrollPhysics({ + ScrollPhysics parent, + @required this.midScrollOffset, + }) : assert(midScrollOffset != null), + super(parent: parent); final double midScrollOffset; diff --git a/packages/flutter/lib/src/gestures/velocity_tracker.dart b/packages/flutter/lib/src/gestures/velocity_tracker.dart index e1081ddabc0..485d10be97c 100644 --- a/packages/flutter/lib/src/gestures/velocity_tracker.dart +++ b/packages/flutter/lib/src/gestures/velocity_tracker.dart @@ -4,6 +4,8 @@ import 'dart:ui' show Offset; +import 'package:flutter/foundation.dart'; + import 'lsq_solver.dart'; export 'dart:ui' show Offset; @@ -13,7 +15,9 @@ class Velocity { /// Creates a velocity. /// /// The [pixelsPerSecond] argument must not be null. - const Velocity({ this.pixelsPerSecond }) : assert(pixelsPerSecond != null); + const Velocity({ + @required this.pixelsPerSecond, + }) : assert(pixelsPerSecond != null); /// A velocity that isn't moving at all. static const Velocity zero = const Velocity(pixelsPerSecond: Offset.zero); @@ -90,10 +94,10 @@ class VelocityEstimate { /// /// [pixelsPerSecond], [confidence], [duration], and [offset] must not be null. const VelocityEstimate({ - this.pixelsPerSecond, - this.confidence, - this.duration, - this.offset, + @required this.pixelsPerSecond, + @required this.confidence, + @required this.duration, + @required this.offset, }) : assert(pixelsPerSecond != null), assert(confidence != null), assert(duration != null), diff --git a/packages/flutter/lib/src/material/data_table.dart b/packages/flutter/lib/src/material/data_table.dart index a08f0581f67..28703926b83 100644 --- a/packages/flutter/lib/src/material/data_table.dart +++ b/packages/flutter/lib/src/material/data_table.dart @@ -91,7 +91,7 @@ class DataRow { this.key, this.selected: false, this.onSelectChanged, - this.cells + @required this.cells }) : assert(cells != null); /// Creates the configuration for a row of a [DataTable], deriving @@ -102,7 +102,7 @@ class DataRow { int index, this.selected: false, this.onSelectChanged, - this.cells + @required this.cells }) : assert(cells != null), key = new ValueKey(index); diff --git a/packages/flutter/lib/src/painting/box_painter.dart b/packages/flutter/lib/src/painting/box_painter.dart index e49250724f1..f5e16e14262 100644 --- a/packages/flutter/lib/src/painting/box_painter.dart +++ b/packages/flutter/lib/src/painting/box_painter.dart @@ -786,7 +786,7 @@ class LinearGradient extends Gradient { const LinearGradient({ this.begin: FractionalOffset.centerLeft, this.end: FractionalOffset.centerRight, - this.colors, + @required this.colors, this.stops, this.tileMode: TileMode.clamp, }) : assert(begin != null), @@ -1000,7 +1000,7 @@ class RadialGradient extends Gradient { const RadialGradient({ this.center: FractionalOffset.center, this.radius: 0.5, - this.colors, + @required this.colors, this.stops, this.tileMode: TileMode.clamp, }) : assert(center != null), @@ -1262,7 +1262,7 @@ class DecorationImage { /// /// The [image] argument must not be null. const DecorationImage({ - this.image, + @required this.image, this.fit, this.repeat: ImageRepeat.noRepeat, this.centerSlice,