Unverified Commit 93395b48 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Add null safety migration annotations. (#64227)

parent 2f2130a8
...@@ -591,7 +591,7 @@ class CupertinoTextField extends StatefulWidget { ...@@ -591,7 +591,7 @@ class CupertinoTextField extends StatefulWidget {
/// {@macro flutter.widgets.editableText.scrollPhysics} /// {@macro flutter.widgets.editableText.scrollPhysics}
final ScrollPhysics scrollPhysics; final ScrollPhysics scrollPhysics;
/// {@macro flutter.rendering.editable.selectionEnabled} /// {@macro flutter.widgets.editableText.selectionEnabled}
bool get selectionEnabled => enableInteractiveSelection; bool get selectionEnabled => enableInteractiveSelection;
/// {@macro flutter.material.textfield.onTap} /// {@macro flutter.material.textfield.onTap}
......
...@@ -391,11 +391,8 @@ class SelectableText extends StatefulWidget { ...@@ -391,11 +391,8 @@ class SelectableText extends StatefulWidget {
/// If not set, select all and copy will be enabled by default. /// If not set, select all and copy will be enabled by default.
final ToolbarOptions toolbarOptions; final ToolbarOptions toolbarOptions;
/// True if interactive selection is enabled based on the values of /// {@macro flutter.widgets.editableText.selectionEnabled}
/// [enableInteractiveSelection]. bool get selectionEnabled => enableInteractiveSelection;
bool get selectionEnabled {
return enableInteractiveSelection;
}
/// Called when the user taps on this selectable text. /// Called when the user taps on this selectable text.
/// ///
......
...@@ -702,7 +702,7 @@ class TextField extends StatefulWidget { ...@@ -702,7 +702,7 @@ class TextField extends StatefulWidget {
/// {@macro flutter.widgets.scrollable.dragStartBehavior} /// {@macro flutter.widgets.scrollable.dragStartBehavior}
final DragStartBehavior dragStartBehavior; final DragStartBehavior dragStartBehavior;
/// {@macro flutter.rendering.editable.selectionEnabled} /// {@macro flutter.widgets.editableText.selectionEnabled}
bool get selectionEnabled => enableInteractiveSelection; bool get selectionEnabled => enableInteractiveSelection;
/// {@template flutter.material.textfield.onTap} /// {@template flutter.material.textfield.onTap}
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:math' show min, max; import 'dart:math' show min, max;
import 'dart:ui' as ui show Paragraph, ParagraphBuilder, ParagraphConstraints, ParagraphStyle, PlaceholderAlignment, LineMetrics, TextHeightBehavior, BoxHeightStyle, BoxWidthStyle; import 'dart:ui' as ui show Paragraph, ParagraphBuilder, ParagraphConstraints, ParagraphStyle, PlaceholderAlignment, LineMetrics, TextHeightBehavior, BoxHeightStyle, BoxWidthStyle;
......
...@@ -19,7 +19,7 @@ import 'object.dart'; ...@@ -19,7 +19,7 @@ import 'object.dart';
class _DebugSize extends Size { class _DebugSize extends Size {
_DebugSize(Size source, this._owner, this._canBeUsedByParent) : super.copy(source); _DebugSize(Size source, this._owner, this._canBeUsedByParent) : super.copy(source);
final RenderBox _owner; final RenderBox _owner;
final bool _canBeUsedByParent; final bool/*!*/ _canBeUsedByParent;
} }
/// Immutable layout constraints for [RenderBox] layout. /// Immutable layout constraints for [RenderBox] layout.
...@@ -92,10 +92,10 @@ class BoxConstraints extends Constraints { ...@@ -92,10 +92,10 @@ class BoxConstraints extends Constraints {
this.maxWidth = double.infinity, this.maxWidth = double.infinity,
this.minHeight = 0.0, this.minHeight = 0.0,
this.maxHeight = double.infinity, this.maxHeight = double.infinity,
}) : assert (minWidth != null), }) : assert(minWidth != null),
assert (maxWidth != null), assert(maxWidth != null),
assert (minHeight != null), assert(minHeight != null),
assert (maxHeight != null); assert(maxHeight != null);
/// Creates box constraints that is respected only by the given size. /// Creates box constraints that is respected only by the given size.
BoxConstraints.tight(Size size) BoxConstraints.tight(Size size)
...@@ -468,7 +468,7 @@ class BoxConstraints extends Constraints { ...@@ -468,7 +468,7 @@ class BoxConstraints extends Constraints {
/// object whose fields are all set to 0.0. /// object whose fields are all set to 0.0.
/// ///
/// {@macro dart.ui.shadow.lerp} /// {@macro dart.ui.shadow.lerp}
static BoxConstraints lerp(BoxConstraints a, BoxConstraints b, double t) { static BoxConstraints lerp(BoxConstraints/*?*/ a, BoxConstraints/*?*/ b, double t) {
assert(t != null); assert(t != null);
if (a == null && b == null) if (a == null && b == null)
return null; return null;
...@@ -1294,9 +1294,9 @@ abstract class RenderBox extends RenderObject { ...@@ -1294,9 +1294,9 @@ abstract class RenderBox extends RenderObject {
child.parentData = BoxParentData(); child.parentData = BoxParentData();
} }
Map<_IntrinsicDimensionsCacheEntry, double> _cachedIntrinsicDimensions; Map<_IntrinsicDimensionsCacheEntry, double/*!*/> _cachedIntrinsicDimensions;
double _computeIntrinsicDimension(_IntrinsicDimension dimension, double argument, double computer(double argument)) { double/*!*/ _computeIntrinsicDimension(_IntrinsicDimension dimension, double argument, double/*!*/ computer(double argument)) {
assert(RenderObject.debugCheckingIntrinsics || !debugDoingThisResize); // performResize should not depend on anything except the incoming constraints assert(RenderObject.debugCheckingIntrinsics || !debugDoingThisResize); // performResize should not depend on anything except the incoming constraints
bool shouldCache = true; bool shouldCache = true;
assert(() { assert(() {
...@@ -1332,7 +1332,7 @@ abstract class RenderBox extends RenderObject { ...@@ -1332,7 +1332,7 @@ abstract class RenderBox extends RenderObject {
/// ///
/// Do not override this method. Instead, implement [computeMinIntrinsicWidth]. /// Do not override this method. Instead, implement [computeMinIntrinsicWidth].
@mustCallSuper @mustCallSuper
double getMinIntrinsicWidth(double height) { double getMinIntrinsicWidth(double/*!*/ height) {
assert(() { assert(() {
if (height == null) { if (height == null) {
throw FlutterError.fromParts(<DiagnosticsNode>[ throw FlutterError.fromParts(<DiagnosticsNode>[
...@@ -1455,7 +1455,7 @@ abstract class RenderBox extends RenderObject { ...@@ -1455,7 +1455,7 @@ abstract class RenderBox extends RenderObject {
/// * [computeMaxIntrinsicWidth], which computes the smallest width beyond /// * [computeMaxIntrinsicWidth], which computes the smallest width beyond
/// which increasing the width never decreases the preferred height. /// which increasing the width never decreases the preferred height.
@protected @protected
double computeMinIntrinsicWidth(double height) { double/*!*/ computeMinIntrinsicWidth(double/*!*/ height) {
return 0.0; return 0.0;
} }
...@@ -1477,7 +1477,7 @@ abstract class RenderBox extends RenderObject { ...@@ -1477,7 +1477,7 @@ abstract class RenderBox extends RenderObject {
/// Do not override this method. Instead, implement /// Do not override this method. Instead, implement
/// [computeMaxIntrinsicWidth]. /// [computeMaxIntrinsicWidth].
@mustCallSuper @mustCallSuper
double getMaxIntrinsicWidth(double height) { double getMaxIntrinsicWidth(double/*!*/ height) {
assert(() { assert(() {
if (height == null) { if (height == null) {
throw FlutterError.fromParts(<DiagnosticsNode>[ throw FlutterError.fromParts(<DiagnosticsNode>[
...@@ -1535,7 +1535,7 @@ abstract class RenderBox extends RenderObject { ...@@ -1535,7 +1535,7 @@ abstract class RenderBox extends RenderObject {
/// ///
/// * [computeMinIntrinsicWidth], which has usage examples. /// * [computeMinIntrinsicWidth], which has usage examples.
@protected @protected
double computeMaxIntrinsicWidth(double height) { double/*!*/ computeMaxIntrinsicWidth(double/*!*/ height) {
return 0.0; return 0.0;
} }
...@@ -1556,7 +1556,7 @@ abstract class RenderBox extends RenderObject { ...@@ -1556,7 +1556,7 @@ abstract class RenderBox extends RenderObject {
/// Do not override this method. Instead, implement /// Do not override this method. Instead, implement
/// [computeMinIntrinsicHeight]. /// [computeMinIntrinsicHeight].
@mustCallSuper @mustCallSuper
double getMinIntrinsicHeight(double width) { double getMinIntrinsicHeight(double/*!*/ width) {
assert(() { assert(() {
if (width == null) { if (width == null) {
throw FlutterError.fromParts(<DiagnosticsNode>[ throw FlutterError.fromParts(<DiagnosticsNode>[
...@@ -1612,7 +1612,7 @@ abstract class RenderBox extends RenderObject { ...@@ -1612,7 +1612,7 @@ abstract class RenderBox extends RenderObject {
/// * [computeMaxIntrinsicHeight], which computes the smallest height beyond /// * [computeMaxIntrinsicHeight], which computes the smallest height beyond
/// which increasing the height never decreases the preferred width. /// which increasing the height never decreases the preferred width.
@protected @protected
double computeMinIntrinsicHeight(double width) { double/*!*/ computeMinIntrinsicHeight(double/*!*/ width) {
return 0.0; return 0.0;
} }
...@@ -1634,7 +1634,7 @@ abstract class RenderBox extends RenderObject { ...@@ -1634,7 +1634,7 @@ abstract class RenderBox extends RenderObject {
/// Do not override this method. Instead, implement /// Do not override this method. Instead, implement
/// [computeMaxIntrinsicHeight]. /// [computeMaxIntrinsicHeight].
@mustCallSuper @mustCallSuper
double getMaxIntrinsicHeight(double width) { double getMaxIntrinsicHeight(double/*!*/ width) {
assert(() { assert(() {
if (width == null) { if (width == null) {
throw FlutterError.fromParts(<DiagnosticsNode>[ throw FlutterError.fromParts(<DiagnosticsNode>[
...@@ -1692,7 +1692,7 @@ abstract class RenderBox extends RenderObject { ...@@ -1692,7 +1692,7 @@ abstract class RenderBox extends RenderObject {
/// ///
/// * [computeMinIntrinsicWidth], which has usage examples. /// * [computeMinIntrinsicWidth], which has usage examples.
@protected @protected
double computeMaxIntrinsicHeight(double width) { double/*!*/ computeMaxIntrinsicHeight(double/*!*/ width) {
return 0.0; return 0.0;
} }
...@@ -1709,7 +1709,7 @@ abstract class RenderBox extends RenderObject { ...@@ -1709,7 +1709,7 @@ abstract class RenderBox extends RenderObject {
/// [performResize] functions. If you wish to change the size of a box outside /// [performResize] functions. If you wish to change the size of a box outside
/// of those functions, call [markNeedsLayout] instead to schedule a layout of /// of those functions, call [markNeedsLayout] instead to schedule a layout of
/// the box. /// the box.
Size get size { Size/*!*/ get size {
assert(hasSize, 'RenderBox was not laid out: ${toString()}'); assert(hasSize, 'RenderBox was not laid out: ${toString()}');
assert(() { assert(() {
final Size _size = this._size; final Size _size = this._size;
...@@ -1733,12 +1733,12 @@ abstract class RenderBox extends RenderObject { ...@@ -1733,12 +1733,12 @@ abstract class RenderBox extends RenderObject {
}()); }());
return _size; return _size;
} }
Size _size; /*late*/ Size/*!*/ _size;
/// Setting the size, in checked mode, triggers some analysis of the render box, /// Setting the size, in checked mode, triggers some analysis of the render box,
/// as implemented by [debugAssertDoesMeetConstraints], including calling the intrinsic /// as implemented by [debugAssertDoesMeetConstraints], including calling the intrinsic
/// sizing methods and checking that they meet certain invariants. /// sizing methods and checking that they meet certain invariants.
@protected @protected
set size(Size value) { set size(Size/*!*/ value) {
assert(!(debugDoingThisResize && debugDoingThisLayout)); assert(!(debugDoingThisResize && debugDoingThisLayout));
assert(sizedByParent || !debugDoingThisResize); assert(sizedByParent || !debugDoingThisResize);
assert(() { assert(() {
...@@ -1852,7 +1852,7 @@ abstract class RenderBox extends RenderObject { ...@@ -1852,7 +1852,7 @@ abstract class RenderBox extends RenderObject {
size = size; size = size;
} }
Map<TextBaseline, double> _cachedBaselines; Map<TextBaseline/*!*/, double> _cachedBaselines;
static bool _debugDoingBaseline = false; static bool _debugDoingBaseline = false;
static bool _debugSetDoingBaseline(bool value) { static bool _debugSetDoingBaseline(bool value) {
_debugDoingBaseline = value; _debugDoingBaseline = value;
...@@ -1875,7 +1875,7 @@ abstract class RenderBox extends RenderObject { ...@@ -1875,7 +1875,7 @@ abstract class RenderBox extends RenderObject {
/// ///
/// When implementing a [RenderBox] subclass, to override the baseline /// When implementing a [RenderBox] subclass, to override the baseline
/// computation, override [computeDistanceToActualBaseline]. /// computation, override [computeDistanceToActualBaseline].
double getDistanceToBaseline(TextBaseline baseline, { bool onlyReal = false }) { double getDistanceToBaseline(TextBaseline/*!*/ baseline, { bool onlyReal = false }) {
assert(!_debugDoingBaseline, 'Please see the documentation for computeDistanceToActualBaseline for the required calling conventions of this method.'); assert(!_debugDoingBaseline, 'Please see the documentation for computeDistanceToActualBaseline for the required calling conventions of this method.');
assert(!debugNeedsLayout); assert(!debugNeedsLayout);
assert(() { assert(() {
...@@ -1903,7 +1903,7 @@ abstract class RenderBox extends RenderObject { ...@@ -1903,7 +1903,7 @@ abstract class RenderBox extends RenderObject {
/// outside those two methods. /// outside those two methods.
@protected @protected
@mustCallSuper @mustCallSuper
double getDistanceToActualBaseline(TextBaseline baseline) { double getDistanceToActualBaseline(TextBaseline/*!*/ baseline) {
assert(_debugDoingBaseline, 'Please see the documentation for computeDistanceToActualBaseline for the required calling conventions of this method.'); assert(_debugDoingBaseline, 'Please see the documentation for computeDistanceToActualBaseline for the required calling conventions of this method.');
_cachedBaselines ??= <TextBaseline, double>{}; _cachedBaselines ??= <TextBaseline, double>{};
_cachedBaselines.putIfAbsent(baseline, () => computeDistanceToActualBaseline(baseline)); _cachedBaselines.putIfAbsent(baseline, () => computeDistanceToActualBaseline(baseline));
......
...@@ -124,8 +124,9 @@ abstract class MultiChildLayoutDelegate { ...@@ -124,8 +124,9 @@ abstract class MultiChildLayoutDelegate {
final Listenable _relayout; final Listenable _relayout;
Map<Object, RenderBox> _idToChild; // TODO(ianh): make these late final
Set<RenderBox> _debugChildrenNeedingLayout; /*late*/ Map<Object/*!*/, RenderBox>/*!*/ _idToChild;
/*late*/ Set<RenderBox/*!*/>/*!*/ _debugChildrenNeedingLayout;
/// True if a non-null LayoutChild was provided for the specified id. /// True if a non-null LayoutChild was provided for the specified id.
/// ///
...@@ -140,7 +141,7 @@ abstract class MultiChildLayoutDelegate { ...@@ -140,7 +141,7 @@ abstract class MultiChildLayoutDelegate {
/// Call this from your [performLayout] function to lay out each /// Call this from your [performLayout] function to lay out each
/// child. Every child must be laid out using this function exactly /// child. Every child must be laid out using this function exactly
/// once each time the [performLayout] function is called. /// once each time the [performLayout] function is called.
Size layoutChild(Object childId, BoxConstraints constraints) { Size/*!*/ layoutChild(Object childId, BoxConstraints constraints) {
final RenderBox child = _idToChild[childId]; final RenderBox child = _idToChild[childId];
assert(() { assert(() {
if (child == null) { if (child == null) {
...@@ -211,7 +212,8 @@ abstract class MultiChildLayoutDelegate { ...@@ -211,7 +212,8 @@ abstract class MultiChildLayoutDelegate {
// we return. // we return.
final Map<Object, RenderBox> previousIdToChild = _idToChild; final Map<Object, RenderBox> previousIdToChild = _idToChild;
Set<RenderBox> debugPreviousChildrenNeedingLayout; // TODO(ianh): make the next line final
/*late*/ Set<RenderBox>/*!*/ debugPreviousChildrenNeedingLayout;
assert(() { assert(() {
debugPreviousChildrenNeedingLayout = _debugChildrenNeedingLayout; debugPreviousChildrenNeedingLayout = _debugChildrenNeedingLayout;
_debugChildrenNeedingLayout = <RenderBox>{}; _debugChildrenNeedingLayout = <RenderBox>{};
......
...@@ -521,8 +521,9 @@ class RenderCustomPaint extends RenderProxyBox { ...@@ -521,8 +521,9 @@ class RenderCustomPaint extends RenderProxyBox {
markNeedsSemanticsUpdate(); markNeedsSemanticsUpdate();
} }
void _paintWithPainter(Canvas canvas, Offset offset, CustomPainter painter) { void _paintWithPainter(Canvas canvas, Offset offset, CustomPainter/*!*/ painter) {
int debugPreviousCanvasSaveCount; // TODO(ianh): make the next line final
/*late*/ int/*!*/ debugPreviousCanvasSaveCount;
canvas.save(); canvas.save();
assert(() { assert(() {
debugPreviousCanvasSaveCount = canvas.getSaveCount(); debugPreviousCanvasSaveCount = canvas.getSaveCount();
...@@ -603,10 +604,10 @@ class RenderCustomPaint extends RenderProxyBox { ...@@ -603,10 +604,10 @@ class RenderCustomPaint extends RenderProxyBox {
} }
/// Describe the semantics of the picture painted by the [painter]. /// Describe the semantics of the picture painted by the [painter].
List<SemanticsNode> _backgroundSemanticsNodes; List<SemanticsNode/*!*/> _backgroundSemanticsNodes;
/// Describe the semantics of the picture painted by the [foregroundPainter]. /// Describe the semantics of the picture painted by the [foregroundPainter].
List<SemanticsNode> _foregroundSemanticsNodes; List<SemanticsNode/*!*/> _foregroundSemanticsNodes;
@override @override
void assembleSemanticsNode( void assembleSemanticsNode(
...@@ -675,7 +676,7 @@ class RenderCustomPaint extends RenderProxyBox { ...@@ -675,7 +676,7 @@ class RenderCustomPaint extends RenderProxyBox {
/// considered because there is only one type of [SemanticsNode]. There is no /// considered because there is only one type of [SemanticsNode]. There is no
/// concept of a "forgotten" node in semantics, deactivated nodes, or global /// concept of a "forgotten" node in semantics, deactivated nodes, or global
/// keys. /// keys.
static List<SemanticsNode> _updateSemanticsChildren( static List<SemanticsNode/*!*/> _updateSemanticsChildren(
List<SemanticsNode> oldSemantics, List<SemanticsNode> oldSemantics,
List<CustomPainterSemantics> newChildSemantics, List<CustomPainterSemantics> newChildSemantics,
) { ) {
...@@ -683,7 +684,7 @@ class RenderCustomPaint extends RenderProxyBox { ...@@ -683,7 +684,7 @@ class RenderCustomPaint extends RenderProxyBox {
newChildSemantics = newChildSemantics ?? const <CustomPainterSemantics>[]; newChildSemantics = newChildSemantics ?? const <CustomPainterSemantics>[];
assert(() { assert(() {
final Map<Key, int> keys = HashMap<Key, int>(); final Map<Key/*!*/, int> keys = HashMap<Key/*!*/, int>();
final List<DiagnosticsNode> information = <DiagnosticsNode>[]; final List<DiagnosticsNode> information = <DiagnosticsNode>[];
for (int i = 0; i < newChildSemantics.length; i += 1) { for (int i = 0; i < newChildSemantics.length; i += 1) {
final CustomPainterSemantics child = newChildSemantics[i]; final CustomPainterSemantics child = newChildSemantics[i];
...@@ -708,7 +709,7 @@ class RenderCustomPaint extends RenderProxyBox { ...@@ -708,7 +709,7 @@ class RenderCustomPaint extends RenderProxyBox {
int newChildrenBottom = newChildSemantics.length - 1; int newChildrenBottom = newChildSemantics.length - 1;
int oldChildrenBottom = oldSemantics.length - 1; int oldChildrenBottom = oldSemantics.length - 1;
final List<SemanticsNode> newChildren = List<SemanticsNode>(newChildSemantics.length); final List<SemanticsNode/*!*/> newChildren = List<SemanticsNode/*!*/>(newChildSemantics.length);
// Update the top of the list. // Update the top of the list.
while ((oldChildrenTop <= oldChildrenBottom) && (newChildrenTop <= newChildrenBottom)) { while ((oldChildrenTop <= oldChildrenBottom) && (newChildrenTop <= newChildrenBottom)) {
...@@ -734,7 +735,7 @@ class RenderCustomPaint extends RenderProxyBox { ...@@ -734,7 +735,7 @@ class RenderCustomPaint extends RenderProxyBox {
// Scan the old children in the middle of the list. // Scan the old children in the middle of the list.
final bool haveOldChildren = oldChildrenTop <= oldChildrenBottom; final bool haveOldChildren = oldChildrenTop <= oldChildrenBottom;
Map<Key, SemanticsNode> oldKeyedChildren; Map<Key/*!*/, SemanticsNode> oldKeyedChildren;
if (haveOldChildren) { if (haveOldChildren) {
oldKeyedChildren = <Key, SemanticsNode>{}; oldKeyedChildren = <Key, SemanticsNode>{};
while (oldChildrenTop <= oldChildrenBottom) { while (oldChildrenTop <= oldChildrenBottom) {
......
...@@ -174,7 +174,7 @@ bool debugProfileLayoutsEnabled = false; ...@@ -174,7 +174,7 @@ bool debugProfileLayoutsEnabled = false;
bool debugProfilePaintsEnabled = false; bool debugProfilePaintsEnabled = false;
/// Signature for [debugOnProfilePaint] implementations. /// Signature for [debugOnProfilePaint] implementations.
typedef ProfilePaintCallback = void Function(RenderObject renderObject); typedef ProfilePaintCallback = void Function(RenderObject/*!*/ renderObject);
/// Callback invoked for every [RenderObject] painted each frame. /// Callback invoked for every [RenderObject] painted each frame.
/// ///
......
...@@ -47,6 +47,8 @@ class RenderErrorBox extends RenderBox { ...@@ -47,6 +47,8 @@ class RenderErrorBox extends RenderBox {
builder.pushStyle(textStyle); builder.pushStyle(textStyle);
builder.addText(message); builder.addText(message);
_paragraph = builder.build(); _paragraph = builder.build();
} else {
_paragraph = null;
} }
} catch (error) { } catch (error) {
// Intentionally left empty. // Intentionally left empty.
...@@ -56,7 +58,8 @@ class RenderErrorBox extends RenderBox { ...@@ -56,7 +58,8 @@ class RenderErrorBox extends RenderBox {
/// The message to attempt to display at paint time. /// The message to attempt to display at paint time.
final String message; final String message;
ui.Paragraph _paragraph; // TODO(ianh): should be final
/*late*/ ui.Paragraph/*?*/ _paragraph;
@override @override
double computeMaxIntrinsicWidth(double height) { double computeMaxIntrinsicWidth(double height) {
......
...@@ -198,7 +198,7 @@ enum CrossAxisAlignment { ...@@ -198,7 +198,7 @@ enum CrossAxisAlignment {
baseline, baseline,
} }
bool _startIsTopLeft(Axis direction, TextDirection textDirection, VerticalDirection verticalDirection) { bool/*?*/ _startIsTopLeft(Axis direction, TextDirection textDirection, VerticalDirection verticalDirection) {
assert(direction != null); assert(direction != null);
// If the relevant value of textDirection or verticalDirection is null, this returns null too. // If the relevant value of textDirection or verticalDirection is null, this returns null too.
switch (direction) { switch (direction) {
...@@ -508,9 +508,9 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl ...@@ -508,9 +508,9 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
} }
double _getIntrinsicSize({ double _getIntrinsicSize({
Axis sizingDirection, @required Axis sizingDirection,
double extent, // the extent in the direction that isn't the sizing direction @required double extent, // the extent in the direction that isn't the sizing direction
_ChildSizingFunction childSize, // a method to find the size in the sizing direction @required _ChildSizingFunction childSize, // a method to find the size in the sizing direction
}) { }) {
if (_direction == sizingDirection) { if (_direction == sizingDirection) {
// INTRINSIC MAIN SIZE // INTRINSIC MAIN SIZE
...@@ -548,8 +548,9 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl ...@@ -548,8 +548,9 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
while (child != null) { while (child != null) {
final int flex = _getFlex(child); final int flex = _getFlex(child);
totalFlex += flex; totalFlex += flex;
double mainSize; // TODO(ianh): these should be late final
double crossSize; /*late*/ double/*!*/ mainSize;
/*late*/ double/*!*/ crossSize;
if (flex == 0) { if (flex == 0) {
switch (_direction) { switch (_direction) {
case Axis.horizontal: case Axis.horizontal:
...@@ -789,7 +790,8 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl ...@@ -789,7 +790,8 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
final int flex = _getFlex(child); final int flex = _getFlex(child);
if (flex > 0) { if (flex > 0) {
final double maxChildExtent = canFlex ? (child == lastFlexChild ? (freeSpace - allocatedFlexSpace) : spacePerFlex * flex) : double.infinity; final double maxChildExtent = canFlex ? (child == lastFlexChild ? (freeSpace - allocatedFlexSpace) : spacePerFlex * flex) : double.infinity;
double minChildExtent; // TODO(ianh): this should be late final
/*late*/ double/*!*/ minChildExtent;
switch (_getFit(child)) { switch (_getFit(child)) {
case FlexFit.tight: case FlexFit.tight:
assert(maxChildExtent < double.infinity); assert(maxChildExtent < double.infinity);
...@@ -865,7 +867,6 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl ...@@ -865,7 +867,6 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
// Align items along the main axis. // Align items along the main axis.
final double idealSize = canFlex && mainAxisSize == MainAxisSize.max ? maxMainSize : allocatedSize; final double idealSize = canFlex && mainAxisSize == MainAxisSize.max ? maxMainSize : allocatedSize;
double actualSize; double actualSize;
double actualSizeDelta;
switch (_direction) { switch (_direction) {
case Axis.horizontal: case Axis.horizontal:
size = constraints.constrain(Size(idealSize, crossSize)); size = constraints.constrain(Size(idealSize, crossSize));
...@@ -878,11 +879,12 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl ...@@ -878,11 +879,12 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
crossSize = size.width; crossSize = size.width;
break; break;
} }
actualSizeDelta = actualSize - allocatedSize; final double actualSizeDelta = actualSize - allocatedSize;
_overflow = math.max(0.0, -actualSizeDelta); _overflow = math.max(0.0, -actualSizeDelta);
final double remainingSpace = math.max(0.0, actualSizeDelta); final double remainingSpace = math.max(0.0, actualSizeDelta);
double leadingSpace; // TODO(ianh): these should be late final
double betweenSpace; /*late*/ double/*!*/ leadingSpace;
/*late*/ double/*!*/ betweenSpace;
// flipMainAxis is used to decide whether to lay out left-to-right/top-to-bottom (false), or // flipMainAxis is used to decide whether to lay out left-to-right/top-to-bottom (false), or
// right-to-left/bottom-to-top (true). The _startIsTopLeft will return null if there's only // right-to-left/bottom-to-top (true). The _startIsTopLeft will return null if there's only
// one child and the relevant direction is null, in which case we arbitrarily decide not to // one child and the relevant direction is null, in which case we arbitrarily decide not to
......
...@@ -1456,8 +1456,15 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im ...@@ -1456,8 +1456,15 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
bool _doingThisLayoutWithCallback = false; bool _doingThisLayoutWithCallback = false;
/// The layout constraints most recently supplied by the parent. /// The layout constraints most recently supplied by the parent.
///
/// If layout has not yet happened, accessing this getter will
/// throw a [StateError] exception.
@protected @protected
Constraints get constraints => _constraints; Constraints/*!*/ get constraints {
if (_constraints == null)
throw StateError('A RenderObject does not have any constraints before it has been laid out.');
return _constraints/*!*/;
}
Constraints _constraints; Constraints _constraints;
/// Verify that the object's constraints are being met. Override /// Verify that the object's constraints are being met. Override
...@@ -2492,7 +2499,7 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im ...@@ -2492,7 +2499,7 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
/// ``` /// ```
/// {@end-tool} /// {@end-tool}
@protected @protected
void describeSemanticsConfiguration(SemanticsConfiguration config) { void describeSemanticsConfiguration(SemanticsConfiguration/*!*/ config) {
// Nothing to do by default. // Nothing to do by default.
} }
...@@ -2890,7 +2897,7 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im ...@@ -2890,7 +2897,7 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
properties.add(FlagProperty('needsCompositing', value: _needsCompositing, ifTrue: 'needs compositing')); properties.add(FlagProperty('needsCompositing', value: _needsCompositing, ifTrue: 'needs compositing'));
properties.add(DiagnosticsProperty<dynamic>('creator', debugCreator, defaultValue: null, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty<dynamic>('creator', debugCreator, defaultValue: null, level: DiagnosticLevel.debug));
properties.add(DiagnosticsProperty<ParentData>('parentData', parentData, tooltip: _debugCanParentUseSize == true ? 'can use size' : null, missingIfNull: true)); properties.add(DiagnosticsProperty<ParentData>('parentData', parentData, tooltip: _debugCanParentUseSize == true ? 'can use size' : null, missingIfNull: true));
properties.add(DiagnosticsProperty<Constraints>('constraints', constraints, missingIfNull: true)); properties.add(DiagnosticsProperty<Constraints>('constraints', _constraints, missingIfNull: true));
// don't access it via the "layer" getter since that's only valid when we don't need paint // don't access it via the "layer" getter since that's only valid when we don't need paint
properties.add(DiagnosticsProperty<ContainerLayer>('layer', _layer, defaultValue: null)); properties.add(DiagnosticsProperty<ContainerLayer>('layer', _layer, defaultValue: null));
properties.add(DiagnosticsProperty<SemanticsNode>('semantics node', _semantics, defaultValue: null)); properties.add(DiagnosticsProperty<SemanticsNode>('semantics node', _semantics, defaultValue: null));
......
...@@ -62,22 +62,22 @@ class RelativeRect { ...@@ -62,22 +62,22 @@ class RelativeRect {
/// Distance from the left side of the container to the left side of this rectangle. /// Distance from the left side of the container to the left side of this rectangle.
/// ///
/// May be negative if the left side of the rectangle is outside of the container. /// May be negative if the left side of the rectangle is outside of the container.
final double left; final double/*!*/ left;
/// Distance from the top side of the container to the top side of this rectangle. /// Distance from the top side of the container to the top side of this rectangle.
/// ///
/// May be negative if the top side of the rectangle is outside of the container. /// May be negative if the top side of the rectangle is outside of the container.
final double top; final double/*!*/ top;
/// Distance from the right side of the container to the right side of this rectangle. /// Distance from the right side of the container to the right side of this rectangle.
/// ///
/// May be positive if the right side of the rectangle is outside of the container. /// May be positive if the right side of the rectangle is outside of the container.
final double right; final double/*!*/ right;
/// Distance from the bottom side of the container to the bottom side of this rectangle. /// Distance from the bottom side of the container to the bottom side of this rectangle.
/// ///
/// May be positive if the bottom side of the rectangle is outside of the container. /// May be positive if the bottom side of the rectangle is outside of the container.
final double bottom; final double/*!*/ bottom;
/// Returns whether any of the values are greater than zero. /// Returns whether any of the values are greater than zero.
/// ///
...@@ -134,7 +134,7 @@ class RelativeRect { ...@@ -134,7 +134,7 @@ class RelativeRect {
/// If either rect is null, this function interpolates from [RelativeRect.fill]. /// If either rect is null, this function interpolates from [RelativeRect.fill].
/// ///
/// {@macro dart.ui.shadow.lerp} /// {@macro dart.ui.shadow.lerp}
static RelativeRect lerp(RelativeRect a, RelativeRect b, double t) { static RelativeRect lerp(RelativeRect/*?*/ a, RelativeRect/*?*/ b, double t) {
assert(t != null); assert(t != null);
if (a == null && b == null) if (a == null && b == null)
return null; return null;
...@@ -492,7 +492,8 @@ class RenderStack extends RenderBox ...@@ -492,7 +492,8 @@ class RenderStack extends RenderBox
child.layout(childConstraints, parentUsesSize: true); child.layout(childConstraints, parentUsesSize: true);
double x; // TODO(ianh): x should be late final
/*late*/ double/*!*/ x;
if (childParentData.left != null) { if (childParentData.left != null) {
x = childParentData.left; x = childParentData.left;
} else if (childParentData.right != null) { } else if (childParentData.right != null) {
...@@ -504,7 +505,8 @@ class RenderStack extends RenderBox ...@@ -504,7 +505,8 @@ class RenderStack extends RenderBox
if (x < 0.0 || x + child.size.width > size.width) if (x < 0.0 || x + child.size.width > size.width)
hasVisualOverflow = true; hasVisualOverflow = true;
double y; // TODO(ianh): y should be late final
/*late*/ double/*!*/ y;
if (childParentData.top != null) { if (childParentData.top != null) {
y = childParentData.top; y = childParentData.top;
} else if (childParentData.bottom != null) { } else if (childParentData.bottom != null) {
......
...@@ -1145,13 +1145,16 @@ class EditableText extends StatefulWidget { ...@@ -1145,13 +1145,16 @@ class EditableText extends StatefulWidget {
final EdgeInsets scrollPadding; final EdgeInsets scrollPadding;
/// {@template flutter.widgets.editableText.enableInteractiveSelection} /// {@template flutter.widgets.editableText.enableInteractiveSelection}
/// If true, then long-pressing this TextField will select text and show the /// Whether to enable user interface affordances for changing the
/// cut/copy/paste menu, and tapping will move the text caret. /// text selection.
/// ///
/// True by default. /// For example, setting this to true will enable features such as
/// long-pressing the TextField to select text and show the
/// cut/copy/paste menu, and tapping to move the text caret.
/// ///
/// If false, most of the accessibility support for selecting text, copy /// When this is false, the text selection cannot be adjusted by
/// and paste, and moving the caret will be disabled. /// the user, text cannot be copied, and the user cannot paste into
/// the text field from the clipboard.
/// {@endtemplate} /// {@endtemplate}
final bool enableInteractiveSelection; final bool enableInteractiveSelection;
...@@ -1186,7 +1189,12 @@ class EditableText extends StatefulWidget { ...@@ -1186,7 +1189,12 @@ class EditableText extends StatefulWidget {
/// {@endtemplate} /// {@endtemplate}
final ScrollPhysics scrollPhysics; final ScrollPhysics scrollPhysics;
/// {@macro flutter.rendering.editable.selectionEnabled} /// {@template flutter.widgets.editableText.selectionEnabled}
/// Same as [enableInteractiveSelection].
///
/// This getter exists primarily for consistency with
/// [RenderEditable.selectionEnabled].
/// {@endtemplate}
bool get selectionEnabled => enableInteractiveSelection; bool get selectionEnabled => enableInteractiveSelection;
/// {@template flutter.widgets.editableText.autofillHints} /// {@template flutter.widgets.editableText.autofillHints}
......
...@@ -630,7 +630,7 @@ void main() { ...@@ -630,7 +630,7 @@ void main() {
); );
}); });
testWidgets('_RenderButtonBarRow.constraints works before layout', (WidgetTester tester) async { testWidgets('_RenderButtonBarRow.constraints does not work before layout', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp(home: ButtonBar()), const MaterialApp(home: ButtonBar()),
Duration.zero, Duration.zero,
...@@ -641,6 +641,6 @@ void main() { ...@@ -641,6 +641,6 @@ void main() {
final RenderBox renderButtonBar = tester.renderObject(buttonBar) as RenderBox; final RenderBox renderButtonBar = tester.renderObject(buttonBar) as RenderBox;
expect(renderButtonBar.debugNeedsLayout, isTrue); expect(renderButtonBar.debugNeedsLayout, isTrue);
expect(renderButtonBar.constraints, isNull); expect(() => renderButtonBar.constraints, throwsStateError);
}); });
} }
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