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
This commit is contained in:
parent
22f376418f
commit
94f9604a96
@ -518,7 +518,7 @@ class _RenderSegmentedControl<T> 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<T> 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<T> 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<T> 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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -744,6 +744,7 @@ class _TabBarState extends State<TabBar> {
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
assert(debugCheckHasMaterial(context));
|
||||
_updateTabController();
|
||||
_initIndicatorPainter();
|
||||
}
|
||||
|
@ -42,8 +42,7 @@ class RenderProxyBox extends RenderBox with RenderObjectWithChildMixin<RenderBox
|
||||
/// Proxy render boxes are rarely created directly because they simply proxy
|
||||
/// the render box protocol to [child]. Instead, consider using one of the
|
||||
/// subclasses.
|
||||
// TODO(a14n): Remove ignore once https://github.com/dart-lang/sdk/issues/30328 is fixed
|
||||
RenderProxyBox([RenderBox child = null]) { //ignore: avoid_init_to_null
|
||||
RenderProxyBox([RenderBox child]) {
|
||||
this.child = child;
|
||||
}
|
||||
}
|
||||
|
@ -227,8 +227,8 @@ abstract class ScrollView extends StatelessWidget {
|
||||
final AxisDirection axisDirection = getDirection(context);
|
||||
|
||||
final ScrollController scrollController = primary
|
||||
? PrimaryScrollController.of(context)
|
||||
: controller;
|
||||
? PrimaryScrollController.of(context)
|
||||
: controller;
|
||||
final Scrollable scrollable = new Scrollable(
|
||||
axisDirection: axisDirection,
|
||||
controller: scrollController,
|
||||
@ -856,7 +856,7 @@ class ListView extends BoxScrollView {
|
||||
physics: physics,
|
||||
shrinkWrap: shrinkWrap,
|
||||
padding: padding,
|
||||
cacheExtent: cacheExtent,
|
||||
cacheExtent: cacheExtent,
|
||||
);
|
||||
|
||||
/// If non-null, forces the children to have the given extent in the scroll
|
||||
|
@ -328,7 +328,7 @@ class ScrollableState extends State<Scrollable> with TickerProviderStateMixin
|
||||
|
||||
// SEMANTICS
|
||||
|
||||
final GlobalKey _excludableScrollSemanticsKey = new GlobalKey();
|
||||
final GlobalKey _scrollSemanticsKey = new GlobalKey();
|
||||
|
||||
@override
|
||||
@protected
|
||||
@ -504,8 +504,8 @@ class ScrollableState extends State<Scrollable> 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<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.
|
||||
///
|
||||
/// Nodes, that are to be excluded, have to be tagged with
|
||||
@ -536,8 +536,8 @@ class ScrollableState extends State<Scrollable> 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,
|
||||
|
@ -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<double> animation = inputBorderPainter.borderAnimation;
|
||||
final dynamic/*_InputBorder */ border = inputBorderTween.evaluate(animation);
|
||||
final dynamic/*_InputBorder*/ border = inputBorderTween.evaluate(animation);
|
||||
return border;
|
||||
}
|
||||
|
||||
|
@ -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: <none> (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: <none> (can use size)\n'
|
||||
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
|
||||
' │ semantic boundary\n'
|
||||
|
Loading…
x
Reference in New Issue
Block a user