Commit a9ba0e2f authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

prefer_initializing_formals (#8797)

parent f8238185
......@@ -393,10 +393,9 @@ class _RectangleDemoState extends State<_RectangleDemo> {
typedef Widget _DemoBuilder(_ArcDemo demo);
class _ArcDemo {
_ArcDemo(String _title, this.builder, TickerProvider vsync)
: title = _title,
controller = new AnimationController(duration: const Duration(milliseconds: 500), vsync: vsync),
key = new GlobalKey(debugLabel: _title);
_ArcDemo(this.title, this.builder, TickerProvider vsync)
: controller = new AnimationController(duration: const Duration(milliseconds: 500), vsync: vsync),
key = new GlobalKey(debugLabel: title);
final String title;
final _DemoBuilder builder;
......
......@@ -66,9 +66,8 @@ enum Operation { Addition, Subtraction, Multiplication, Division }
/// A token that represents an arithmetic operation symbol.
class OperationToken extends ExpressionToken {
OperationToken(Operation operation)
: operation = operation,
super(opString(operation));
OperationToken(this.operation)
: super(opString(operation));
Operation operation;
......
......@@ -548,11 +548,10 @@ class RenderBoxToRenderSectorAdapter extends RenderBox with RenderObjectWithChil
}
class RenderSolidColor extends RenderDecoratedSector {
RenderSolidColor(Color backgroundColor, {
RenderSolidColor(this.backgroundColor, {
this.desiredDeltaRadius: double.INFINITY,
this.desiredDeltaTheta: kTwoPi
}) : this.backgroundColor = backgroundColor,
super(new BoxDecoration(backgroundColor: backgroundColor));
}) : super(new BoxDecoration(backgroundColor: backgroundColor));
double desiredDeltaRadius;
double desiredDeltaTheta;
......
......@@ -9,9 +9,8 @@ class RenderSolidColorBox extends RenderDecoratedBox {
final Size desiredSize;
final Color backgroundColor;
RenderSolidColorBox(Color backgroundColor, { this.desiredSize: Size.infinite })
: backgroundColor = backgroundColor,
super(decoration: new BoxDecoration(backgroundColor: backgroundColor));
RenderSolidColorBox(this.backgroundColor, { this.desiredSize: Size.infinite })
: super(decoration: new BoxDecoration(backgroundColor: backgroundColor));
@override
double computeMinIntrinsicWidth(double height) {
......
......@@ -11,11 +11,11 @@ typedef void StockRowActionCallback(Stock stock);
class StockRow extends StatelessWidget {
StockRow({
Stock stock,
this.stock,
this.onPressed,
this.onDoubleTap,
this.onLongPressed
}) : this.stock = stock, super(key: new ObjectKey(stock));
}) : super(key: new ObjectKey(stock));
final Stock stock;
final StockRowActionCallback onPressed;
......
......@@ -86,8 +86,8 @@ final RRect _kTickFundamentalRRect = new RRect.fromLTRBXY(-10.0, 1.0, -5.0, -1.0
class _CupertinoActivityIndicatorPainter extends CustomPainter {
_CupertinoActivityIndicatorPainter({
Animation<double> position,
}) : position = position, super(repaint: position);
this.position,
}) : super(repaint: position);
final Animation<double> position;
......
......@@ -227,11 +227,10 @@ class DoubleTapGestureRecognizer extends GestureRecognizer {
class _TapGesture extends _TapTracker {
_TapGesture({
MultiTapGestureRecognizer gestureRecognizer,
this.gestureRecognizer,
PointerEvent event,
Duration longTapDelay
}) : gestureRecognizer = gestureRecognizer,
_lastPosition = event.position,
}) : _lastPosition = event.position,
super(
event: event,
entry: GestureBinding.instance.gestureArena.add(event.pointer, gestureRecognizer)
......
......@@ -164,7 +164,7 @@ class AppBar extends StatefulWidget {
this.title,
this.actions,
this.flexibleSpace,
AppBarBottomWidget bottom,
this.bottom,
this.elevation: 4,
this.backgroundColor,
this.brightness,
......@@ -174,8 +174,7 @@ class AppBar extends StatefulWidget {
this.centerTitle,
this.toolbarOpacity: 1.0,
this.bottomOpacity: 1.0,
}) : bottom = bottom,
_bottomHeight = bottom?.bottomHeight ?? 0.0,
}) : _bottomHeight = bottom?.bottomHeight ?? 0.0,
super(key: key) {
assert(elevation != null);
assert(primary != null);
......@@ -497,7 +496,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
@required this.title,
@required this.actions,
@required this.flexibleSpace,
@required AppBarBottomWidget bottom,
@required this.bottom,
@required this.elevation,
@required this.backgroundColor,
@required this.brightness,
......@@ -510,8 +509,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
@required this.topPadding,
@required this.floating,
@required this.pinned,
}) : bottom = bottom,
_bottomHeight = bottom?.bottomHeight ?? 0.0 {
}) : _bottomHeight = bottom?.bottomHeight ?? 0.0 {
assert(primary || topPadding == 0.0);
}
......
......@@ -253,13 +253,12 @@ class DataTable extends StatelessWidget {
/// otherwise it should be false.
DataTable({
Key key,
List<DataColumn> columns,
this.columns,
this.sortColumnIndex,
this.sortAscending: true,
this.onSelectAll,
this.rows
}) : columns = columns,
_onlyTextColumn = _initOnlyTextColumn(columns), super(key: key) {
}) : _onlyTextColumn = _initOnlyTextColumn(columns), super(key: key) {
assert(columns != null);
assert(columns.isNotEmpty);
assert(sortColumnIndex == null || (sortColumnIndex >= 0 && sortColumnIndex < columns.length));
......
......@@ -26,14 +26,11 @@ const EdgeInsets _kMenuHorizontalPadding = const EdgeInsets.symmetric(horizontal
class _DropdownMenuPainter extends CustomPainter {
_DropdownMenuPainter({
Color color,
int elevation,
this.color,
this.elevation,
this.selectedIndex,
Animation<double> resize,
}) : color = color,
elevation = elevation,
resize = resize,
_painter = new BoxDecoration(
this.resize,
}) : _painter = new BoxDecoration(
// If you add a background image here, you must provide a real
// configuration in the paint() function and you must provide some sort
// of onChanged callback here.
......@@ -95,8 +92,8 @@ class _DropdownScrollBehavior extends ScrollBehavior {
class _DropdownMenu<T> extends StatefulWidget {
_DropdownMenu({
Key key,
_DropdownRoute<T> route,
}) : route = route, super(key: key);
this.route,
}) : super(key: key);
final _DropdownRoute<T> route;
......
......@@ -206,18 +206,13 @@ class _CircularProgressIndicatorPainter extends CustomPainter {
_CircularProgressIndicatorPainter({
this.valueColor,
double value,
double headValue,
double tailValue,
int stepValue,
double rotationValue,
this.value,
this.headValue,
this.tailValue,
this.stepValue,
this.rotationValue,
this.strokeWidth
}) : this.value = value,
this.headValue = headValue,
this.tailValue = tailValue,
this.stepValue = stepValue,
this.rotationValue = rotationValue,
arcStart = value != null
}) : arcStart = value != null
? _kStartAngle
: _kStartAngle + tailValue * 3 / 2 * math.PI + rotationValue * math.PI * 1.7 - stepValue * 0.8 * math.PI,
arcSweep = value != null
......
......@@ -50,10 +50,9 @@ class FlutterLogoDecoration extends Decoration {
const FlutterLogoDecoration({
this.swatch: _kDefaultSwatch,
this.textColor: const Color(0xFF616161),
FlutterLogoStyle style: FlutterLogoStyle.markOnly,
this.style: FlutterLogoStyle.markOnly,
this.margin: EdgeInsets.zero,
}) : style = style,
_position = style == FlutterLogoStyle.markOnly ? 0.0 : style == FlutterLogoStyle.horizontal ? 1.0 : -1.0, // ignore: CONST_EVAL_TYPE_BOOL_NUM_STRING
}) : _position = style == FlutterLogoStyle.markOnly ? 0.0 : style == FlutterLogoStyle.horizontal ? 1.0 : -1.0, // ignore: CONST_EVAL_TYPE_BOOL_NUM_STRING
// (see https://github.com/dart-lang/sdk/issues/26980 for details about that ignore statement)
_opacity = 1.0;
......
......@@ -94,13 +94,11 @@ class TextSelection extends TextRange {
///
/// The [baseOffset] and [extentOffset] arguments must not be null.
const TextSelection({
@required int baseOffset,
@required int extentOffset,
@required this.baseOffset,
@required this.extentOffset,
this.affinity: TextAffinity.downstream,
this.isDirectional: false
}) : baseOffset = baseOffset,
extentOffset = extentOffset,
super(
}) : super(
start: baseOffset < extentOffset ? baseOffset : extentOffset,
end: baseOffset < extentOffset ? extentOffset : baseOffset
);
......
......@@ -29,12 +29,10 @@ class SpringDescription {
/// See [mass] and [springConstant] for the units for those arguments. The
/// damping ratio is unitless.
SpringDescription.withDampingRatio({
double mass,
double springConstant,
this.mass,
this.springConstant,
double ratio: 1.0
}) : mass = mass,
springConstant = springConstant,
damping = ratio * 2.0 * math.sqrt(mass * springConstant);
}) : damping = ratio * 2.0 * math.sqrt(mass * springConstant);
/// The mass of the spring (m). The units are arbitrary, but all springs
/// within a system should use the same mass units.
......
......@@ -826,9 +826,9 @@ class LayoutId extends ParentDataWidget<CustomMultiChildLayout> {
/// Both the child and the id arguments must not be null.
LayoutId({
Key key,
@required Object id,
@required this.id,
@required Widget child
}) : id = id, super(key: key ?? new ValueKey<Object>(id), child: child) {
}) : super(key: key ?? new ValueKey<Object>(id), child: child) {
assert(child != null);
assert(id != null);
}
......@@ -2610,9 +2610,9 @@ class WidgetToRenderBoxAdapter extends LeafRenderObjectWidget {
///
/// The [renderBox] argument must not be null.
WidgetToRenderBoxAdapter({
@required RenderBox renderBox,
@required this.renderBox,
this.onBuild
}) : renderBox = renderBox,
}) :
// WidgetToRenderBoxAdapter objects are keyed to their render box. This
// prevents the widget being used in the widget hierarchy in two different
// places, which would cause the RenderBox to get inserted in multiple
......
......@@ -445,9 +445,9 @@ class RenderObjectToWidgetAdapter<T extends RenderObject> extends RenderObjectWi
/// Used by [WidgetsBinding] to attach the root widget to the [RenderView].
RenderObjectToWidgetAdapter({
this.child,
RenderObjectWithChildMixin<T> container,
this.container,
this.debugShortDescription
}) : container = container, super(key: new GlobalObjectKey(container));
}) : super(key: new GlobalObjectKey(container));
/// The widget below this widget in the tree.
final Widget child;
......
......@@ -129,8 +129,8 @@ class Dismissable extends StatefulWidget {
class _DismissableClipper extends CustomClipper<Rect> {
_DismissableClipper({
this.axis,
Animation<FractionalOffset> moveAnimation
}) : moveAnimation = moveAnimation, super(reclip: moveAnimation) {
this.moveAnimation
}) : super(reclip: moveAnimation) {
assert(axis != null);
assert(moveAnimation != null);
}
......
......@@ -154,7 +154,7 @@ class OverlayEntry {
}
class _OverlayEntry extends StatefulWidget {
_OverlayEntry(OverlayEntry entry) : entry = entry, super(key: entry._key) {
_OverlayEntry(this.entry) : super(key: entry._key) {
assert(entry != null);
}
......
......@@ -93,14 +93,13 @@ class Table extends RenderObjectWidget {
/// arguments must not be null.
Table({
Key key,
List<TableRow> children: const <TableRow>[],
this.children: const <TableRow>[],
this.columnWidths,
this.defaultColumnWidth: const FlexColumnWidth(1.0),
this.border,
this.defaultVerticalAlignment: TableCellVerticalAlignment.top,
this.textBaseline
}) : children = children,
_rowDecorations = children.any((TableRow row) => row.decoration != null)
}) : _rowDecorations = children.any((TableRow row) => row.decoration != null)
? children.map<Decoration>((TableRow row) => row.decoration).toList(growable: false)
: null,
super(key: key) {
......
......@@ -67,7 +67,7 @@ class FixedSizeLayoutDelegate extends SingleChildLayoutDelegate {
}
class NotifierLayoutDelegate extends SingleChildLayoutDelegate {
NotifierLayoutDelegate(ValueNotifier<Size> size) : size = size, super(relayout: size);
NotifierLayoutDelegate(this.size) : super(relayout: size);
final ValueNotifier<Size> size;
......
......@@ -6,9 +6,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/widgets.dart';
class TestFlowDelegate extends FlowDelegate {
TestFlowDelegate({
Animation<double> startOffset
}) : startOffset = startOffset, super(repaint: startOffset);
TestFlowDelegate({this.startOffset}) : super(repaint: startOffset);
final Animation<double> startOffset;
......
......@@ -161,9 +161,8 @@ class ByValueKey extends SerializableFinder {
final String finderType = 'ByValueKey';
/// Creates a finder given the key value.
ByValueKey(dynamic keyValue)
: this.keyValue = keyValue,
this.keyValueString = '$keyValue',
ByValueKey(this.keyValue)
: this.keyValueString = '$keyValue',
this.keyValueType = '${keyValue.runtimeType}' {
if (!_supportedKeyValueTypes.contains(keyValue.runtimeType))
throw _createInvalidKeyValueTypeError('$keyValue.runtimeType');
......
......@@ -22,9 +22,8 @@ class MatchResult {
: hasMatched = true,
mismatchDescription = null;
MatchResult._mismatched(String mismatchDescription)
: hasMatched = false,
mismatchDescription = mismatchDescription;
MatchResult._mismatched(this.mismatchDescription)
: hasMatched = false;
/// Whether the match succeeded.
final bool hasMatched;
......
......@@ -184,8 +184,6 @@ class TimedEvent {
final Duration duration;
/// Creates a timed event given begin and end timestamps in microseconds.
TimedEvent(int beginTimeMicros, int endTimeMicros)
: this.beginTimeMicros = beginTimeMicros,
this.endTimeMicros = endTimeMicros,
this.duration = new Duration(microseconds: endTimeMicros - beginTimeMicros);
TimedEvent(this.beginTimeMicros, this.endTimeMicros)
: this.duration = new Duration(microseconds: endTimeMicros - beginTimeMicros);
}
......@@ -23,9 +23,8 @@ Iterable<Element> collectAllElementsFrom(Element rootElement, {
}
class _DepthFirstChildIterator implements Iterator<Element> {
_DepthFirstChildIterator(Element rootElement, bool skipOffstage)
: skipOffstage = skipOffstage,
_stack = _reverseChildrenOf(rootElement, skipOffstage).toList();
_DepthFirstChildIterator(Element rootElement, this.skipOffstage)
: _stack = _reverseChildrenOf(rootElement, skipOffstage).toList();
final bool skipOffstage;
......
......@@ -829,10 +829,9 @@ const int _kPointerDecay = -2;
class _LiveTestPointerRecord {
_LiveTestPointerRecord(
int pointer,
this.pointer,
this.position
) : pointer = pointer,
color = new HSVColor.fromAHSV(0.8, (35.0 * pointer) % 360.0, 1.0, 1.0).toColor(),
) : color = new HSVColor.fromAHSV(0.8, (35.0 * pointer) % 360.0, 1.0, 1.0).toColor(),
decay = 1;
final int pointer;
final Color color;
......
......@@ -298,13 +298,12 @@ class _DevFSHttpWriter {
class DevFS {
/// Create a [DevFS] named [fsName] for the local files in [directory].
DevFS(VMService serviceProtocol,
String fsName,
this.fsName,
this.rootDirectory, {
String packagesFilePath
})
: _operations = new ServiceProtocolDevFSOperations(serviceProtocol),
_httpWriter = new _DevFSHttpWriter(fsName, serviceProtocol),
fsName = fsName {
_httpWriter = new _DevFSHttpWriter(fsName, serviceProtocol) {
_packagesFilePath =
packagesFilePath ?? fs.path.join(rootDirectory.path, kPackagesFileName);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment