Unverified Commit 94f9604a authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

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
parent 22f37641
...@@ -518,7 +518,7 @@ class _RenderSegmentedControl<T> extends RenderBox ...@@ -518,7 +518,7 @@ class _RenderSegmentedControl<T> extends RenderBox
double minWidth = 0.0; double minWidth = 0.0;
while (child != null) { while (child != null) {
final _SegmentedControlContainerBoxParentData childParentData = child.parentData; final _SegmentedControlContainerBoxParentData childParentData = child.parentData;
final double childWidth = child.computeMinIntrinsicWidth(height); final double childWidth = child.getMinIntrinsicWidth(height);
minWidth = math.max(minWidth, childWidth); minWidth = math.max(minWidth, childWidth);
child = childParentData.nextSibling; child = childParentData.nextSibling;
} }
...@@ -531,7 +531,7 @@ class _RenderSegmentedControl<T> extends RenderBox ...@@ -531,7 +531,7 @@ class _RenderSegmentedControl<T> extends RenderBox
double maxWidth = 0.0; double maxWidth = 0.0;
while (child != null) { while (child != null) {
final _SegmentedControlContainerBoxParentData childParentData = child.parentData; final _SegmentedControlContainerBoxParentData childParentData = child.parentData;
final double childWidth = child.computeMaxIntrinsicWidth(height); final double childWidth = child.getMaxIntrinsicWidth(height);
maxWidth = math.max(maxWidth, childWidth); maxWidth = math.max(maxWidth, childWidth);
child = childParentData.nextSibling; child = childParentData.nextSibling;
} }
...@@ -544,7 +544,7 @@ class _RenderSegmentedControl<T> extends RenderBox ...@@ -544,7 +544,7 @@ class _RenderSegmentedControl<T> extends RenderBox
double minHeight = 0.0; double minHeight = 0.0;
while (child != null) { while (child != null) {
final _SegmentedControlContainerBoxParentData childParentData = child.parentData; final _SegmentedControlContainerBoxParentData childParentData = child.parentData;
final double childHeight = child.computeMinIntrinsicHeight(width); final double childHeight = child.getMinIntrinsicHeight(width);
minHeight = math.max(minHeight, childHeight); minHeight = math.max(minHeight, childHeight);
child = childParentData.nextSibling; child = childParentData.nextSibling;
} }
...@@ -557,7 +557,7 @@ class _RenderSegmentedControl<T> extends RenderBox ...@@ -557,7 +557,7 @@ class _RenderSegmentedControl<T> extends RenderBox
double maxHeight = 0.0; double maxHeight = 0.0;
while (child != null) { while (child != null) {
final _SegmentedControlContainerBoxParentData childParentData = child.parentData; final _SegmentedControlContainerBoxParentData childParentData = child.parentData;
final double childHeight = child.computeMaxIntrinsicHeight(width); final double childHeight = child.getMaxIntrinsicHeight(width);
maxHeight = math.max(maxHeight, childHeight); maxHeight = math.max(maxHeight, childHeight);
child = childParentData.nextSibling; child = childParentData.nextSibling;
} }
......
...@@ -497,28 +497,28 @@ class _RenderInputPadding extends RenderShiftedBox { ...@@ -497,28 +497,28 @@ class _RenderInputPadding extends RenderShiftedBox {
@override @override
double computeMinIntrinsicWidth(double height) { double computeMinIntrinsicWidth(double height) {
if (child != null) if (child != null)
return math.max(child.computeMinIntrinsicWidth(height), minSize.width); return math.max(child.getMinIntrinsicWidth(height), minSize.width);
return 0.0; return 0.0;
} }
@override @override
double computeMinIntrinsicHeight(double width) { double computeMinIntrinsicHeight(double width) {
if (child != null) if (child != null)
return math.max(child.computeMinIntrinsicHeight(width), minSize.height); return math.max(child.getMinIntrinsicHeight(width), minSize.height);
return 0.0; return 0.0;
} }
@override @override
double computeMaxIntrinsicWidth(double height) { double computeMaxIntrinsicWidth(double height) {
if (child != null) if (child != null)
return math.max(child.computeMaxIntrinsicWidth(height), minSize.width); return math.max(child.getMaxIntrinsicWidth(height), minSize.width);
return 0.0; return 0.0;
} }
@override @override
double computeMaxIntrinsicHeight(double width) { double computeMaxIntrinsicHeight(double width) {
if (child != null) if (child != null)
return math.max(child.computeMaxIntrinsicHeight(width), minSize.height); return math.max(child.getMaxIntrinsicHeight(width), minSize.height);
return 0.0; return 0.0;
} }
......
...@@ -144,7 +144,7 @@ class ExpansionPanelList extends StatefulWidget { ...@@ -144,7 +144,7 @@ class ExpansionPanelList extends StatefulWidget {
this.expansionCallback, this.expansionCallback,
this.animationDuration = kThemeAnimationDuration, this.animationDuration = kThemeAnimationDuration,
this.initialOpenPanelValue, this.initialOpenPanelValue,
}) : children = children, //ignore:prefer_initializing_formals }) : children = children, // ignore: prefer_initializing_formals
assert(children != null), assert(children != null),
assert(animationDuration != null), assert(animationDuration != null),
_allowOnlyOnePanelOpen = true, _allowOnlyOnePanelOpen = true,
......
...@@ -744,6 +744,7 @@ class _TabBarState extends State<TabBar> { ...@@ -744,6 +744,7 @@ class _TabBarState extends State<TabBar> {
@override @override
void didChangeDependencies() { void didChangeDependencies() {
super.didChangeDependencies(); super.didChangeDependencies();
assert(debugCheckHasMaterial(context));
_updateTabController(); _updateTabController();
_initIndicatorPainter(); _initIndicatorPainter();
} }
......
...@@ -42,8 +42,7 @@ class RenderProxyBox extends RenderBox with RenderObjectWithChildMixin<RenderBox ...@@ -42,8 +42,7 @@ class RenderProxyBox extends RenderBox with RenderObjectWithChildMixin<RenderBox
/// Proxy render boxes are rarely created directly because they simply proxy /// Proxy render boxes are rarely created directly because they simply proxy
/// the render box protocol to [child]. Instead, consider using one of the /// the render box protocol to [child]. Instead, consider using one of the
/// subclasses. /// subclasses.
// TODO(a14n): Remove ignore once https://github.com/dart-lang/sdk/issues/30328 is fixed RenderProxyBox([RenderBox child]) {
RenderProxyBox([RenderBox child = null]) { //ignore: avoid_init_to_null
this.child = child; this.child = child;
} }
} }
......
...@@ -328,7 +328,7 @@ class ScrollableState extends State<Scrollable> with TickerProviderStateMixin ...@@ -328,7 +328,7 @@ class ScrollableState extends State<Scrollable> with TickerProviderStateMixin
// SEMANTICS // SEMANTICS
final GlobalKey _excludableScrollSemanticsKey = new GlobalKey(); final GlobalKey _scrollSemanticsKey = new GlobalKey();
@override @override
@protected @protected
...@@ -504,8 +504,8 @@ class ScrollableState extends State<Scrollable> with TickerProviderStateMixin ...@@ -504,8 +504,8 @@ class ScrollableState extends State<Scrollable> with TickerProviderStateMixin
); );
if (!widget.excludeFromSemantics) { if (!widget.excludeFromSemantics) {
result = new _ExcludableScrollSemantics( result = new _ScrollSemantics(
key: _excludableScrollSemanticsKey, key: _scrollSemanticsKey,
child: result, child: result,
position: position, position: position,
allowImplicitScrolling: widget?.physics?.allowImplicitScrolling ?? false, allowImplicitScrolling: widget?.physics?.allowImplicitScrolling ?? false,
...@@ -522,7 +522,7 @@ class ScrollableState extends State<Scrollable> with TickerProviderStateMixin ...@@ -522,7 +522,7 @@ class ScrollableState extends State<Scrollable> 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. /// excluded from the scrollable area for semantics purposes.
/// ///
/// Nodes, that are to be excluded, have to be tagged with /// Nodes, that are to be excluded, have to be tagged with
...@@ -536,8 +536,8 @@ class ScrollableState extends State<Scrollable> with TickerProviderStateMixin ...@@ -536,8 +536,8 @@ class ScrollableState extends State<Scrollable> with TickerProviderStateMixin
/// node will contain all children, that are excluded from scrolling. The inner /// node will contain all children, that are excluded from scrolling. The inner
/// node, which is annotated with the scrolling actions, will house the /// node, which is annotated with the scrolling actions, will house the
/// scrollable children. /// scrollable children.
class _ExcludableScrollSemantics extends SingleChildRenderObjectWidget { class _ScrollSemantics extends SingleChildRenderObjectWidget {
const _ExcludableScrollSemantics({ const _ScrollSemantics({
Key key, Key key,
@required this.position, @required this.position,
@required this.allowImplicitScrolling, @required this.allowImplicitScrolling,
...@@ -548,25 +548,23 @@ class _ExcludableScrollSemantics extends SingleChildRenderObjectWidget { ...@@ -548,25 +548,23 @@ class _ExcludableScrollSemantics extends SingleChildRenderObjectWidget {
final bool allowImplicitScrolling; final bool allowImplicitScrolling;
@override @override
_RenderExcludableScrollSemantics createRenderObject(BuildContext context) { _RenderScrollSemantics createRenderObject(BuildContext context) {
return new _RenderExcludableScrollSemantics( return new _RenderScrollSemantics(
position: position, position: position,
allowImplicitScrolling: allowImplicitScrolling, allowImplicitScrolling: allowImplicitScrolling,
); );
} }
@override @override
void updateRenderObject(BuildContext context, _RenderExcludableScrollSemantics renderObject) { void updateRenderObject(BuildContext context, _RenderScrollSemantics renderObject) {
renderObject renderObject
..allowImplicitScrolling = allowImplicitScrolling ..allowImplicitScrolling = allowImplicitScrolling
..position = position; ..position = position;
} }
} }
class _RenderExcludableScrollSemantics extends RenderProxyBox { class _RenderScrollSemantics extends RenderProxyBox {
_RenderExcludableScrollSemantics({ _RenderScrollSemantics({
@required ScrollPosition position, @required ScrollPosition position,
@required bool allowImplicitScrolling, @required bool allowImplicitScrolling,
RenderBox child, RenderBox child,
......
...@@ -66,10 +66,10 @@ InputBorder getBorder(WidgetTester tester) { ...@@ -66,10 +66,10 @@ InputBorder getBorder(WidgetTester tester) {
if (!tester.any(findBorderPainter())) if (!tester.any(findBorderPainter()))
return null; return null;
final CustomPaint customPaint = tester.widget(findBorderPainter()); final CustomPaint customPaint = tester.widget(findBorderPainter());
final dynamic/* _InputBorderPainter */ inputBorderPainter = customPaint.foregroundPainter; final dynamic/*_InputBorderPainter*/ inputBorderPainter = customPaint.foregroundPainter;
final dynamic/*_InputBorderTween */ inputBorderTween = inputBorderPainter.border; final dynamic/*_InputBorderTween*/ inputBorderTween = inputBorderPainter.border;
final Animation<double> animation = inputBorderPainter.borderAnimation; final Animation<double> animation = inputBorderPainter.borderAnimation;
final dynamic/*_InputBorder */ border = inputBorderTween.evaluate(animation); final dynamic/*_InputBorder*/ border = inputBorderTween.evaluate(animation);
return border; return border;
} }
......
...@@ -226,7 +226,7 @@ void main() { ...@@ -226,7 +226,7 @@ void main() {
' │ diagnosis: insufficient data to draw conclusion (less than five\n' ' │ diagnosis: insufficient data to draw conclusion (less than five\n'
' │ repaints)\n' ' │ repaints)\n'
' │\n' ' │\n'
' └─child: _RenderExcludableScrollSemantics#00000\n' ' └─child: _RenderScrollSemantics#00000\n'
' │ parentData: <none> (can use size)\n' ' │ parentData: <none> (can use size)\n'
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n' ' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' │ semantic boundary\n' ' │ semantic boundary\n'
...@@ -355,7 +355,7 @@ void main() { ...@@ -355,7 +355,7 @@ void main() {
' │ diagnosis: insufficient data to draw conclusion (less than five\n' ' │ diagnosis: insufficient data to draw conclusion (less than five\n'
' │ repaints)\n' ' │ repaints)\n'
' │\n' ' │\n'
' └─child: _RenderExcludableScrollSemantics#00000\n' ' └─child: _RenderScrollSemantics#00000\n'
' │ parentData: <none> (can use size)\n' ' │ parentData: <none> (can use size)\n'
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n' ' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' │ semantic boundary\n' ' │ semantic boundary\n'
......
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