From 94f9604a969d6343de76543599d5fd21978f3de8 Mon Sep 17 00:00:00 2001 From: Ian Hickson Date: Tue, 21 Aug 2018 14:02:48 -0700 Subject: [PATCH] Cleanup (#20754) - remove an //ignore that is no longer needed - fix some intrinsic methods that used the API incorrectly (shouldn't affect correctness but should make things a tiny bit more efficient) - add some asserts to help track down bugs quicker - update a TODO to point to the currently relevant bug - fix some indenting - improve the naming of some privates to improve readability --- .../lib/src/cupertino/segmented_control.dart | 8 +++---- packages/flutter/lib/src/material/button.dart | 8 +++---- .../lib/src/material/expansion_panel.dart | 2 +- packages/flutter/lib/src/material/tabs.dart | 1 + .../flutter/lib/src/rendering/proxy_box.dart | 3 +-- .../flutter/lib/src/widgets/scroll_view.dart | 6 ++--- .../flutter/lib/src/widgets/scrollable.dart | 24 +++++++++---------- .../test/material/input_decorator_test.dart | 6 ++--- .../flutter/test/widgets/keep_alive_test.dart | 4 ++-- 9 files changed, 30 insertions(+), 32 deletions(-) diff --git a/packages/flutter/lib/src/cupertino/segmented_control.dart b/packages/flutter/lib/src/cupertino/segmented_control.dart index 0a6af17009..b3c157e98f 100644 --- a/packages/flutter/lib/src/cupertino/segmented_control.dart +++ b/packages/flutter/lib/src/cupertino/segmented_control.dart @@ -518,7 +518,7 @@ class _RenderSegmentedControl extends RenderBox double minWidth = 0.0; while (child != null) { final _SegmentedControlContainerBoxParentData childParentData = child.parentData; - final double childWidth = child.computeMinIntrinsicWidth(height); + final double childWidth = child.getMinIntrinsicWidth(height); minWidth = math.max(minWidth, childWidth); child = childParentData.nextSibling; } @@ -531,7 +531,7 @@ class _RenderSegmentedControl extends RenderBox double maxWidth = 0.0; while (child != null) { final _SegmentedControlContainerBoxParentData childParentData = child.parentData; - final double childWidth = child.computeMaxIntrinsicWidth(height); + final double childWidth = child.getMaxIntrinsicWidth(height); maxWidth = math.max(maxWidth, childWidth); child = childParentData.nextSibling; } @@ -544,7 +544,7 @@ class _RenderSegmentedControl extends RenderBox double minHeight = 0.0; while (child != null) { final _SegmentedControlContainerBoxParentData childParentData = child.parentData; - final double childHeight = child.computeMinIntrinsicHeight(width); + final double childHeight = child.getMinIntrinsicHeight(width); minHeight = math.max(minHeight, childHeight); child = childParentData.nextSibling; } @@ -557,7 +557,7 @@ class _RenderSegmentedControl extends RenderBox double maxHeight = 0.0; while (child != null) { final _SegmentedControlContainerBoxParentData childParentData = child.parentData; - final double childHeight = child.computeMaxIntrinsicHeight(width); + final double childHeight = child.getMaxIntrinsicHeight(width); maxHeight = math.max(maxHeight, childHeight); child = childParentData.nextSibling; } diff --git a/packages/flutter/lib/src/material/button.dart b/packages/flutter/lib/src/material/button.dart index 64198c08ec..6bf3891851 100644 --- a/packages/flutter/lib/src/material/button.dart +++ b/packages/flutter/lib/src/material/button.dart @@ -497,28 +497,28 @@ class _RenderInputPadding extends RenderShiftedBox { @override double computeMinIntrinsicWidth(double height) { if (child != null) - return math.max(child.computeMinIntrinsicWidth(height), minSize.width); + return math.max(child.getMinIntrinsicWidth(height), minSize.width); return 0.0; } @override double computeMinIntrinsicHeight(double width) { if (child != null) - return math.max(child.computeMinIntrinsicHeight(width), minSize.height); + return math.max(child.getMinIntrinsicHeight(width), minSize.height); return 0.0; } @override double computeMaxIntrinsicWidth(double height) { if (child != null) - return math.max(child.computeMaxIntrinsicWidth(height), minSize.width); + return math.max(child.getMaxIntrinsicWidth(height), minSize.width); return 0.0; } @override double computeMaxIntrinsicHeight(double width) { if (child != null) - return math.max(child.computeMaxIntrinsicHeight(width), minSize.height); + return math.max(child.getMaxIntrinsicHeight(width), minSize.height); return 0.0; } diff --git a/packages/flutter/lib/src/material/expansion_panel.dart b/packages/flutter/lib/src/material/expansion_panel.dart index d3fa4d8e53..52d390c624 100644 --- a/packages/flutter/lib/src/material/expansion_panel.dart +++ b/packages/flutter/lib/src/material/expansion_panel.dart @@ -144,7 +144,7 @@ class ExpansionPanelList extends StatefulWidget { this.expansionCallback, this.animationDuration = kThemeAnimationDuration, this.initialOpenPanelValue, - }) : children = children, //ignore:prefer_initializing_formals + }) : children = children, // ignore: prefer_initializing_formals assert(children != null), assert(animationDuration != null), _allowOnlyOnePanelOpen = true, diff --git a/packages/flutter/lib/src/material/tabs.dart b/packages/flutter/lib/src/material/tabs.dart index c23b70dab6..648aea923e 100644 --- a/packages/flutter/lib/src/material/tabs.dart +++ b/packages/flutter/lib/src/material/tabs.dart @@ -744,6 +744,7 @@ class _TabBarState extends State { @override void didChangeDependencies() { super.didChangeDependencies(); + assert(debugCheckHasMaterial(context)); _updateTabController(); _initIndicatorPainter(); } diff --git a/packages/flutter/lib/src/rendering/proxy_box.dart b/packages/flutter/lib/src/rendering/proxy_box.dart index 63b9917a4e..78f3edaa95 100644 --- a/packages/flutter/lib/src/rendering/proxy_box.dart +++ b/packages/flutter/lib/src/rendering/proxy_box.dart @@ -42,8 +42,7 @@ class RenderProxyBox extends RenderBox with RenderObjectWithChildMixin with TickerProviderStateMixin // SEMANTICS - final GlobalKey _excludableScrollSemanticsKey = new GlobalKey(); + final GlobalKey _scrollSemanticsKey = new GlobalKey(); @override @protected @@ -504,8 +504,8 @@ class ScrollableState extends State with TickerProviderStateMixin ); if (!widget.excludeFromSemantics) { - result = new _ExcludableScrollSemantics( - key: _excludableScrollSemanticsKey, + result = new _ScrollSemantics( + key: _scrollSemanticsKey, child: result, position: position, allowImplicitScrolling: widget?.physics?.allowImplicitScrolling ?? false, @@ -522,7 +522,7 @@ class ScrollableState extends State with TickerProviderStateMixin } } -/// With [_ExcludableScrollSemantics] certain child [SemanticsNode]s can be +/// With [_ScrollSemantics] certain child [SemanticsNode]s can be /// excluded from the scrollable area for semantics purposes. /// /// Nodes, that are to be excluded, have to be tagged with @@ -536,8 +536,8 @@ class ScrollableState extends State with TickerProviderStateMixin /// node will contain all children, that are excluded from scrolling. The inner /// node, which is annotated with the scrolling actions, will house the /// scrollable children. -class _ExcludableScrollSemantics extends SingleChildRenderObjectWidget { - const _ExcludableScrollSemantics({ +class _ScrollSemantics extends SingleChildRenderObjectWidget { + const _ScrollSemantics({ Key key, @required this.position, @required this.allowImplicitScrolling, @@ -548,25 +548,23 @@ class _ExcludableScrollSemantics extends SingleChildRenderObjectWidget { final bool allowImplicitScrolling; @override - _RenderExcludableScrollSemantics createRenderObject(BuildContext context) { - return new _RenderExcludableScrollSemantics( + _RenderScrollSemantics createRenderObject(BuildContext context) { + return new _RenderScrollSemantics( position: position, allowImplicitScrolling: allowImplicitScrolling, ); } - - @override - void updateRenderObject(BuildContext context, _RenderExcludableScrollSemantics renderObject) { + void updateRenderObject(BuildContext context, _RenderScrollSemantics renderObject) { renderObject ..allowImplicitScrolling = allowImplicitScrolling ..position = position; } } -class _RenderExcludableScrollSemantics extends RenderProxyBox { - _RenderExcludableScrollSemantics({ +class _RenderScrollSemantics extends RenderProxyBox { + _RenderScrollSemantics({ @required ScrollPosition position, @required bool allowImplicitScrolling, RenderBox child, diff --git a/packages/flutter/test/material/input_decorator_test.dart b/packages/flutter/test/material/input_decorator_test.dart index 0b98a7382c..fa650eed59 100644 --- a/packages/flutter/test/material/input_decorator_test.dart +++ b/packages/flutter/test/material/input_decorator_test.dart @@ -66,10 +66,10 @@ InputBorder getBorder(WidgetTester tester) { if (!tester.any(findBorderPainter())) return null; final CustomPaint customPaint = tester.widget(findBorderPainter()); - final dynamic/* _InputBorderPainter */ inputBorderPainter = customPaint.foregroundPainter; - final dynamic/*_InputBorderTween */ inputBorderTween = inputBorderPainter.border; + final dynamic/*_InputBorderPainter*/ inputBorderPainter = customPaint.foregroundPainter; + final dynamic/*_InputBorderTween*/ inputBorderTween = inputBorderPainter.border; final Animation animation = inputBorderPainter.borderAnimation; - final dynamic/*_InputBorder */ border = inputBorderTween.evaluate(animation); + final dynamic/*_InputBorder*/ border = inputBorderTween.evaluate(animation); return border; } diff --git a/packages/flutter/test/widgets/keep_alive_test.dart b/packages/flutter/test/widgets/keep_alive_test.dart index 05e3bafd97..bce1f224b7 100644 --- a/packages/flutter/test/widgets/keep_alive_test.dart +++ b/packages/flutter/test/widgets/keep_alive_test.dart @@ -226,7 +226,7 @@ void main() { ' │ diagnosis: insufficient data to draw conclusion (less than five\n' ' │ repaints)\n' ' │\n' - ' └─child: _RenderExcludableScrollSemantics#00000\n' + ' └─child: _RenderScrollSemantics#00000\n' ' │ parentData: (can use size)\n' ' │ constraints: BoxConstraints(w=800.0, h=600.0)\n' ' │ semantic boundary\n' @@ -355,7 +355,7 @@ void main() { ' │ diagnosis: insufficient data to draw conclusion (less than five\n' ' │ repaints)\n' ' │\n' - ' └─child: _RenderExcludableScrollSemantics#00000\n' + ' └─child: _RenderScrollSemantics#00000\n' ' │ parentData: (can use size)\n' ' │ constraints: BoxConstraints(w=800.0, h=600.0)\n' ' │ semantic boundary\n'