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

Flutter style guide: Prefer naming the argument to a setter 'value' (#8691)

parent 7b9cefb3
...@@ -225,10 +225,10 @@ class _RenderCupertinoSlider extends RenderConstrainedBox implements SemanticsAc ...@@ -225,10 +225,10 @@ class _RenderCupertinoSlider extends RenderConstrainedBox implements SemanticsAc
int get divisions => _divisions; int get divisions => _divisions;
int _divisions; int _divisions;
set divisions(int newDivisions) { set divisions(int value) {
if (newDivisions == _divisions) if (value == _divisions)
return; return;
_divisions = newDivisions; _divisions = value;
markNeedsPaint(); markNeedsPaint();
} }
......
...@@ -316,27 +316,27 @@ class _RenderSlider extends RenderConstrainedBox implements SemanticsActionHandl ...@@ -316,27 +316,27 @@ class _RenderSlider extends RenderConstrainedBox implements SemanticsActionHandl
int get divisions => _divisions; int get divisions => _divisions;
int _divisions; int _divisions;
set divisions(int newDivisions) { set divisions(int value) {
if (newDivisions == _divisions) if (value == _divisions)
return; return;
_divisions = newDivisions; _divisions = value;
markNeedsPaint(); markNeedsPaint();
} }
String get label => _label; String get label => _label;
String _label; String _label;
set label(String newLabel) { set label(String value) {
if (newLabel == _label) if (value == _label)
return; return;
_label = newLabel; _label = value;
additionalConstraints = _getAdditionalConstraints(_label); additionalConstraints = _getAdditionalConstraints(_label);
if (newLabel != null) { if (value != null) {
// TODO(abarth): Handle textScaleFactor. // TODO(abarth): Handle textScaleFactor.
// https://github.com/flutter/flutter/issues/5938 // https://github.com/flutter/flutter/issues/5938
_labelPainter _labelPainter
..text = new TextSpan( ..text = new TextSpan(
style: _textTheme.body1.copyWith(fontSize: 10.0), style: _textTheme.body1.copyWith(fontSize: 10.0),
text: newLabel text: value
) )
..layout(); ..layout();
} else { } else {
......
...@@ -148,13 +148,13 @@ class TabController extends ChangeNotifier { ...@@ -148,13 +148,13 @@ class TabController extends ChangeNotifier {
/// TabBarView has been dragged to the left. Similarly a value between /// TabBarView has been dragged to the left. Similarly a value between
/// 0.0 and 1.0 implies that the TabBarView has been dragged to the right. /// 0.0 and 1.0 implies that the TabBarView has been dragged to the right.
double get offset => _animationController.value - _index.toDouble(); double get offset => _animationController.value - _index.toDouble();
set offset(double newOffset) { set offset(double value) {
assert(newOffset != null); assert(value != null);
assert(newOffset >= -1.0 && newOffset <= 1.0); assert(value >= -1.0 && value <= 1.0);
assert(!indexIsChanging); assert(!indexIsChanging);
if (newOffset == offset) if (value == offset)
return; return;
_animationController.value = newOffset + _index.toDouble(); _animationController.value = value + _index.toDouble();
} }
@override @override
......
...@@ -69,8 +69,8 @@ abstract class SimulationGroup extends Simulation { ...@@ -69,8 +69,8 @@ abstract class SimulationGroup extends Simulation {
} }
@override @override
set tolerance(Tolerance t) { set tolerance(Tolerance value) {
currentSimulation.tolerance = t; currentSimulation.tolerance = value;
super.tolerance = t; super.tolerance = value;
} }
} }
...@@ -282,13 +282,13 @@ class RenderCustomMultiChildLayoutBox extends RenderBox ...@@ -282,13 +282,13 @@ class RenderCustomMultiChildLayoutBox extends RenderBox
/// The delegate that controls the layout of the children. /// The delegate that controls the layout of the children.
MultiChildLayoutDelegate get delegate => _delegate; MultiChildLayoutDelegate get delegate => _delegate;
MultiChildLayoutDelegate _delegate; MultiChildLayoutDelegate _delegate;
set delegate (MultiChildLayoutDelegate newDelegate) { set delegate (MultiChildLayoutDelegate value) {
assert(newDelegate != null); assert(value != null);
if (_delegate == newDelegate) if (_delegate == value)
return; return;
if (newDelegate.runtimeType != _delegate.runtimeType || newDelegate.shouldRelayout(_delegate)) if (value.runtimeType != _delegate.runtimeType || value.shouldRelayout(_delegate))
markNeedsLayout(); markNeedsLayout();
_delegate = newDelegate; _delegate = value;
} }
Size _getSize(BoxConstraints constraints) { Size _getSize(BoxConstraints constraints) {
......
...@@ -77,11 +77,11 @@ class RenderPerformanceOverlay extends RenderBox { ...@@ -77,11 +77,11 @@ class RenderPerformanceOverlay extends RenderBox {
/// [PerformanceOverlayOption] to enable. /// [PerformanceOverlayOption] to enable.
int get optionsMask => _optionsMask; int get optionsMask => _optionsMask;
int _optionsMask; int _optionsMask;
set optionsMask(int mask) { set optionsMask(int value) {
assert(mask != null); assert(value != null);
if (mask == _optionsMask) if (value == _optionsMask)
return; return;
_optionsMask = mask; _optionsMask = value;
markNeedsPaint(); markNeedsPaint();
} }
...@@ -90,22 +90,22 @@ class RenderPerformanceOverlay extends RenderBox { ...@@ -90,22 +90,22 @@ class RenderPerformanceOverlay extends RenderBox {
/// is suitable for capturing an SkPicture trace for further analysis. /// is suitable for capturing an SkPicture trace for further analysis.
int get rasterizerThreshold => _rasterizerThreshold; int get rasterizerThreshold => _rasterizerThreshold;
int _rasterizerThreshold; int _rasterizerThreshold;
set rasterizerThreshold (int threshold) { set rasterizerThreshold (int value) {
assert(threshold != null); assert(value != null);
if (threshold == _rasterizerThreshold) if (value == _rasterizerThreshold)
return; return;
_rasterizerThreshold = threshold; _rasterizerThreshold = value;
markNeedsPaint(); markNeedsPaint();
} }
/// Whether the raster cache should checkerboard cached entries. /// Whether the raster cache should checkerboard cached entries.
bool get checkerboardRasterCacheImages => _checkerboardRasterCacheImages; bool get checkerboardRasterCacheImages => _checkerboardRasterCacheImages;
bool _checkerboardRasterCacheImages; bool _checkerboardRasterCacheImages;
set checkerboardRasterCacheImages (bool checkerboard) { set checkerboardRasterCacheImages (bool value) {
assert(checkerboard != null); assert(value != null);
if (checkerboard == _checkerboardRasterCacheImages) if (value == _checkerboardRasterCacheImages)
return; return;
_checkerboardRasterCacheImages = checkerboard; _checkerboardRasterCacheImages = value;
markNeedsPaint(); markNeedsPaint();
} }
......
...@@ -212,11 +212,11 @@ abstract class RenderAligningShiftedBox extends RenderShiftedBox { ...@@ -212,11 +212,11 @@ abstract class RenderAligningShiftedBox extends RenderShiftedBox {
/// Sets the alignment to a new value, and triggers a layout update. /// Sets the alignment to a new value, and triggers a layout update.
/// ///
/// The new alignment must not be null or have any null properties. /// The new alignment must not be null or have any null properties.
set alignment (FractionalOffset newAlignment) { set alignment (FractionalOffset value) {
assert(newAlignment != null && newAlignment.dx != null && newAlignment.dy != null); assert(value != null && value.dx != null && value.dy != null);
if (_alignment == newAlignment) if (_alignment == value)
return; return;
_alignment = newAlignment; _alignment = value;
markNeedsLayout(); markNeedsLayout();
} }
......
...@@ -163,11 +163,11 @@ class RenderSliverFixedExtentList extends RenderSliverFixedExtentBoxAdaptor { ...@@ -163,11 +163,11 @@ class RenderSliverFixedExtentList extends RenderSliverFixedExtentBoxAdaptor {
@override @override
double get itemExtent => _itemExtent; double get itemExtent => _itemExtent;
double _itemExtent; double _itemExtent;
set itemExtent (double newValue) { set itemExtent (double value) {
assert(newValue != null); assert(value != null);
if (_itemExtent == newValue) if (_itemExtent == value)
return; return;
_itemExtent = newValue; _itemExtent = value;
markNeedsLayout(); markNeedsLayout();
} }
} }
...@@ -186,11 +186,11 @@ class RenderSliverFill extends RenderSliverFixedExtentBoxAdaptor { ...@@ -186,11 +186,11 @@ class RenderSliverFill extends RenderSliverFixedExtentBoxAdaptor {
double get viewportFraction => _viewportFraction; double get viewportFraction => _viewportFraction;
double _viewportFraction; double _viewportFraction;
set viewportFraction (double newValue) { set viewportFraction (double value) {
assert(newValue != null); assert(value != null);
if (_viewportFraction == newValue) if (_viewportFraction == value)
return; return;
_viewportFraction = newValue; _viewportFraction = value;
markNeedsLayout(); markNeedsLayout();
} }
......
...@@ -426,14 +426,14 @@ class RenderSliverGrid extends RenderSliverMultiBoxAdaptor { ...@@ -426,14 +426,14 @@ class RenderSliverGrid extends RenderSliverMultiBoxAdaptor {
SliverGridDelegate get gridDelegate => _gridDelegate; SliverGridDelegate get gridDelegate => _gridDelegate;
SliverGridDelegate _gridDelegate; SliverGridDelegate _gridDelegate;
set gridDelegate(SliverGridDelegate newDelegate) { set gridDelegate(SliverGridDelegate value) {
assert(newDelegate != null); assert(value != null);
if (_gridDelegate == newDelegate) if (_gridDelegate == value)
return; return;
if (newDelegate.runtimeType != _gridDelegate.runtimeType || if (value.runtimeType != _gridDelegate.runtimeType ||
newDelegate.shouldRelayout(_gridDelegate)) value.shouldRelayout(_gridDelegate))
markNeedsLayout(); markNeedsLayout();
_gridDelegate = newDelegate; _gridDelegate = value;
} }
@override @override
......
...@@ -159,11 +159,11 @@ class _PagePosition extends ScrollPosition { ...@@ -159,11 +159,11 @@ class _PagePosition extends ScrollPosition {
double get viewportFraction => _viewportFraction; double get viewportFraction => _viewportFraction;
double _viewportFraction; double _viewportFraction;
set viewportFraction(double newValue) { set viewportFraction(double value) {
if (_viewportFraction == newValue) if (_viewportFraction == value)
return; return;
final double oldPage = page; final double oldPage = page;
_viewportFraction = newValue; _viewportFraction = value;
if (oldPage != null) if (oldPage != null)
correctPixels(getPixelsFromPage(oldPage)); correctPixels(getPixelsFromPage(oldPage));
} }
......
...@@ -23,11 +23,11 @@ class PlaceholderState extends State<Placeholder> { ...@@ -23,11 +23,11 @@ class PlaceholderState extends State<Placeholder> {
/// Mutating this field will cause this widget to rebuild with the new child. /// Mutating this field will cause this widget to rebuild with the new child.
Widget get child => _child; Widget get child => _child;
Widget _child; Widget _child;
set child(Widget child) { set child(Widget value) {
if (_child == child) if (_child == value)
return; return;
setState(() { setState(() {
_child = child; _child = value;
}); });
} }
......
...@@ -356,9 +356,9 @@ class _Block { ...@@ -356,9 +356,9 @@ class _Block {
List<_Block> subBlocks; List<_Block> subBlocks;
bool get open => _open; bool get open => _open;
set open(bool open) { set open(bool value) {
_open = open; _open = value;
if (!open && subBlocks.isNotEmpty) if (!value && subBlocks.isNotEmpty)
subBlocks.last.isLast = true; subBlocks.last.isLast = true;
} }
......
...@@ -202,8 +202,8 @@ abstract class TestWidgetsFlutterBinding extends BindingBase ...@@ -202,8 +202,8 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
/// the focus change. /// the focus change.
EditableTextState get focusedEditable => _focusedEditable; EditableTextState get focusedEditable => _focusedEditable;
EditableTextState _focusedEditable; EditableTextState _focusedEditable;
set focusedEditable (EditableTextState editable) { set focusedEditable (EditableTextState value) {
_focusedEditable = editable..requestKeyboard(); _focusedEditable = value..requestKeyboard();
} }
/// Returns the exception most recently caught by the Flutter framework. /// Returns the exception most recently caught by the Flutter framework.
......
...@@ -113,8 +113,8 @@ class DevFSByteContent extends DevFSContent { ...@@ -113,8 +113,8 @@ class DevFSByteContent extends DevFSContent {
List<int> get bytes => _bytes; List<int> get bytes => _bytes;
set bytes(List<int> newBytes) { set bytes(List<int> value) {
_bytes = newBytes; _bytes = value;
_isModified = true; _isModified = true;
} }
...@@ -145,14 +145,14 @@ class DevFSStringContent extends DevFSByteContent { ...@@ -145,14 +145,14 @@ class DevFSStringContent extends DevFSByteContent {
String get string => _string; String get string => _string;
set string(String newString) { set string(String value) {
_string = newString; _string = value;
super.bytes = UTF8.encode(_string); super.bytes = UTF8.encode(_string);
} }
@override @override
set bytes(List<int> newBytes) { set bytes(List<int> value) {
string = UTF8.decode(newBytes); string = UTF8.decode(value);
} }
} }
......
...@@ -77,8 +77,8 @@ abstract class FlutterCommand extends Command<Null> { ...@@ -77,8 +77,8 @@ abstract class FlutterCommand extends Command<Null> {
help: 'Build a release version of your app${defaultToRelease ? ' (default mode)' : ''}.'); help: 'Build a release version of your app${defaultToRelease ? ' (default mode)' : ''}.');
} }
set defaultBuildMode(BuildMode buildMode) { set defaultBuildMode(BuildMode value) {
_defaultBuildMode = buildMode; _defaultBuildMode = value;
} }
BuildMode getBuildMode() { BuildMode getBuildMode() {
......
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