Unverified Commit bd69fa59 authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

use predefined constants (#74627)

parent efe8a397
...@@ -982,7 +982,7 @@ class _CupertinoModalPopupRoute<T> extends PopupRoute<T> { ...@@ -982,7 +982,7 @@ class _CupertinoModalPopupRoute<T> extends PopupRoute<T> {
); );
_offsetTween = Tween<Offset>( _offsetTween = Tween<Offset>(
begin: const Offset(0.0, 1.0), begin: const Offset(0.0, 1.0),
end: const Offset(0.0, 0.0), end: Offset.zero,
); );
return _animation!; return _animation!;
} }
......
...@@ -311,7 +311,7 @@ class _RenderCupertinoTextSelectionToolbarShape extends RenderShiftedBox { ...@@ -311,7 +311,7 @@ class _RenderCupertinoTextSelectionToolbarShape extends RenderShiftedBox {
_debugPaint ??= Paint() _debugPaint ??= Paint()
..shader = ui.Gradient.linear( ..shader = ui.Gradient.linear(
const Offset(0.0, 0.0), Offset.zero,
const Offset(10.0, 10.0), const Offset(10.0, 10.0),
const <Color>[Color(0x00000000), Color(0xFFFF00FF), Color(0xFFFF00FF), Color(0x00000000)], const <Color>[Color(0x00000000), Color(0xFFFF00FF), Color(0xFFFF00FF), Color(0x00000000)],
const <double>[0.25, 0.25, 0.75, 0.75], const <double>[0.25, 0.25, 0.75, 0.75],
......
...@@ -231,7 +231,7 @@ class _AutocompleteOptions<T extends Object> extends StatelessWidget { ...@@ -231,7 +231,7 @@ class _AutocompleteOptions<T extends Object> extends StatelessWidget {
child: Container( child: Container(
height: 200.0, height: 200.0,
child: ListView.builder( child: ListView.builder(
padding: const EdgeInsets.all(0.0), padding: EdgeInsets.zero,
itemCount: options.length, itemCount: options.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
final T option = options.elementAt(index); final T option = options.elementAt(index);
......
...@@ -66,7 +66,7 @@ class RawMaterialButton extends StatefulWidget { ...@@ -66,7 +66,7 @@ class RawMaterialButton extends StatefulWidget {
this.highlightElevation = 8.0, this.highlightElevation = 8.0,
this.disabledElevation = 0.0, this.disabledElevation = 0.0,
this.padding = EdgeInsets.zero, this.padding = EdgeInsets.zero,
this.visualDensity = const VisualDensity(), this.visualDensity = VisualDensity.standard,
this.constraints = const BoxConstraints(minWidth: 88.0, minHeight: 36.0), this.constraints = const BoxConstraints(minWidth: 88.0, minHeight: 36.0),
this.shape = const RoundedRectangleBorder(), this.shape = const RoundedRectangleBorder(),
this.animationDuration = kThemeChangeDuration, this.animationDuration = kThemeChangeDuration,
......
...@@ -1053,9 +1053,9 @@ class _DateRangePickerDialogState extends State<_DateRangePickerDialog> { ...@@ -1053,9 +1053,9 @@ class _DateRangePickerDialogState extends State<_DateRangePickerDialog> {
helpText: widget.helpText ?? localizations.dateRangePickerHelpText, helpText: widget.helpText ?? localizations.dateRangePickerHelpText,
); );
size = mediaQuery.size; size = mediaQuery.size;
insetPadding = const EdgeInsets.all(0.0); insetPadding = EdgeInsets.zero;
shape = const RoundedRectangleBorder( shape = const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.zero) borderRadius: BorderRadius.zero
); );
elevation = 0; elevation = 0;
break; break;
......
...@@ -128,7 +128,7 @@ class Dialog extends StatelessWidget { ...@@ -128,7 +128,7 @@ class Dialog extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final DialogTheme dialogTheme = DialogTheme.of(context); final DialogTheme dialogTheme = DialogTheme.of(context);
final EdgeInsets effectivePadding = MediaQuery.of(context).viewInsets + (insetPadding ?? const EdgeInsets.all(0.0)); final EdgeInsets effectivePadding = MediaQuery.of(context).viewInsets + (insetPadding ?? EdgeInsets.zero);
return AnimatedPadding( return AnimatedPadding(
padding: effectivePadding, padding: effectivePadding,
duration: insetAnimationDuration, duration: insetAnimationDuration,
......
...@@ -396,7 +396,7 @@ class _HelperErrorState extends State<_HelperError> with SingleTickerProviderSta ...@@ -396,7 +396,7 @@ class _HelperErrorState extends State<_HelperError> with SingleTickerProviderSta
child: FractionalTranslation( child: FractionalTranslation(
translation: Tween<Offset>( translation: Tween<Offset>(
begin: const Offset(0.0, -0.25), begin: const Offset(0.0, -0.25),
end: const Offset(0.0, 0.0), end: Offset.zero,
).evaluate(_controller.view), ).evaluate(_controller.view),
child: Text( child: Text(
widget.errorText!, widget.errorText!,
...@@ -1284,7 +1284,7 @@ class _RenderDecoration extends RenderBox { ...@@ -1284,7 +1284,7 @@ class _RenderDecoration extends RenderBox {
assert(debugCannotComputeDryLayout( assert(debugCannotComputeDryLayout(
reason: 'Layout requires baseline metrics, which are only available after a full layout.', reason: 'Layout requires baseline metrics, which are only available after a full layout.',
)); ));
return const Size(0, 0); return Size.zero;
} }
@override @override
......
...@@ -1691,7 +1691,7 @@ class _RenderListTile extends RenderBox { ...@@ -1691,7 +1691,7 @@ class _RenderListTile extends RenderBox {
assert(debugCannotComputeDryLayout( assert(debugCannotComputeDryLayout(
reason: 'Layout requires baseline metrics, which are only available after a full layout.' reason: 'Layout requires baseline metrics, which are only available after a full layout.'
)); ));
return const Size(0, 0); return Size.zero;
} }
// All of the dimensions below were taken from the Material Design spec: // All of the dimensions below were taken from the Material Design spec:
......
...@@ -419,7 +419,7 @@ class _ReorderableListContentState extends State<_ReorderableListContent> { ...@@ -419,7 +419,7 @@ class _ReorderableListContentState extends State<_ReorderableListContent> {
// so we wrap the CustomScrollView in the padding for the top, left and right // so we wrap the CustomScrollView in the padding for the top, left and right
// and only add the padding from the bottom to the sliver list (or the equivalent // and only add the padding from the bottom to the sliver list (or the equivalent
// for other axis directions). // for other axis directions).
final EdgeInsets padding = widget.padding ?? const EdgeInsets.all(0); final EdgeInsets padding = widget.padding ?? EdgeInsets.zero;
late EdgeInsets outerPadding; late EdgeInsets outerPadding;
late EdgeInsets listPadding; late EdgeInsets listPadding;
switch (widget.scrollDirection) { switch (widget.scrollDirection) {
......
...@@ -228,7 +228,7 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin { ...@@ -228,7 +228,7 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
static const Duration _fadeInDuration = Duration(milliseconds: 150); static const Duration _fadeInDuration = Duration(milliseconds: 150);
static const Duration _fadeOutDuration = Duration(milliseconds: 75); static const Duration _fadeOutDuration = Duration(milliseconds: 75);
static const Duration _defaultShowDuration = Duration(milliseconds: 1500); static const Duration _defaultShowDuration = Duration(milliseconds: 1500);
static const Duration _defaultWaitDuration = Duration(milliseconds: 0); static const Duration _defaultWaitDuration = Duration.zero;
static const bool _defaultExcludeFromSemantics = false; static const bool _defaultExcludeFromSemantics = false;
late double height; late double height;
......
...@@ -1884,7 +1884,7 @@ abstract class RenderBox extends RenderObject { ...@@ -1884,7 +1884,7 @@ abstract class RenderBox extends RenderObject {
), ),
]), ]),
)); ));
return const Size(0, 0); return Size.zero;
} }
static bool _dryLayoutCalculationValid = true; static bool _dryLayoutCalculationValid = true;
......
...@@ -100,7 +100,7 @@ mixin DebugOverflowIndicatorMixin on RenderObject { ...@@ -100,7 +100,7 @@ mixin DebugOverflowIndicatorMixin on RenderObject {
); );
static final Paint _indicatorPaint = Paint() static final Paint _indicatorPaint = Paint()
..shader = ui.Gradient.linear( ..shader = ui.Gradient.linear(
const Offset(0.0, 0.0), Offset.zero,
const Offset(10.0, 10.0), const Offset(10.0, 10.0),
<Color>[_black, _yellow, _yellow, _black], <Color>[_black, _yellow, _yellow, _black],
<double>[0.25, 0.25, 0.75, 0.75], <double>[0.25, 0.25, 0.75, 0.75],
......
...@@ -2193,7 +2193,7 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin { ...@@ -2193,7 +2193,7 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
assert(boundedOffset != null); assert(boundedOffset != null);
assert(lastTextPosition != null); assert(lastTextPosition != null);
if (state == FloatingCursorDragState.Start) { if (state == FloatingCursorDragState.Start) {
_relativeOrigin = const Offset(0, 0); _relativeOrigin = Offset.zero;
_previousOffset = null; _previousOffset = null;
_resetOriginOnBottom = false; _resetOriginOnBottom = false;
_resetOriginOnTop = false; _resetOriginOnTop = false;
...@@ -2242,7 +2242,7 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin { ...@@ -2242,7 +2242,7 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
// The relative origin in relation to the distance the user has theoretically // The relative origin in relation to the distance the user has theoretically
// dragged the floating cursor offscreen. This value is used to account for the // dragged the floating cursor offscreen. This value is used to account for the
// difference in the rendering position and the raw offset value. // difference in the rendering position and the raw offset value.
Offset _relativeOrigin = const Offset(0, 0); Offset _relativeOrigin = Offset.zero;
Offset? _previousOffset; Offset? _previousOffset;
bool _resetOriginOnLeft = false; bool _resetOriginOnLeft = false;
bool _resetOriginOnRight = false; bool _resetOriginOnRight = false;
...@@ -2252,7 +2252,7 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin { ...@@ -2252,7 +2252,7 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
/// Returns the position within the text field closest to the raw cursor offset. /// Returns the position within the text field closest to the raw cursor offset.
Offset calculateBoundedFloatingCursorOffset(Offset rawCursorOffset) { Offset calculateBoundedFloatingCursorOffset(Offset rawCursorOffset) {
Offset deltaPosition = const Offset(0, 0); Offset deltaPosition = Offset.zero;
final double topBound = -floatingCursorAddedMargin.top; final double topBound = -floatingCursorAddedMargin.top;
final double bottomBound = _textPainter.height - preferredLineHeight + floatingCursorAddedMargin.bottom; final double bottomBound = _textPainter.height - preferredLineHeight + floatingCursorAddedMargin.bottom;
final double leftBound = -floatingCursorAddedMargin.left; final double leftBound = -floatingCursorAddedMargin.left;
......
...@@ -677,7 +677,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl ...@@ -677,7 +677,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
assert(debugCannotComputeDryLayout( assert(debugCannotComputeDryLayout(
reason: 'Dry layout cannot be computed for CrossAxisAlignment.baseline, which requires a full layout.' reason: 'Dry layout cannot be computed for CrossAxisAlignment.baseline, which requires a full layout.'
)); ));
return const Size(0, 0); return Size.zero;
} }
FlutterError? constraintsError; FlutterError? constraintsError;
assert(() { assert(() {
...@@ -689,7 +689,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl ...@@ -689,7 +689,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
}()); }());
if (constraintsError != null) { if (constraintsError != null) {
assert(debugCannotComputeDryLayout(error: constraintsError)); assert(debugCannotComputeDryLayout(error: constraintsError));
return const Size(0, 0); return Size.zero;
} }
final _LayoutSizes sizes = _computeSizes( final _LayoutSizes sizes = _computeSizes(
......
...@@ -637,7 +637,7 @@ class RenderParagraph extends RenderBox ...@@ -637,7 +637,7 @@ class RenderParagraph extends RenderBox
assert(debugCannotComputeDryLayout( assert(debugCannotComputeDryLayout(
reason: 'Dry layout not available for alignments that require baseline.', reason: 'Dry layout not available for alignments that require baseline.',
)); ));
return const Size(0, 0); return Size.zero;
} }
_textPainter.setPlaceholderDimensions(_layoutChildren(constraints, dry: true)); _textPainter.setPlaceholderDimensions(_layoutChildren(constraints, dry: true));
_layoutText(minWidth: constraints.minWidth, maxWidth: constraints.maxWidth); _layoutText(minWidth: constraints.minWidth, maxWidth: constraints.maxWidth);
......
...@@ -1389,7 +1389,7 @@ abstract class _RenderCustomClip<T> extends RenderProxyBox { ...@@ -1389,7 +1389,7 @@ abstract class _RenderCustomClip<T> extends RenderProxyBox {
assert(() { assert(() {
_debugPaint ??= Paint() _debugPaint ??= Paint()
..shader = ui.Gradient.linear( ..shader = ui.Gradient.linear(
const Offset(0.0, 0.0), Offset.zero,
const Offset(10.0, 10.0), const Offset(10.0, 10.0),
<Color>[const Color(0x00000000), const Color(0xFFFF00FF), const Color(0xFFFF00FF), const Color(0x00000000)], <Color>[const Color(0x00000000), const Color(0xFFFF00FF), const Color(0xFFFF00FF), const Color(0x00000000)],
<double>[0.25, 0.25, 0.75, 0.75], <double>[0.25, 0.25, 0.75, 0.75],
...@@ -2502,7 +2502,7 @@ class RenderFittedBox extends RenderProxyBox { ...@@ -2502,7 +2502,7 @@ class RenderFittedBox extends RenderProxyBox {
assert(debugCannotComputeDryLayout( assert(debugCannotComputeDryLayout(
reason: 'Child provided invalid size of $childSize.', reason: 'Child provided invalid size of $childSize.',
)); ));
return const Size(0, 0); return Size.zero;
} }
switch (fit) { switch (fit) {
......
...@@ -317,11 +317,7 @@ class RenderSliverOffstage extends RenderProxySliver { ...@@ -317,11 +317,7 @@ class RenderSliverOffstage extends RenderProxySliver {
if (!offstage) if (!offstage)
geometry = child!.geometry; geometry = child!.geometry;
else else
geometry = const SliverGeometry( geometry = SliverGeometry.zero;
scrollExtent: 0.0,
visible: false,
maxPaintExtent: 0.0,
);
} }
@override @override
......
...@@ -1287,7 +1287,7 @@ class RenderBaseline extends RenderShiftedBox { ...@@ -1287,7 +1287,7 @@ class RenderBaseline extends RenderShiftedBox {
assert(debugCannotComputeDryLayout( assert(debugCannotComputeDryLayout(
reason: 'Baseline metrics are only available after a full layout.', reason: 'Baseline metrics are only available after a full layout.',
)); ));
return const Size(0, 0); return Size.zero;
} }
return constraints.smallest; return constraints.smallest;
} }
......
...@@ -1002,7 +1002,7 @@ class RenderTable extends RenderBox { ...@@ -1002,7 +1002,7 @@ class RenderTable extends RenderBox {
@override @override
Size computeDryLayout(BoxConstraints constraints) { Size computeDryLayout(BoxConstraints constraints) {
if (rows * columns == 0) { if (rows * columns == 0) {
return constraints.constrain(const Size(0.0, 0.0)); return constraints.constrain(Size.zero);
} }
final List<double> widths = _computeColumnWidths(constraints); final List<double> widths = _computeColumnWidths(constraints);
final double tableWidth = widths.fold(0.0, (double a, double b) => a + b); final double tableWidth = widths.fold(0.0, (double a, double b) => a + b);
...@@ -1020,7 +1020,7 @@ class RenderTable extends RenderBox { ...@@ -1020,7 +1020,7 @@ class RenderTable extends RenderBox {
assert(debugCannotComputeDryLayout( assert(debugCannotComputeDryLayout(
reason: 'TableCellVerticalAlignment.baseline requires a full layout for baseline metrics to be available.' reason: 'TableCellVerticalAlignment.baseline requires a full layout for baseline metrics to be available.'
)); ));
return const Size(0 ,0); return Size.zero;
case TableCellVerticalAlignment.top: case TableCellVerticalAlignment.top:
case TableCellVerticalAlignment.middle: case TableCellVerticalAlignment.middle:
case TableCellVerticalAlignment.bottom: case TableCellVerticalAlignment.bottom:
...@@ -1046,7 +1046,7 @@ class RenderTable extends RenderBox { ...@@ -1046,7 +1046,7 @@ class RenderTable extends RenderBox {
if (rows * columns == 0) { if (rows * columns == 0) {
// TODO(ianh): if columns is zero, this should be zero width // TODO(ianh): if columns is zero, this should be zero width
// TODO(ianh): if columns is not zero, this should be based on the column width specifications // TODO(ianh): if columns is not zero, this should be based on the column width specifications
size = constraints.constrain(const Size(0.0, 0.0)); size = constraints.constrain(Size.zero);
return; return;
} }
final List<double> widths = _computeColumnWidths(constraints); final List<double> widths = _computeColumnWidths(constraints);
......
...@@ -1070,7 +1070,7 @@ RawFloatingCursorPoint _toTextPoint(FloatingCursorDragState state, Map<String, d ...@@ -1070,7 +1070,7 @@ RawFloatingCursorPoint _toTextPoint(FloatingCursorDragState state, Map<String, d
assert(encoded['Y'] != null, 'You must provide a value for the vertical location of the floating cursor.'); assert(encoded['Y'] != null, 'You must provide a value for the vertical location of the floating cursor.');
final Offset offset = state == FloatingCursorDragState.Update final Offset offset = state == FloatingCursorDragState.Update
? Offset(encoded['X'] as double, encoded['Y'] as double) ? Offset(encoded['X'] as double, encoded['Y'] as double)
: const Offset(0, 0); : Offset.zero;
return RawFloatingCursorPoint(offset: offset, state: state); return RawFloatingCursorPoint(offset: offset, state: state);
} }
......
...@@ -495,7 +495,7 @@ class AnimatedListState extends State<AnimatedList> with TickerProviderStateMixi ...@@ -495,7 +495,7 @@ class AnimatedListState extends State<AnimatedList> with TickerProviderStateMixi
shrinkWrap: widget.shrinkWrap, shrinkWrap: widget.shrinkWrap,
slivers: <Widget>[ slivers: <Widget>[
SliverPadding( SliverPadding(
padding: widget.padding ?? const EdgeInsets.all(0), padding: widget.padding ?? EdgeInsets.zero,
sliver: SliverAnimatedList( sliver: SliverAnimatedList(
key: _sliverAnimatedListKey, key: _sliverAnimatedListKey,
itemBuilder: widget.itemBuilder, itemBuilder: widget.itemBuilder,
......
...@@ -351,7 +351,7 @@ class _RenderLayoutBuilder extends RenderBox with RenderObjectWithChildMixin<Ren ...@@ -351,7 +351,7 @@ class _RenderLayoutBuilder extends RenderBox with RenderObjectWithChildMixin<Ren
'Calculating the dry layout would require running the layout callback ' 'Calculating the dry layout would require running the layout callback '
'speculatively, which might mutate the live render object tree.', 'speculatively, which might mutate the live render object tree.',
)); ));
return const Size(0, 0); return Size.zero;
} }
@override @override
......
...@@ -1895,7 +1895,7 @@ class RenderSliverOverlapAbsorber extends RenderSliver with RenderObjectWithChil ...@@ -1895,7 +1895,7 @@ class RenderSliverOverlapAbsorber extends RenderSliver with RenderObjectWithChil
'A SliverOverlapAbsorberHandle cannot be passed to multiple RenderSliverOverlapAbsorber objects at the same time.', 'A SliverOverlapAbsorberHandle cannot be passed to multiple RenderSliverOverlapAbsorber objects at the same time.',
); );
if (child == null) { if (child == null) {
geometry = const SliverGeometry(); geometry = SliverGeometry.zero;
return; return;
} }
child!.layout(constraints, parentUsesSize: true); child!.layout(constraints, parentUsesSize: true);
......
...@@ -336,7 +336,7 @@ class ReorderableListState extends State<ReorderableList> { ...@@ -336,7 +336,7 @@ class ReorderableListState extends State<ReorderableList> {
shrinkWrap: widget.shrinkWrap, shrinkWrap: widget.shrinkWrap,
slivers: <Widget>[ slivers: <Widget>[
SliverPadding( SliverPadding(
padding: widget.padding ?? const EdgeInsets.all(0), padding: widget.padding ?? EdgeInsets.zero,
sliver: SliverReorderableList( sliver: SliverReorderableList(
key: _sliverReorderableListKey, key: _sliverReorderableListKey,
itemBuilder: widget.itemBuilder, itemBuilder: widget.itemBuilder,
......
...@@ -2492,7 +2492,7 @@ class _RenderInspectorOverlay extends RenderBox { ...@@ -2492,7 +2492,7 @@ class _RenderInspectorOverlay extends RenderBox {
@override @override
Size computeDryLayout(BoxConstraints constraints) { Size computeDryLayout(BoxConstraints constraints) {
return constraints.constrain(const Size(double.infinity, double.infinity)); return constraints.constrain(Size.infinite);
} }
@override @override
......
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