mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
fix some bad indentations (#41172)
This commit is contained in:
parent
1ea760096a
commit
b873162194
@ -1063,8 +1063,9 @@ class _RenderCupertinoAlertActions extends RenderBox
|
||||
..color = pressedColor,
|
||||
_dividerPaint = Paint()
|
||||
..color = dividerColor
|
||||
..style = PaintingStyle.fill
|
||||
{ addAll(children); }
|
||||
..style = PaintingStyle.fill {
|
||||
addAll(children);
|
||||
}
|
||||
|
||||
// The thickness of the divider between buttons.
|
||||
double get dividerThickness => _dividerThickness;
|
||||
|
@ -1339,7 +1339,7 @@ class _RenderCupertinoDialogActions extends RenderBox
|
||||
final Paint _pressedButtonBackgroundPaint;
|
||||
set dialogPressedColor(Color value) {
|
||||
if (value == _pressedButtonBackgroundPaint.color)
|
||||
return;
|
||||
return;
|
||||
|
||||
_pressedButtonBackgroundPaint.color = value;
|
||||
markNeedsPaint();
|
||||
@ -1348,7 +1348,7 @@ class _RenderCupertinoDialogActions extends RenderBox
|
||||
final Paint _dividerPaint;
|
||||
set dividerColor(Color value) {
|
||||
if (value == _dividerPaint.color)
|
||||
return;
|
||||
return;
|
||||
|
||||
_dividerPaint.color = value;
|
||||
markNeedsPaint();
|
||||
|
@ -225,9 +225,9 @@ class _ToolbarRenderBox extends RenderShiftedBox {
|
||||
@override
|
||||
void debugPaintSize(PaintingContext context, Offset offset) {
|
||||
assert(() {
|
||||
if (child == null) {
|
||||
return true;
|
||||
}
|
||||
if (child == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
_debugPaint ??= Paint()
|
||||
..shader = ui.Gradient.linear(
|
||||
|
@ -98,7 +98,10 @@ abstract class BindingBase {
|
||||
@mustCallSuper
|
||||
void initInstances() {
|
||||
assert(!_debugInitialized);
|
||||
assert(() { _debugInitialized = true; return true; }());
|
||||
assert(() {
|
||||
_debugInitialized = true;
|
||||
return true;
|
||||
}());
|
||||
}
|
||||
|
||||
/// Called when the binding is initialized, to register service
|
||||
@ -182,7 +185,10 @@ abstract class BindingBase {
|
||||
);
|
||||
return true;
|
||||
}());
|
||||
assert(() { _debugServiceExtensionsRegistered = true; return true; }());
|
||||
assert(() {
|
||||
_debugServiceExtensionsRegistered = true;
|
||||
return true;
|
||||
}());
|
||||
}
|
||||
|
||||
/// Whether [lockEvents] is currently locking events.
|
||||
|
@ -52,7 +52,10 @@ bool debugInstrumentationEnabled = false;
|
||||
/// implicitly add any timeline events.
|
||||
Future<T> debugInstrumentAction<T>(String description, Future<T> action()) {
|
||||
bool instrument = false;
|
||||
assert(() { instrument = debugInstrumentationEnabled; return true; }());
|
||||
assert(() {
|
||||
instrument = debugInstrumentationEnabled;
|
||||
return true;
|
||||
}());
|
||||
if (instrument) {
|
||||
final Stopwatch stopwatch = Stopwatch()..start();
|
||||
return action().whenComplete(() {
|
||||
|
@ -163,7 +163,10 @@ abstract class MultiDragPointerState {
|
||||
void dispose() {
|
||||
_arenaEntry?.resolve(GestureDisposition.rejected);
|
||||
_arenaEntry = null;
|
||||
assert(() { _pendingDelta = null; return true; }());
|
||||
assert(() {
|
||||
_pendingDelta = null;
|
||||
return true;
|
||||
}());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ class PointerSignalResolver {
|
||||
}
|
||||
assert((_currentEvent.original ?? _currentEvent) == event);
|
||||
try {
|
||||
_firstRegisteredCallback(_currentEvent);
|
||||
_firstRegisteredCallback(_currentEvent);
|
||||
} catch (exception, stack) {
|
||||
FlutterError.reportError(FlutterErrorDetails(
|
||||
exception: exception,
|
||||
|
@ -480,8 +480,8 @@ class _AppBarState extends State<AppBar> {
|
||||
switch (theme.platform) {
|
||||
case TargetPlatform.android:
|
||||
case TargetPlatform.fuchsia:
|
||||
namesRoute = true;
|
||||
break;
|
||||
namesRoute = true;
|
||||
break;
|
||||
case TargetPlatform.iOS:
|
||||
break;
|
||||
}
|
||||
|
@ -620,7 +620,7 @@ class ButtonThemeData extends Diagnosticable {
|
||||
case ButtonTextTheme.accent:
|
||||
return colorScheme.secondary;
|
||||
|
||||
case ButtonTextTheme.primary: {
|
||||
case ButtonTextTheme.primary:
|
||||
final Color fillColor = getFillColor(button);
|
||||
final bool fillIsDark = fillColor != null
|
||||
? ThemeData.estimateBrightnessForColor(fillColor) == Brightness.dark
|
||||
@ -630,7 +630,6 @@ class ButtonThemeData extends Diagnosticable {
|
||||
if (button is FlatButton || button is OutlineButton)
|
||||
return colorScheme.primary;
|
||||
return Colors.black;
|
||||
}
|
||||
}
|
||||
|
||||
assert(false);
|
||||
|
@ -2776,23 +2776,22 @@ class _RenderChip extends RenderBox {
|
||||
|
||||
@override
|
||||
void debugPaint(PaintingContext context, Offset offset) {
|
||||
assert(!_debugShowTapTargetOutlines ||
|
||||
() {
|
||||
// Draws a rect around the tap targets to help with visualizing where
|
||||
// they really are.
|
||||
final Paint outlinePaint = Paint()
|
||||
..color = const Color(0xff800000)
|
||||
..strokeWidth = 1.0
|
||||
..style = PaintingStyle.stroke;
|
||||
if (deleteIconShowing) {
|
||||
context.canvas.drawRect(deleteButtonRect.shift(offset), outlinePaint);
|
||||
}
|
||||
context.canvas.drawRect(
|
||||
pressRect.shift(offset),
|
||||
outlinePaint..color = const Color(0xff008000),
|
||||
);
|
||||
return true;
|
||||
}());
|
||||
assert(!_debugShowTapTargetOutlines || () {
|
||||
// Draws a rect around the tap targets to help with visualizing where
|
||||
// they really are.
|
||||
final Paint outlinePaint = Paint()
|
||||
..color = const Color(0xff800000)
|
||||
..strokeWidth = 1.0
|
||||
..style = PaintingStyle.stroke;
|
||||
if (deleteIconShowing) {
|
||||
context.canvas.drawRect(deleteButtonRect.shift(offset), outlinePaint);
|
||||
}
|
||||
context.canvas.drawRect(
|
||||
pressRect.shift(offset),
|
||||
outlinePaint..color = const Color(0xff008000),
|
||||
);
|
||||
return true;
|
||||
}());
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -425,12 +425,12 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
|
||||
break;
|
||||
}
|
||||
switch (Directionality.of(context)) {
|
||||
case TextDirection.rtl:
|
||||
_controller.fling(velocity: -visualVelocity);
|
||||
break;
|
||||
case TextDirection.ltr:
|
||||
_controller.fling(velocity: visualVelocity);
|
||||
break;
|
||||
case TextDirection.rtl:
|
||||
_controller.fling(velocity: -visualVelocity);
|
||||
break;
|
||||
case TextDirection.ltr:
|
||||
_controller.fling(velocity: visualVelocity);
|
||||
break;
|
||||
}
|
||||
} else if (_controller.value < 0.5) {
|
||||
close();
|
||||
@ -492,16 +492,14 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
|
||||
double dragAreaWidth = widget.edgeDragWidth;
|
||||
if (widget.edgeDragWidth == null) {
|
||||
switch (textDirection) {
|
||||
case TextDirection.ltr: {
|
||||
case TextDirection.ltr:
|
||||
dragAreaWidth = _kEdgeDragWidth +
|
||||
(drawerIsStart ? padding.left : padding.right);
|
||||
}
|
||||
break;
|
||||
case TextDirection.rtl: {
|
||||
break;
|
||||
case TextDirection.rtl:
|
||||
dragAreaWidth = _kEdgeDragWidth +
|
||||
(drawerIsStart ? padding.right : padding.left);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -898,12 +898,12 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
|
||||
items = widget.selectedItemBuilder == null
|
||||
? List<Widget>.from(widget.items)
|
||||
: widget.selectedItemBuilder(context).map((Widget item) {
|
||||
return Container(
|
||||
height: _kMenuItemHeight,
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: item,
|
||||
);
|
||||
}).toList();
|
||||
return Container(
|
||||
height: _kMenuItemHeight,
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: item,
|
||||
);
|
||||
}).toList();
|
||||
} else {
|
||||
items = <Widget>[];
|
||||
}
|
||||
|
@ -478,16 +478,15 @@ class OutlineInputBorder extends InputBorder {
|
||||
} else {
|
||||
final double extent = lerpDouble(0.0, gapExtent + gapPadding * 2.0, gapPercentage);
|
||||
switch (textDirection) {
|
||||
case TextDirection.rtl: {
|
||||
case TextDirection.rtl:
|
||||
final Path path = _gapBorderPath(canvas, center, math.max(0.0, gapStart + gapPadding - extent), extent);
|
||||
canvas.drawPath(path, paint);
|
||||
break;
|
||||
}
|
||||
case TextDirection.ltr: {
|
||||
|
||||
case TextDirection.ltr:
|
||||
final Path path = _gapBorderPath(canvas, center, math.max(0.0, gapStart - gapPadding), extent);
|
||||
canvas.drawPath(path, paint);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -615,7 +615,10 @@ abstract class InkFeature {
|
||||
@mustCallSuper
|
||||
void dispose() {
|
||||
assert(!_debugDisposed);
|
||||
assert(() { _debugDisposed = true; return true; }());
|
||||
assert(() {
|
||||
_debugDisposed = true;
|
||||
return true;
|
||||
}());
|
||||
_controller._removeFeature(this);
|
||||
if (onRemoved != null)
|
||||
onRemoved();
|
||||
|
@ -1723,10 +1723,10 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
|
||||
final LocalHistoryEntry entry = isPersistent
|
||||
? null
|
||||
: LocalHistoryEntry(onRemove: () {
|
||||
if (!removedEntry) {
|
||||
_removeCurrentBottomSheet();
|
||||
}
|
||||
});
|
||||
if (!removedEntry) {
|
||||
_removeCurrentBottomSheet();
|
||||
}
|
||||
});
|
||||
|
||||
bottomSheet = _StandardBottomSheet(
|
||||
key: bottomSheetKey,
|
||||
|
@ -76,7 +76,10 @@ class _ScrollbarState extends State<Scrollbar> with TickerProviderStateMixin {
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
assert((() { _useCupertinoScrollbar = null; return true; })());
|
||||
assert((() {
|
||||
_useCupertinoScrollbar = null;
|
||||
return true;
|
||||
})());
|
||||
final ThemeData theme = Theme.of(context);
|
||||
switch (theme.platform) {
|
||||
case TargetPlatform.iOS:
|
||||
|
@ -440,7 +440,7 @@ class _SelectableTextState extends State<SelectableText> with AutomaticKeepAlive
|
||||
);
|
||||
}
|
||||
if (_effectiveFocusNode.hasFocus && _controller.selection.isCollapsed) {
|
||||
_showSelectionHandles = false;
|
||||
_showSelectionHandles = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2767,23 +2767,22 @@ class _PaddleSliderTrackShapePathPainter {
|
||||
final double stretch = (neckStretchBaseline * t).clamp(0.0, 10.0 * neckStretchBaseline);
|
||||
final Offset neckStretch = Offset(0.0, neckStretchBaseline - stretch);
|
||||
|
||||
assert(!_debuggingLabelLocation ||
|
||||
() {
|
||||
final Offset leftCenter = _topLobeCenter - Offset(leftWidthNeeded, 0.0) + neckStretch;
|
||||
final Offset rightCenter = _topLobeCenter + Offset(rightWidthNeeded, 0.0) + neckStretch;
|
||||
final Rect valueRect = Rect.fromLTRB(
|
||||
leftCenter.dx - _topLobeRadius,
|
||||
leftCenter.dy - _topLobeRadius,
|
||||
rightCenter.dx + _topLobeRadius,
|
||||
rightCenter.dy + _topLobeRadius,
|
||||
);
|
||||
final Paint outlinePaint = Paint()
|
||||
..color = const Color(0xffff0000)
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 1.0;
|
||||
canvas.drawRect(valueRect, outlinePaint);
|
||||
return true;
|
||||
}());
|
||||
assert(!_debuggingLabelLocation || () {
|
||||
final Offset leftCenter = _topLobeCenter - Offset(leftWidthNeeded, 0.0) + neckStretch;
|
||||
final Offset rightCenter = _topLobeCenter + Offset(rightWidthNeeded, 0.0) + neckStretch;
|
||||
final Rect valueRect = Rect.fromLTRB(
|
||||
leftCenter.dx - _topLobeRadius,
|
||||
leftCenter.dy - _topLobeRadius,
|
||||
rightCenter.dx + _topLobeRadius,
|
||||
rightCenter.dy + _topLobeRadius,
|
||||
);
|
||||
final Paint outlinePaint = Paint()
|
||||
..color = const Color(0xffff0000)
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 1.0;
|
||||
canvas.drawRect(valueRect, outlinePaint);
|
||||
return true;
|
||||
}());
|
||||
|
||||
_addArc(
|
||||
path,
|
||||
|
@ -122,7 +122,7 @@ class _TextFieldSelectionGestureDetectorBuilder extends TextSelectionGestureDete
|
||||
break;
|
||||
case TargetPlatform.android:
|
||||
case TargetPlatform.fuchsia:
|
||||
renderEditable.selectWord(cause: SelectionChangedCause.longPress);
|
||||
renderEditable.selectWord(cause: SelectionChangedCause.longPress);
|
||||
Feedback.forLongPress(_state.context);
|
||||
break;
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ class BeveledRectangleBorder extends ShapeBorder {
|
||||
case BorderStyle.none:
|
||||
break;
|
||||
case BorderStyle.solid:
|
||||
final Path path = getOuterPath(rect, textDirection: textDirection)
|
||||
final Path path = getOuterPath(rect, textDirection: textDirection)
|
||||
..addPath(getInnerPath(rect, textDirection: textDirection), Offset.zero);
|
||||
canvas.drawPath(path, side.toPaint());
|
||||
break;
|
||||
|
@ -138,7 +138,7 @@ class ContinuousRectangleBorder extends ShapeBorder {
|
||||
return;
|
||||
switch (side.style) {
|
||||
case BorderStyle.none:
|
||||
break;
|
||||
break;
|
||||
case BorderStyle.solid:
|
||||
final Path path = getOuterPath(rect, textDirection: textDirection);
|
||||
final Paint paint = side.toPaint();
|
||||
|
@ -275,7 +275,10 @@ class BoxConstraints extends Constraints {
|
||||
/// separately provided widths and heights.
|
||||
Size constrain(Size size) {
|
||||
Size result = Size(constrainWidth(size.width), constrainHeight(size.height));
|
||||
assert(() { result = _debugPropagateDebugSize(size, result); return true; }());
|
||||
assert(() {
|
||||
result = _debugPropagateDebugSize(size, result);
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -298,7 +301,10 @@ class BoxConstraints extends Constraints {
|
||||
Size constrainSizeAndAttemptToPreserveAspectRatio(Size size) {
|
||||
if (isTight) {
|
||||
Size result = smallest;
|
||||
assert(() { result = _debugPropagateDebugSize(size, result); return true; }());
|
||||
assert(() {
|
||||
result = _debugPropagateDebugSize(size, result);
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -329,7 +335,10 @@ class BoxConstraints extends Constraints {
|
||||
}
|
||||
|
||||
Size result = Size(constrainWidth(width), constrainHeight(height));
|
||||
assert(() { result = _debugPropagateDebugSize(size, result); return true; }());
|
||||
assert(() {
|
||||
result = _debugPropagateDebugSize(size, result);
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -522,7 +522,10 @@ class RenderCustomPaint extends RenderProxyBox {
|
||||
void _paintWithPainter(Canvas canvas, Offset offset, CustomPainter painter) {
|
||||
int debugPreviousCanvasSaveCount;
|
||||
canvas.save();
|
||||
assert(() { debugPreviousCanvasSaveCount = canvas.getSaveCount(); return true; }());
|
||||
assert(() {
|
||||
debugPreviousCanvasSaveCount = canvas.getSaveCount();
|
||||
return true;
|
||||
}());
|
||||
if (offset != Offset.zero)
|
||||
canvas.translate(offset.dx, offset.dy);
|
||||
painter.paint(canvas, size);
|
||||
|
@ -525,14 +525,14 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
|
||||
double crossSize;
|
||||
if (flex == 0) {
|
||||
switch (_direction) {
|
||||
case Axis.horizontal:
|
||||
mainSize = child.getMaxIntrinsicWidth(double.infinity);
|
||||
crossSize = childSize(child, mainSize);
|
||||
break;
|
||||
case Axis.vertical:
|
||||
mainSize = child.getMaxIntrinsicHeight(double.infinity);
|
||||
crossSize = childSize(child, mainSize);
|
||||
break;
|
||||
case Axis.horizontal:
|
||||
mainSize = child.getMaxIntrinsicWidth(double.infinity);
|
||||
crossSize = childSize(child, mainSize);
|
||||
break;
|
||||
case Axis.vertical:
|
||||
mainSize = child.getMaxIntrinsicHeight(double.infinity);
|
||||
crossSize = childSize(child, mainSize);
|
||||
break;
|
||||
}
|
||||
inflexibleSpace += mainSize;
|
||||
maxCrossSize = math.max(maxCrossSize, crossSize);
|
||||
|
@ -110,70 +110,70 @@ class RenderListBody extends RenderBox
|
||||
double mainAxisExtent = 0.0;
|
||||
RenderBox child = firstChild;
|
||||
switch (axisDirection) {
|
||||
case AxisDirection.right:
|
||||
final BoxConstraints innerConstraints = BoxConstraints.tightFor(height: constraints.maxHeight);
|
||||
while (child != null) {
|
||||
child.layout(innerConstraints, parentUsesSize: true);
|
||||
final ListBodyParentData childParentData = child.parentData;
|
||||
childParentData.offset = Offset(mainAxisExtent, 0.0);
|
||||
mainAxisExtent += child.size.width;
|
||||
assert(child.parentData == childParentData);
|
||||
child = childParentData.nextSibling;
|
||||
}
|
||||
size = constraints.constrain(Size(mainAxisExtent, constraints.maxHeight));
|
||||
break;
|
||||
case AxisDirection.left:
|
||||
final BoxConstraints innerConstraints = BoxConstraints.tightFor(height: constraints.maxHeight);
|
||||
while (child != null) {
|
||||
child.layout(innerConstraints, parentUsesSize: true);
|
||||
final ListBodyParentData childParentData = child.parentData;
|
||||
mainAxisExtent += child.size.width;
|
||||
assert(child.parentData == childParentData);
|
||||
child = childParentData.nextSibling;
|
||||
}
|
||||
double position = 0.0;
|
||||
child = firstChild;
|
||||
while (child != null) {
|
||||
final ListBodyParentData childParentData = child.parentData;
|
||||
position += child.size.width;
|
||||
childParentData.offset = Offset(mainAxisExtent - position, 0.0);
|
||||
assert(child.parentData == childParentData);
|
||||
child = childParentData.nextSibling;
|
||||
}
|
||||
size = constraints.constrain(Size(mainAxisExtent, constraints.maxHeight));
|
||||
break;
|
||||
case AxisDirection.down:
|
||||
final BoxConstraints innerConstraints = BoxConstraints.tightFor(width: constraints.maxWidth);
|
||||
while (child != null) {
|
||||
child.layout(innerConstraints, parentUsesSize: true);
|
||||
final ListBodyParentData childParentData = child.parentData;
|
||||
childParentData.offset = Offset(0.0, mainAxisExtent);
|
||||
mainAxisExtent += child.size.height;
|
||||
assert(child.parentData == childParentData);
|
||||
child = childParentData.nextSibling;
|
||||
}
|
||||
size = constraints.constrain(Size(constraints.maxWidth, mainAxisExtent));
|
||||
break;
|
||||
case AxisDirection.up:
|
||||
final BoxConstraints innerConstraints = BoxConstraints.tightFor(width: constraints.maxWidth);
|
||||
while (child != null) {
|
||||
child.layout(innerConstraints, parentUsesSize: true);
|
||||
final ListBodyParentData childParentData = child.parentData;
|
||||
mainAxisExtent += child.size.height;
|
||||
assert(child.parentData == childParentData);
|
||||
child = childParentData.nextSibling;
|
||||
}
|
||||
double position = 0.0;
|
||||
child = firstChild;
|
||||
while (child != null) {
|
||||
final ListBodyParentData childParentData = child.parentData;
|
||||
position += child.size.height;
|
||||
childParentData.offset = Offset(0.0, mainAxisExtent - position);
|
||||
assert(child.parentData == childParentData);
|
||||
child = childParentData.nextSibling;
|
||||
}
|
||||
size = constraints.constrain(Size(constraints.maxWidth, mainAxisExtent));
|
||||
break;
|
||||
case AxisDirection.right:
|
||||
final BoxConstraints innerConstraints = BoxConstraints.tightFor(height: constraints.maxHeight);
|
||||
while (child != null) {
|
||||
child.layout(innerConstraints, parentUsesSize: true);
|
||||
final ListBodyParentData childParentData = child.parentData;
|
||||
childParentData.offset = Offset(mainAxisExtent, 0.0);
|
||||
mainAxisExtent += child.size.width;
|
||||
assert(child.parentData == childParentData);
|
||||
child = childParentData.nextSibling;
|
||||
}
|
||||
size = constraints.constrain(Size(mainAxisExtent, constraints.maxHeight));
|
||||
break;
|
||||
case AxisDirection.left:
|
||||
final BoxConstraints innerConstraints = BoxConstraints.tightFor(height: constraints.maxHeight);
|
||||
while (child != null) {
|
||||
child.layout(innerConstraints, parentUsesSize: true);
|
||||
final ListBodyParentData childParentData = child.parentData;
|
||||
mainAxisExtent += child.size.width;
|
||||
assert(child.parentData == childParentData);
|
||||
child = childParentData.nextSibling;
|
||||
}
|
||||
double position = 0.0;
|
||||
child = firstChild;
|
||||
while (child != null) {
|
||||
final ListBodyParentData childParentData = child.parentData;
|
||||
position += child.size.width;
|
||||
childParentData.offset = Offset(mainAxisExtent - position, 0.0);
|
||||
assert(child.parentData == childParentData);
|
||||
child = childParentData.nextSibling;
|
||||
}
|
||||
size = constraints.constrain(Size(mainAxisExtent, constraints.maxHeight));
|
||||
break;
|
||||
case AxisDirection.down:
|
||||
final BoxConstraints innerConstraints = BoxConstraints.tightFor(width: constraints.maxWidth);
|
||||
while (child != null) {
|
||||
child.layout(innerConstraints, parentUsesSize: true);
|
||||
final ListBodyParentData childParentData = child.parentData;
|
||||
childParentData.offset = Offset(0.0, mainAxisExtent);
|
||||
mainAxisExtent += child.size.height;
|
||||
assert(child.parentData == childParentData);
|
||||
child = childParentData.nextSibling;
|
||||
}
|
||||
size = constraints.constrain(Size(constraints.maxWidth, mainAxisExtent));
|
||||
break;
|
||||
case AxisDirection.up:
|
||||
final BoxConstraints innerConstraints = BoxConstraints.tightFor(width: constraints.maxWidth);
|
||||
while (child != null) {
|
||||
child.layout(innerConstraints, parentUsesSize: true);
|
||||
final ListBodyParentData childParentData = child.parentData;
|
||||
mainAxisExtent += child.size.height;
|
||||
assert(child.parentData == childParentData);
|
||||
child = childParentData.nextSibling;
|
||||
}
|
||||
double position = 0.0;
|
||||
child = firstChild;
|
||||
while (child != null) {
|
||||
final ListBodyParentData childParentData = child.parentData;
|
||||
position += child.size.height;
|
||||
childParentData.offset = Offset(0.0, mainAxisExtent - position);
|
||||
assert(child.parentData == childParentData);
|
||||
child = childParentData.nextSibling;
|
||||
}
|
||||
size = constraints.constrain(Size(constraints.maxWidth, mainAxisExtent));
|
||||
break;
|
||||
}
|
||||
assert(size.isFinite);
|
||||
}
|
||||
|
@ -1027,7 +1027,10 @@ class PipelineOwner {
|
||||
Timeline.startSync('Semantics');
|
||||
}
|
||||
assert(_semanticsOwner != null);
|
||||
assert(() { _debugDoingSemantics = true; return true; }());
|
||||
assert(() {
|
||||
_debugDoingSemantics = true;
|
||||
return true;
|
||||
}());
|
||||
try {
|
||||
final List<RenderObject> nodesToProcess = _nodesNeedingSemantics.toList()
|
||||
..sort((RenderObject a, RenderObject b) => a.depth - b.depth);
|
||||
@ -1039,7 +1042,10 @@ class PipelineOwner {
|
||||
_semanticsOwner.sendSemanticsUpdate();
|
||||
} finally {
|
||||
assert(_nodesNeedingSemantics.isEmpty);
|
||||
assert(() { _debugDoingSemantics = false; return true; }());
|
||||
assert(() {
|
||||
_debugDoingSemantics = false;
|
||||
return true;
|
||||
}());
|
||||
if (!kReleaseMode) {
|
||||
Timeline.finishSync();
|
||||
}
|
||||
@ -1681,14 +1687,23 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
|
||||
return true;
|
||||
}());
|
||||
if (sizedByParent) {
|
||||
assert(() { _debugDoingThisResize = true; return true; }());
|
||||
assert(() {
|
||||
_debugDoingThisResize = true;
|
||||
return true;
|
||||
}());
|
||||
try {
|
||||
performResize();
|
||||
assert(() { debugAssertDoesMeetConstraints(); return true; }());
|
||||
assert(() {
|
||||
debugAssertDoesMeetConstraints();
|
||||
return true;
|
||||
}());
|
||||
} catch (e, stack) {
|
||||
_debugReportException('performResize', e, stack);
|
||||
}
|
||||
assert(() { _debugDoingThisResize = false; return true; }());
|
||||
assert(() {
|
||||
_debugDoingThisResize = false;
|
||||
return true;
|
||||
}());
|
||||
}
|
||||
RenderObject debugPreviousActiveLayout;
|
||||
assert(() {
|
||||
@ -1700,7 +1715,10 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
|
||||
try {
|
||||
performLayout();
|
||||
markNeedsSemanticsUpdate();
|
||||
assert(() { debugAssertDoesMeetConstraints(); return true; }());
|
||||
assert(() {
|
||||
debugAssertDoesMeetConstraints();
|
||||
return true;
|
||||
}());
|
||||
} catch (e, stack) {
|
||||
_debugReportException('performLayout', e, stack);
|
||||
}
|
||||
|
@ -707,9 +707,9 @@ class PlatformViewRenderBox extends RenderBox with _PlatformViewGestureMixin {
|
||||
assert(hitTestBehavior != null),
|
||||
assert(gestureRecognizers != null),
|
||||
_controller = controller {
|
||||
this.hitTestBehavior = hitTestBehavior;
|
||||
updateGestureRecognizers(gestureRecognizers);
|
||||
}
|
||||
this.hitTestBehavior = hitTestBehavior;
|
||||
updateGestureRecognizers(gestureRecognizers);
|
||||
}
|
||||
|
||||
/// Sets the [controller] for this render object.
|
||||
///
|
||||
@ -722,8 +722,8 @@ class PlatformViewRenderBox extends RenderBox with _PlatformViewGestureMixin {
|
||||
return;
|
||||
}
|
||||
final bool needsSemanticsUpdate = _controller.viewId != controller.viewId;
|
||||
_controller = controller;
|
||||
markNeedsPaint();
|
||||
_controller = controller;
|
||||
markNeedsPaint();
|
||||
if (needsSemanticsUpdate) {
|
||||
markNeedsSemanticsUpdate();
|
||||
}
|
||||
@ -738,8 +738,8 @@ class PlatformViewRenderBox extends RenderBox with _PlatformViewGestureMixin {
|
||||
///
|
||||
/// Any active gesture arena the `PlatformView` participates in is rejected when the
|
||||
/// set of gesture recognizers is changed.
|
||||
void updateGestureRecognizers(Set<Factory<OneSequenceGestureRecognizer>> gestureRecognizers) {
|
||||
_updateGestureRecognizersWithCallBack(gestureRecognizers, _controller.dispatchPointerEvent);
|
||||
void updateGestureRecognizers(Set<Factory<OneSequenceGestureRecognizer>> gestureRecognizers) {
|
||||
_updateGestureRecognizersWithCallBack(gestureRecognizers, _controller.dispatchPointerEvent);
|
||||
}
|
||||
|
||||
PlatformViewController _controller;
|
||||
|
@ -895,7 +895,10 @@ class RenderTable extends RenderBox {
|
||||
}
|
||||
|
||||
// beyond this point, unflexedTableWidth is no longer valid
|
||||
assert(() { unflexedTableWidth = null; return true; }());
|
||||
assert(() {
|
||||
unflexedTableWidth = null;
|
||||
return true;
|
||||
}());
|
||||
|
||||
// 4. apply the maximum width of the table, shrinking columns as
|
||||
// necessary, applying minimum column widths as we go
|
||||
|
@ -504,7 +504,7 @@ mixin SchedulerBinding on BindingBase, ServicesBinding {
|
||||
FlutterError.reportError(FlutterErrorDetails(
|
||||
exception: reason,
|
||||
library: 'scheduler library',
|
||||
informationCollector: () sync* {
|
||||
informationCollector: () sync* {
|
||||
if (count == 1) {
|
||||
// TODO(jacobr): I have added an extra line break in this case.
|
||||
yield ErrorDescription(
|
||||
@ -1035,7 +1035,10 @@ mixin SchedulerBinding on BindingBase, ServicesBinding {
|
||||
void _invokeFrameCallback(FrameCallback callback, Duration timeStamp, [ StackTrace callbackStack ]) {
|
||||
assert(callback != null);
|
||||
assert(_FrameCallbackEntry.debugCurrentCallbackStack == null);
|
||||
assert(() { _FrameCallbackEntry.debugCurrentCallbackStack = callbackStack; return true; }());
|
||||
assert(() {
|
||||
_FrameCallbackEntry.debugCurrentCallbackStack = callbackStack;
|
||||
return true;
|
||||
}());
|
||||
try {
|
||||
callback(timeStamp);
|
||||
} catch (exception, exceptionStack) {
|
||||
@ -1054,7 +1057,10 @@ mixin SchedulerBinding on BindingBase, ServicesBinding {
|
||||
},
|
||||
));
|
||||
}
|
||||
assert(() { _FrameCallbackEntry.debugCurrentCallbackStack = null; return true; }());
|
||||
assert(() {
|
||||
_FrameCallbackEntry.debugCurrentCallbackStack = null;
|
||||
return true;
|
||||
}());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ class RawKeyEventDataLinux extends RawKeyEventData {
|
||||
|
||||
@override
|
||||
bool isModifierPressed(ModifierKey key, {KeyboardSide side = KeyboardSide.any}) {
|
||||
return keyHelper.isModifierPressed(key, modifiers, side: side);
|
||||
return keyHelper.isModifierPressed(key, modifiers, side: side);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -206,13 +206,13 @@ class GLFWKeyHelper with KeyHelper {
|
||||
bool isModifierPressed(ModifierKey key, int modifiers, {KeyboardSide side = KeyboardSide.any}) {
|
||||
switch (key) {
|
||||
case ModifierKey.controlModifier:
|
||||
return modifiers & modifierControl != 0;
|
||||
return modifiers & modifierControl != 0;
|
||||
case ModifierKey.shiftModifier:
|
||||
return modifiers & modifierShift != 0;
|
||||
return modifiers & modifierShift != 0;
|
||||
case ModifierKey.altModifier:
|
||||
return modifiers & modifierAlt != 0;
|
||||
return modifiers & modifierAlt != 0;
|
||||
case ModifierKey.metaModifier:
|
||||
return modifiers & modifierMeta != 0;
|
||||
return modifiers & modifierMeta != 0;
|
||||
case ModifierKey.capsLockModifier:
|
||||
return modifiers & modifierCapsLock != 0;
|
||||
case ModifierKey.numLockModifier:
|
||||
@ -233,15 +233,15 @@ class GLFWKeyHelper with KeyHelper {
|
||||
case ModifierKey.shiftModifier:
|
||||
case ModifierKey.altModifier:
|
||||
case ModifierKey.metaModifier:
|
||||
// Neither GLFW or X11 provide a distinction between left and right modifiers, so defaults to KeyboardSide.any.
|
||||
// https://code.woboq.org/qt5/include/X11/X.h.html#_M/ShiftMask
|
||||
return KeyboardSide.any;
|
||||
// Neither GLFW or X11 provide a distinction between left and right modifiers, so defaults to KeyboardSide.any.
|
||||
// https://code.woboq.org/qt5/include/X11/X.h.html#_M/ShiftMask
|
||||
return KeyboardSide.any;
|
||||
case ModifierKey.capsLockModifier:
|
||||
case ModifierKey.numLockModifier:
|
||||
case ModifierKey.functionModifier:
|
||||
case ModifierKey.symbolModifier:
|
||||
case ModifierKey.scrollLockModifier:
|
||||
return KeyboardSide.all;
|
||||
return KeyboardSide.all;
|
||||
}
|
||||
assert(false, 'Not handling $key type properly.');
|
||||
return null;
|
||||
@ -254,6 +254,6 @@ class GLFWKeyHelper with KeyHelper {
|
||||
|
||||
@override
|
||||
LogicalKeyboardKey logicalKey(int keyCode) {
|
||||
return kGlfwToLogicalKey[keyCode];
|
||||
return kGlfwToLogicalKey[keyCode];
|
||||
}
|
||||
}
|
||||
|
@ -876,7 +876,10 @@ void runApp(Widget app) {
|
||||
void debugDumpApp() {
|
||||
assert(WidgetsBinding.instance != null);
|
||||
String mode = 'RELEASE MODE';
|
||||
assert(() { mode = 'CHECKED MODE'; return true; }());
|
||||
assert(() {
|
||||
mode = 'CHECKED MODE';
|
||||
return true;
|
||||
}());
|
||||
debugPrint('${WidgetsBinding.instance.runtimeType} - $mode');
|
||||
if (WidgetsBinding.instance.renderViewElement != null) {
|
||||
debugPrint(WidgetsBinding.instance.renderViewElement.toStringDeep());
|
||||
|
@ -1274,12 +1274,12 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
|
||||
}
|
||||
break;
|
||||
case FloatingCursorDragState.End:
|
||||
// We skip animation if no update has happened.
|
||||
// We skip animation if no update has happened.
|
||||
if (_lastTextPosition != null && _lastBoundedOffset != null) {
|
||||
_floatingCursorResetController.value = 0.0;
|
||||
_floatingCursorResetController.animateTo(1.0, duration: _floatingCursorResetTime, curve: Curves.decelerate);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1208,7 +1208,10 @@ abstract class State<T extends StatefulWidget> extends Diagnosticable {
|
||||
@mustCallSuper
|
||||
void dispose() {
|
||||
assert(_debugLifecycleState == _StateLifecycle.ready);
|
||||
assert(() { _debugLifecycleState = _StateLifecycle.defunct; return true; }());
|
||||
assert(() {
|
||||
_debugLifecycleState = _StateLifecycle.defunct;
|
||||
return true;
|
||||
}());
|
||||
}
|
||||
|
||||
/// Describes the part of the user interface represented by this widget.
|
||||
@ -1756,7 +1759,10 @@ class _InactiveElements {
|
||||
element.deactivate();
|
||||
assert(element._debugLifecycleState == _ElementLifecycle.inactive);
|
||||
element.visitChildren(_deactivateRecursively);
|
||||
assert(() { element.debugDeactivated(); return true; }());
|
||||
assert(() {
|
||||
element.debugDeactivated();
|
||||
return true;
|
||||
}());
|
||||
}
|
||||
|
||||
void add(Element element) {
|
||||
@ -2926,7 +2932,10 @@ abstract class Element extends DiagnosticableTree implements BuildContext {
|
||||
key._register(this);
|
||||
}
|
||||
_updateInheritance();
|
||||
assert(() { _debugLifecycleState = _ElementLifecycle.active; return true; }());
|
||||
assert(() {
|
||||
_debugLifecycleState = _ElementLifecycle.active;
|
||||
return true;
|
||||
}());
|
||||
}
|
||||
|
||||
/// Change the widget used to configure this element.
|
||||
@ -3082,7 +3091,10 @@ abstract class Element extends DiagnosticableTree implements BuildContext {
|
||||
final Element newChild = _retakeInactiveElement(key, newWidget);
|
||||
if (newChild != null) {
|
||||
assert(newChild._parent == null);
|
||||
assert(() { _debugCheckForCycles(newChild); return true; }());
|
||||
assert(() {
|
||||
_debugCheckForCycles(newChild);
|
||||
return true;
|
||||
}());
|
||||
newChild._activateWithParent(this, newSlot);
|
||||
final Element updatedChild = updateChild(newChild, newWidget, newSlot);
|
||||
assert(newChild == updatedChild);
|
||||
@ -3090,7 +3102,10 @@ abstract class Element extends DiagnosticableTree implements BuildContext {
|
||||
}
|
||||
}
|
||||
final Element newChild = newWidget.createElement();
|
||||
assert(() { _debugCheckForCycles(newChild); return true; }());
|
||||
assert(() {
|
||||
_debugCheckForCycles(newChild);
|
||||
return true;
|
||||
}());
|
||||
newChild.mount(this, newSlot);
|
||||
assert(newChild._debugLifecycleState == _ElementLifecycle.active);
|
||||
return newChild;
|
||||
@ -3191,7 +3206,10 @@ abstract class Element extends DiagnosticableTree implements BuildContext {
|
||||
_dependencies?.clear();
|
||||
_hadUnsatisfiedDependencies = false;
|
||||
_updateInheritance();
|
||||
assert(() { _debugLifecycleState = _ElementLifecycle.active; return true; }());
|
||||
assert(() {
|
||||
_debugLifecycleState = _ElementLifecycle.active;
|
||||
return true;
|
||||
}());
|
||||
if (_dirty)
|
||||
owner.scheduleBuildFor(this);
|
||||
if (hadDependencies)
|
||||
@ -3228,7 +3246,10 @@ abstract class Element extends DiagnosticableTree implements BuildContext {
|
||||
}
|
||||
_inheritedWidgets = null;
|
||||
_active = false;
|
||||
assert(() { _debugLifecycleState = _ElementLifecycle.inactive; return true; }());
|
||||
assert(() {
|
||||
_debugLifecycleState = _ElementLifecycle.inactive;
|
||||
return true;
|
||||
}());
|
||||
}
|
||||
|
||||
/// Called, in debug mode, after children have been deactivated (see [deactivate]).
|
||||
@ -3260,7 +3281,10 @@ abstract class Element extends DiagnosticableTree implements BuildContext {
|
||||
final GlobalKey key = widget.key;
|
||||
key._unregister(this);
|
||||
}
|
||||
assert(() { _debugLifecycleState = _ElementLifecycle.defunct; return true; }());
|
||||
assert(() {
|
||||
_debugLifecycleState = _ElementLifecycle.defunct;
|
||||
return true;
|
||||
}());
|
||||
}
|
||||
|
||||
@override
|
||||
@ -4075,9 +4099,15 @@ class StatefulElement extends ComponentElement {
|
||||
} finally {
|
||||
_debugSetAllowIgnoredCallsToMarkNeedsBuild(false);
|
||||
}
|
||||
assert(() { _state._debugLifecycleState = _StateLifecycle.initialized; return true; }());
|
||||
assert(() {
|
||||
_state._debugLifecycleState = _StateLifecycle.initialized;
|
||||
return true;
|
||||
}());
|
||||
_state.didChangeDependencies();
|
||||
assert(() { _state._debugLifecycleState = _StateLifecycle.ready; return true; }());
|
||||
assert(() {
|
||||
_state._debugLifecycleState = _StateLifecycle.ready;
|
||||
return true;
|
||||
}());
|
||||
super._firstBuild();
|
||||
}
|
||||
|
||||
@ -4740,7 +4770,10 @@ abstract class RenderObjectElement extends Element {
|
||||
void mount(Element parent, dynamic newSlot) {
|
||||
super.mount(parent, newSlot);
|
||||
_renderObject = widget.createRenderObject(this);
|
||||
assert(() { _debugUpdateRenderObjectOwner(); return true; }());
|
||||
assert(() {
|
||||
_debugUpdateRenderObjectOwner();
|
||||
return true;
|
||||
}());
|
||||
assert(_slot == newSlot);
|
||||
attachRenderObject(newSlot);
|
||||
_dirty = false;
|
||||
@ -4750,7 +4783,10 @@ abstract class RenderObjectElement extends Element {
|
||||
void update(covariant RenderObjectWidget newWidget) {
|
||||
super.update(newWidget);
|
||||
assert(widget == newWidget);
|
||||
assert(() { _debugUpdateRenderObjectOwner(); return true; }());
|
||||
assert(() {
|
||||
_debugUpdateRenderObjectOwner();
|
||||
return true;
|
||||
}());
|
||||
widget.updateRenderObject(this, renderObject);
|
||||
_dirty = false;
|
||||
}
|
||||
|
@ -1581,7 +1581,10 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin {
|
||||
@override
|
||||
void dispose() {
|
||||
assert(!_debugLocked);
|
||||
assert(() { _debugLocked = true; return true; }());
|
||||
assert(() {
|
||||
_debugLocked = true;
|
||||
return true;
|
||||
}());
|
||||
for (NavigatorObserver observer in widget.observers)
|
||||
observer._navigator = null;
|
||||
final List<Route<dynamic>> doomed = _poppedRoutes.toList()..addAll(_history);
|
||||
@ -1591,7 +1594,10 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin {
|
||||
_history.clear();
|
||||
focusScopeNode.dispose();
|
||||
super.dispose();
|
||||
assert(() { _debugLocked = false; return true; }());
|
||||
assert(() {
|
||||
_debugLocked = false;
|
||||
return true;
|
||||
}());
|
||||
}
|
||||
|
||||
/// The overlay this navigator uses for its visual presentation.
|
||||
@ -1767,7 +1773,10 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin {
|
||||
@optionalTypeArgs
|
||||
Future<T> push<T extends Object>(Route<T> route) {
|
||||
assert(!_debugLocked);
|
||||
assert(() { _debugLocked = true; return true; }());
|
||||
assert(() {
|
||||
_debugLocked = true;
|
||||
return true;
|
||||
}());
|
||||
assert(route != null);
|
||||
assert(route._navigator == null);
|
||||
final Route<dynamic> oldRoute = _history.isNotEmpty ? _history.last : null;
|
||||
@ -1783,7 +1792,10 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin {
|
||||
for (NavigatorObserver observer in widget.observers)
|
||||
observer.didPush(route, oldRoute);
|
||||
RouteNotificationMessages.maybeNotifyRouteChange(_routePushedMethod, route, oldRoute);
|
||||
assert(() { _debugLocked = false; return true; }());
|
||||
assert(() {
|
||||
_debugLocked = false;
|
||||
return true;
|
||||
}());
|
||||
_afterNavigation(route);
|
||||
return route.popped;
|
||||
}
|
||||
@ -1848,7 +1860,10 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin {
|
||||
@optionalTypeArgs
|
||||
Future<T> pushReplacement<T extends Object, TO extends Object>(Route<T> newRoute, { TO result }) {
|
||||
assert(!_debugLocked);
|
||||
assert(() { _debugLocked = true; return true; }());
|
||||
assert(() {
|
||||
_debugLocked = true;
|
||||
return true;
|
||||
}());
|
||||
final Route<dynamic> oldRoute = _history.last;
|
||||
assert(oldRoute != null && oldRoute._navigator == this);
|
||||
assert(oldRoute.overlayEntries.isNotEmpty);
|
||||
@ -1877,7 +1892,10 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin {
|
||||
for (NavigatorObserver observer in widget.observers)
|
||||
observer.didReplace(newRoute: newRoute, oldRoute: oldRoute);
|
||||
RouteNotificationMessages.maybeNotifyRouteChange(_routeReplacedMethod, newRoute, oldRoute);
|
||||
assert(() { _debugLocked = false; return true; }());
|
||||
assert(() {
|
||||
_debugLocked = false;
|
||||
return true;
|
||||
}());
|
||||
_afterNavigation(newRoute);
|
||||
return newRoute.popped;
|
||||
}
|
||||
@ -1903,7 +1921,10 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin {
|
||||
@optionalTypeArgs
|
||||
Future<T> pushAndRemoveUntil<T extends Object>(Route<T> newRoute, RoutePredicate predicate) {
|
||||
assert(!_debugLocked);
|
||||
assert(() { _debugLocked = true; return true; }());
|
||||
assert(() {
|
||||
_debugLocked = true;
|
||||
return true;
|
||||
}());
|
||||
|
||||
// The route that is being pushed on top of
|
||||
final Route<dynamic> precedingRoute = _history.isNotEmpty ? _history.last : null;
|
||||
@ -1944,7 +1965,10 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin {
|
||||
for (NavigatorObserver observer in widget.observers)
|
||||
observer.didPush(newRoute, precedingRoute);
|
||||
|
||||
assert(() { _debugLocked = false; return true; }());
|
||||
assert(() {
|
||||
_debugLocked = false;
|
||||
return true;
|
||||
}());
|
||||
_afterNavigation(newRoute);
|
||||
return newRoute.popped;
|
||||
}
|
||||
@ -1964,7 +1988,10 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin {
|
||||
assert(newRoute != null);
|
||||
if (oldRoute == newRoute)
|
||||
return;
|
||||
assert(() { _debugLocked = true; return true; }());
|
||||
assert(() {
|
||||
_debugLocked = true;
|
||||
return true;
|
||||
}());
|
||||
assert(oldRoute._navigator == this);
|
||||
assert(newRoute._navigator == null);
|
||||
assert(oldRoute.overlayEntries.isNotEmpty);
|
||||
@ -1990,7 +2017,10 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin {
|
||||
observer.didReplace(newRoute: newRoute, oldRoute: oldRoute);
|
||||
RouteNotificationMessages.maybeNotifyRouteChange(_routeReplacedMethod, newRoute, oldRoute);
|
||||
oldRoute.dispose();
|
||||
assert(() { _debugLocked = false; return true; }());
|
||||
assert(() {
|
||||
_debugLocked = false;
|
||||
return true;
|
||||
}());
|
||||
}
|
||||
|
||||
/// Replaces a route on the navigator with a new route. The route to be
|
||||
@ -2074,11 +2104,17 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin {
|
||||
@optionalTypeArgs
|
||||
bool pop<T extends Object>([ T result ]) {
|
||||
assert(!_debugLocked);
|
||||
assert(() { _debugLocked = true; return true; }());
|
||||
assert(() {
|
||||
_debugLocked = true;
|
||||
return true;
|
||||
}());
|
||||
final Route<dynamic> route = _history.last;
|
||||
assert(route._navigator == this);
|
||||
bool debugPredictedWouldPop;
|
||||
assert(() { debugPredictedWouldPop = !route.willHandlePopInternally; return true; }());
|
||||
assert(() {
|
||||
debugPredictedWouldPop = !route.willHandlePopInternally;
|
||||
return true;
|
||||
}());
|
||||
if (route.didPop(result ?? route.currentResult)) {
|
||||
assert(debugPredictedWouldPop);
|
||||
if (_history.length > 1) {
|
||||
@ -2093,13 +2129,19 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin {
|
||||
observer.didPop(route, _history.last);
|
||||
RouteNotificationMessages.maybeNotifyRouteChange(_routePoppedMethod, route, _history.last);
|
||||
} else {
|
||||
assert(() { _debugLocked = false; return true; }());
|
||||
assert(() {
|
||||
_debugLocked = false;
|
||||
return true;
|
||||
}());
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
assert(!debugPredictedWouldPop);
|
||||
}
|
||||
assert(() { _debugLocked = false; return true; }());
|
||||
assert(() {
|
||||
_debugLocked = false;
|
||||
return true;
|
||||
}());
|
||||
_afterNavigation<dynamic>(route);
|
||||
return true;
|
||||
}
|
||||
@ -2129,7 +2171,10 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin {
|
||||
void removeRoute(Route<dynamic> route) {
|
||||
assert(route != null);
|
||||
assert(!_debugLocked);
|
||||
assert(() { _debugLocked = true; return true; }());
|
||||
assert(() {
|
||||
_debugLocked = true;
|
||||
return true;
|
||||
}());
|
||||
assert(route._navigator == this);
|
||||
final int index = _history.indexOf(route);
|
||||
assert(index != -1);
|
||||
@ -2141,7 +2186,10 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin {
|
||||
for (NavigatorObserver observer in widget.observers)
|
||||
observer.didRemove(route, previousRoute);
|
||||
route.dispose();
|
||||
assert(() { _debugLocked = false; return true; }());
|
||||
assert(() {
|
||||
_debugLocked = false;
|
||||
return true;
|
||||
}());
|
||||
_afterNavigation<dynamic>(nextRoute);
|
||||
}
|
||||
|
||||
@ -2151,7 +2199,10 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin {
|
||||
/// {@macro flutter.widgets.navigator.removeRouteBelow}
|
||||
void removeRouteBelow(Route<dynamic> anchorRoute) {
|
||||
assert(!_debugLocked);
|
||||
assert(() { _debugLocked = true; return true; }());
|
||||
assert(() {
|
||||
_debugLocked = true;
|
||||
return true;
|
||||
}());
|
||||
assert(anchorRoute._navigator == this);
|
||||
final int index = _history.indexOf(anchorRoute) - 1;
|
||||
assert(index >= 0);
|
||||
@ -2166,7 +2217,10 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin {
|
||||
if (nextRoute != null)
|
||||
nextRoute.didChangePrevious(previousRoute);
|
||||
targetRoute.dispose();
|
||||
assert(() { _debugLocked = false; return true; }());
|
||||
assert(() {
|
||||
_debugLocked = false;
|
||||
return true;
|
||||
}());
|
||||
}
|
||||
|
||||
/// Complete the lifecycle for a route that has been popped off the navigator.
|
||||
|
@ -514,15 +514,15 @@ class _AndroidViewState extends State<AndroidView> {
|
||||
}
|
||||
if (!isFocused) {
|
||||
_controller.clearFocus().catchError((dynamic e) {
|
||||
if (e is MissingPluginException) {
|
||||
// We land the framework part of Android platform views keyboard
|
||||
// support before the engine part. There will be a commit range where
|
||||
// clearFocus isn't implemented in the engine. When that happens we
|
||||
// just swallow the error here. Once the engine part is rolled to the
|
||||
// framework I'll remove this.
|
||||
// TODO(amirh): remove this once the engine's clearFocus is rolled.
|
||||
return;
|
||||
}
|
||||
if (e is MissingPluginException) {
|
||||
// We land the framework part of Android platform views keyboard
|
||||
// support before the engine part. There will be a commit range where
|
||||
// clearFocus isn't implemented in the engine. When that happens we
|
||||
// just swallow the error here. Once the engine part is rolled to the
|
||||
// framework I'll remove this.
|
||||
// TODO(amirh): remove this once the engine's clearFocus is rolled.
|
||||
return;
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
@ -947,7 +947,10 @@ mixin WidgetInspectorService {
|
||||
void initServiceExtensions(_RegisterServiceExtensionCallback registerServiceExtensionCallback) {
|
||||
_registerServiceExtensionCallback = registerServiceExtensionCallback;
|
||||
assert(!_debugServiceExtensionsRegistered);
|
||||
assert(() { _debugServiceExtensionsRegistered = true; return true; }());
|
||||
assert(() {
|
||||
_debugServiceExtensionsRegistered = true;
|
||||
return true;
|
||||
}());
|
||||
|
||||
SchedulerBinding.instance.addPersistentFrameCallback(_onFrameStart);
|
||||
|
||||
|
@ -667,92 +667,98 @@ void main() {
|
||||
statusLog.clear();
|
||||
});
|
||||
|
||||
test('calling repeat with reverse set to true makes the animation alternate '
|
||||
'between lowerBound and upperBound values on each repeat', () {
|
||||
final AnimationController controller = AnimationController(
|
||||
duration: const Duration(milliseconds: 100),
|
||||
value: 0.0,
|
||||
lowerBound: 0.0,
|
||||
upperBound: 1.0,
|
||||
vsync: const TestVSync(),
|
||||
);
|
||||
test(
|
||||
'calling repeat with reverse set to true makes the animation alternate '
|
||||
'between lowerBound and upperBound values on each repeat',
|
||||
() {
|
||||
final AnimationController controller = AnimationController(
|
||||
duration: const Duration(milliseconds: 100),
|
||||
value: 0.0,
|
||||
lowerBound: 0.0,
|
||||
upperBound: 1.0,
|
||||
vsync: const TestVSync(),
|
||||
);
|
||||
|
||||
expect(controller.value, 0.0);
|
||||
expect(controller.value, 0.0);
|
||||
|
||||
controller.repeat(reverse: true);
|
||||
tick(const Duration(milliseconds: 0));
|
||||
tick(const Duration(milliseconds: 25));
|
||||
expect(controller.value, 0.25);
|
||||
controller.repeat(reverse: true);
|
||||
tick(const Duration(milliseconds: 0));
|
||||
tick(const Duration(milliseconds: 25));
|
||||
expect(controller.value, 0.25);
|
||||
|
||||
tick(const Duration(milliseconds: 0));
|
||||
tick(const Duration(milliseconds: 125));
|
||||
expect(controller.value, 0.75);
|
||||
tick(const Duration(milliseconds: 0));
|
||||
tick(const Duration(milliseconds: 125));
|
||||
expect(controller.value, 0.75);
|
||||
|
||||
controller.reset();
|
||||
controller.value = 1.0;
|
||||
expect(controller.value, 1.0);
|
||||
controller.reset();
|
||||
controller.value = 1.0;
|
||||
expect(controller.value, 1.0);
|
||||
|
||||
controller.repeat(reverse: true);
|
||||
tick(const Duration(milliseconds: 0));
|
||||
tick(const Duration(milliseconds: 25));
|
||||
expect(controller.value, 0.75);
|
||||
controller.repeat(reverse: true);
|
||||
tick(const Duration(milliseconds: 0));
|
||||
tick(const Duration(milliseconds: 25));
|
||||
expect(controller.value, 0.75);
|
||||
|
||||
tick(const Duration(milliseconds: 0));
|
||||
tick(const Duration(milliseconds: 125));
|
||||
expect(controller.value, 0.25);
|
||||
tick(const Duration(milliseconds: 0));
|
||||
tick(const Duration(milliseconds: 125));
|
||||
expect(controller.value, 0.25);
|
||||
|
||||
controller.reset();
|
||||
controller.value = 0.5;
|
||||
expect(controller.value, 0.5);
|
||||
controller.reset();
|
||||
controller.value = 0.5;
|
||||
expect(controller.value, 0.5);
|
||||
|
||||
controller.repeat(reverse: true);
|
||||
tick(const Duration(milliseconds: 0));
|
||||
tick(const Duration(milliseconds: 50));
|
||||
expect(controller.value, 1.0);
|
||||
controller.repeat(reverse: true);
|
||||
tick(const Duration(milliseconds: 0));
|
||||
tick(const Duration(milliseconds: 50));
|
||||
expect(controller.value, 1.0);
|
||||
|
||||
tick(const Duration(milliseconds: 0));
|
||||
tick(const Duration(milliseconds: 150));
|
||||
expect(controller.value, 0.0);
|
||||
});
|
||||
tick(const Duration(milliseconds: 0));
|
||||
tick(const Duration(milliseconds: 150));
|
||||
expect(controller.value, 0.0);
|
||||
},
|
||||
);
|
||||
|
||||
test('calling repeat with specified min and max values makes the animation '
|
||||
'alternate between min and max values on each repeat', () {
|
||||
final AnimationController controller = AnimationController(
|
||||
duration: const Duration(milliseconds: 100),
|
||||
value: 0.0,
|
||||
lowerBound: 0.0,
|
||||
upperBound: 1.0,
|
||||
vsync: const TestVSync(),
|
||||
);
|
||||
test(
|
||||
'calling repeat with specified min and max values makes the animation '
|
||||
'alternate between min and max values on each repeat',
|
||||
() {
|
||||
final AnimationController controller = AnimationController(
|
||||
duration: const Duration(milliseconds: 100),
|
||||
value: 0.0,
|
||||
lowerBound: 0.0,
|
||||
upperBound: 1.0,
|
||||
vsync: const TestVSync(),
|
||||
);
|
||||
|
||||
expect(controller.value, 0.0);
|
||||
expect(controller.value, 0.0);
|
||||
|
||||
controller.repeat(reverse: true, min: 0.5, max: 1.0);
|
||||
tick(const Duration(milliseconds: 0));
|
||||
tick(const Duration(milliseconds: 50));
|
||||
expect(controller.value, 0.75);
|
||||
controller.repeat(reverse: true, min: 0.5, max: 1.0);
|
||||
tick(const Duration(milliseconds: 0));
|
||||
tick(const Duration(milliseconds: 50));
|
||||
expect(controller.value, 0.75);
|
||||
|
||||
tick(const Duration(milliseconds: 0));
|
||||
tick(const Duration(milliseconds: 100));
|
||||
expect(controller.value, 1.00);
|
||||
tick(const Duration(milliseconds: 0));
|
||||
tick(const Duration(milliseconds: 100));
|
||||
expect(controller.value, 1.00);
|
||||
|
||||
tick(const Duration(milliseconds: 0));
|
||||
tick(const Duration(milliseconds: 200));
|
||||
expect(controller.value, 0.5);
|
||||
tick(const Duration(milliseconds: 0));
|
||||
tick(const Duration(milliseconds: 200));
|
||||
expect(controller.value, 0.5);
|
||||
|
||||
controller.reset();
|
||||
controller.value = 0.0;
|
||||
expect(controller.value, 0.0);
|
||||
controller.reset();
|
||||
controller.value = 0.0;
|
||||
expect(controller.value, 0.0);
|
||||
|
||||
controller.repeat(reverse: true, min: 1.0, max: 1.0);
|
||||
tick(const Duration(milliseconds: 0));
|
||||
tick(const Duration(milliseconds: 25));
|
||||
expect(controller.value, 1.0);
|
||||
controller.repeat(reverse: true, min: 1.0, max: 1.0);
|
||||
tick(const Duration(milliseconds: 0));
|
||||
tick(const Duration(milliseconds: 25));
|
||||
expect(controller.value, 1.0);
|
||||
|
||||
tick(const Duration(milliseconds: 0));
|
||||
tick(const Duration(milliseconds: 125));
|
||||
expect(controller.value, 1.0);
|
||||
});
|
||||
tick(const Duration(milliseconds: 0));
|
||||
tick(const Duration(milliseconds: 125));
|
||||
expect(controller.value, 1.0);
|
||||
},
|
||||
);
|
||||
|
||||
group('AnimationBehavior', () {
|
||||
test('Default values for constructor', () {
|
||||
|
@ -88,7 +88,10 @@ void main() {
|
||||
final List<String> log = <String>[];
|
||||
|
||||
final VoidCallback listener1 = () { log.add('listener1'); };
|
||||
final VoidCallback badListener = () { log.add('badListener'); throw null; };
|
||||
final VoidCallback badListener = () {
|
||||
log.add('badListener');
|
||||
throw null;
|
||||
};
|
||||
final VoidCallback listener2 = () { log.add('listener2'); };
|
||||
|
||||
controller.addListener(listener1);
|
||||
@ -108,7 +111,10 @@ void main() {
|
||||
final List<String> log = <String>[];
|
||||
|
||||
final AnimationStatusListener listener1 = (AnimationStatus status) { log.add('listener1'); };
|
||||
final AnimationStatusListener badListener = (AnimationStatus status) { log.add('badListener'); throw null; };
|
||||
final AnimationStatusListener badListener = (AnimationStatus status) {
|
||||
log.add('badListener');
|
||||
throw null;
|
||||
};
|
||||
final AnimationStatusListener listener2 = (AnimationStatus status) { log.add('listener2'); };
|
||||
|
||||
controller.addStatusListener(listener1);
|
||||
|
@ -319,7 +319,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('background color is not null', (WidgetTester tester) async {
|
||||
expect(
|
||||
expect(
|
||||
() {
|
||||
CupertinoDatePicker(
|
||||
onDateTimeChanged: (_) { },
|
||||
@ -345,30 +345,30 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('initial date honors minuteInterval', (WidgetTester tester) async {
|
||||
DateTime newDateTime;
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: Center(
|
||||
child: SizedBox(
|
||||
width: 400,
|
||||
height: 400,
|
||||
child: CupertinoDatePicker(
|
||||
onDateTimeChanged: (DateTime d) => newDateTime = d,
|
||||
initialDateTime: DateTime(2018, 10, 10, 10, 3),
|
||||
minuteInterval: 3,
|
||||
),
|
||||
DateTime newDateTime;
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: Center(
|
||||
child: SizedBox(
|
||||
width: 400,
|
||||
height: 400,
|
||||
child: CupertinoDatePicker(
|
||||
onDateTimeChanged: (DateTime d) => newDateTime = d,
|
||||
initialDateTime: DateTime(2018, 10, 10, 10, 3),
|
||||
minuteInterval: 3,
|
||||
),
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
)
|
||||
);
|
||||
|
||||
// Drag the minute picker to the next slot (03 -> 06).
|
||||
// The `initialDateTime` and the `minuteInterval` values are specifically chosen
|
||||
// so that `find.text` finds exactly one widget.
|
||||
await tester.drag(find.text('03'), _kRowOffset);
|
||||
await tester.pump();
|
||||
// Drag the minute picker to the next slot (03 -> 06).
|
||||
// The `initialDateTime` and the `minuteInterval` values are specifically chosen
|
||||
// so that `find.text` finds exactly one widget.
|
||||
await tester.drag(find.text('03'), _kRowOffset);
|
||||
await tester.pump();
|
||||
|
||||
expect(newDateTime.minute, 6);
|
||||
expect(newDateTime.minute, 6);
|
||||
});
|
||||
|
||||
testWidgets('changing initialDateTime after first build does not do anything', (WidgetTester tester) async {
|
||||
|
@ -381,85 +381,86 @@ void main() {
|
||||
final FlutterError error = FlutterError('Oops');
|
||||
double errorCount = 0;
|
||||
|
||||
runZoned(() async {
|
||||
refreshCompleter = Completer<void>.sync();
|
||||
runZoned(
|
||||
() async {
|
||||
refreshCompleter = Completer<void>.sync();
|
||||
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: CustomScrollView(
|
||||
slivers: <Widget>[
|
||||
CupertinoSliverRefreshControl(
|
||||
builder: builder,
|
||||
onRefresh: onRefresh,
|
||||
),
|
||||
buildAListOfStuff(),
|
||||
],
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: CustomScrollView(
|
||||
slivers: <Widget>[
|
||||
CupertinoSliverRefreshControl(
|
||||
builder: builder,
|
||||
onRefresh: onRefresh,
|
||||
),
|
||||
buildAListOfStuff(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
|
||||
await tester.drag(find.text('0'), const Offset(0.0, 150.0), touchSlopY: 0);
|
||||
await tester.pump();
|
||||
// Let it start snapping back.
|
||||
await tester.pump(const Duration(milliseconds: 50));
|
||||
await tester.drag(find.text('0'), const Offset(0.0, 150.0), touchSlopY: 0);
|
||||
await tester.pump();
|
||||
// Let it start snapping back.
|
||||
await tester.pump(const Duration(milliseconds: 50));
|
||||
|
||||
verifyInOrder(<void>[
|
||||
mockHelper.builder(
|
||||
verifyInOrder(<void>[
|
||||
mockHelper.builder(
|
||||
any,
|
||||
RefreshIndicatorMode.armed,
|
||||
150.0,
|
||||
100.0, // Default value.
|
||||
60.0, // Default value.
|
||||
),
|
||||
mockHelper.refreshTask(),
|
||||
mockHelper.builder(
|
||||
any,
|
||||
RefreshIndicatorMode.armed,
|
||||
argThat(moreOrLessEquals(127.10396988577114)),
|
||||
100.0, // Default value.
|
||||
60.0, // Default value.
|
||||
),
|
||||
]);
|
||||
|
||||
// Reaches refresh state and sliver's at 60.0 in height after a while.
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
verify(mockHelper.builder(
|
||||
any,
|
||||
RefreshIndicatorMode.armed,
|
||||
150.0,
|
||||
RefreshIndicatorMode.refresh,
|
||||
60.0,
|
||||
100.0, // Default value.
|
||||
60.0, // Default value.
|
||||
),
|
||||
mockHelper.refreshTask(),
|
||||
mockHelper.builder(
|
||||
));
|
||||
|
||||
// Stays in that state forever until future completes.
|
||||
await tester.pump(const Duration(seconds: 1000));
|
||||
verifyNoMoreInteractions(mockHelper);
|
||||
expect(
|
||||
tester.getTopLeft(find.widgetWithText(Container, '0')),
|
||||
const Offset(0.0, 60.0),
|
||||
);
|
||||
|
||||
refreshCompleter.completeError(error);
|
||||
await tester.pump();
|
||||
|
||||
verify(mockHelper.builder(
|
||||
any,
|
||||
RefreshIndicatorMode.armed,
|
||||
argThat(moreOrLessEquals(127.10396988577114)),
|
||||
RefreshIndicatorMode.done,
|
||||
60.0,
|
||||
100.0, // Default value.
|
||||
60.0, // Default value.
|
||||
),
|
||||
]);
|
||||
));
|
||||
verifyNoMoreInteractions(mockHelper);
|
||||
},
|
||||
onError: (dynamic e) {
|
||||
expect(e, error);
|
||||
expect(errorCount, 0);
|
||||
errorCount++;
|
||||
},
|
||||
);
|
||||
|
||||
// Reaches refresh state and sliver's at 60.0 in height after a while.
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
verify(mockHelper.builder(
|
||||
any,
|
||||
RefreshIndicatorMode.refresh,
|
||||
60.0,
|
||||
100.0, // Default value.
|
||||
60.0, // Default value.
|
||||
));
|
||||
|
||||
// Stays in that state forever until future completes.
|
||||
await tester.pump(const Duration(seconds: 1000));
|
||||
verifyNoMoreInteractions(mockHelper);
|
||||
expect(
|
||||
tester.getTopLeft(find.widgetWithText(Container, '0')),
|
||||
const Offset(0.0, 60.0),
|
||||
);
|
||||
|
||||
refreshCompleter.completeError(error);
|
||||
await tester.pump();
|
||||
|
||||
verify(mockHelper.builder(
|
||||
any,
|
||||
RefreshIndicatorMode.done,
|
||||
60.0,
|
||||
100.0, // Default value.
|
||||
60.0, // Default value.
|
||||
));
|
||||
verifyNoMoreInteractions(mockHelper);
|
||||
},
|
||||
onError: (dynamic e) {
|
||||
expect(e, error);
|
||||
expect(errorCount, 0);
|
||||
errorCount++;
|
||||
},
|
||||
);
|
||||
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -805,15 +805,15 @@ void main() {
|
||||
theme: const CupertinoThemeData(brightness: Brightness.dark),
|
||||
home: CupertinoPageScaffold(
|
||||
child: Builder(builder: (BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () async {
|
||||
await showCupertinoModalPopup<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) => const SizedBox(),
|
||||
);
|
||||
},
|
||||
child: const Text('tap'),
|
||||
);
|
||||
return GestureDetector(
|
||||
onTap: () async {
|
||||
await showCupertinoModalPopup<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) => const SizedBox(),
|
||||
);
|
||||
},
|
||||
child: const Text('tap'),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
|
@ -494,22 +494,24 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'Background color of child should change on selection, '
|
||||
'and should not change when tapped again', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(setupSimpleSegmentedControl());
|
||||
'Background color of child should change on selection, '
|
||||
'and should not change when tapped again',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(setupSimpleSegmentedControl());
|
||||
|
||||
expect(getBackgroundColor(tester, 1), CupertinoColors.white);
|
||||
expect(getBackgroundColor(tester, 1), CupertinoColors.white);
|
||||
|
||||
await tester.tap(find.text('Child 2'));
|
||||
await tester.pumpAndSettle(const Duration(milliseconds: 200));
|
||||
await tester.tap(find.text('Child 2'));
|
||||
await tester.pumpAndSettle(const Duration(milliseconds: 200));
|
||||
|
||||
expect(getBackgroundColor(tester, 1), CupertinoColors.activeBlue);
|
||||
expect(getBackgroundColor(tester, 1), CupertinoColors.activeBlue);
|
||||
|
||||
await tester.tap(find.text('Child 2'));
|
||||
await tester.pump();
|
||||
await tester.tap(find.text('Child 2'));
|
||||
await tester.pump();
|
||||
|
||||
expect(getBackgroundColor(tester, 1), CupertinoColors.activeBlue);
|
||||
});
|
||||
expect(getBackgroundColor(tester, 1), CupertinoColors.activeBlue);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'Children can be non-Text or Icon widgets (in this case, '
|
||||
|
@ -482,7 +482,7 @@ void main() {
|
||||
expect(tester.widget<Opacity>(find.byType(Opacity).first).opacity, 0.5);
|
||||
});
|
||||
|
||||
testWidgets('Switch turns opaque after becoming enabled', (WidgetTester tester) async {
|
||||
testWidgets('Switch turns opaque after becoming enabled', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
|
@ -981,7 +981,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'tapping clear button also calls onChanged when text not empty',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
String value = 'text entry';
|
||||
final TextEditingController controller = TextEditingController();
|
||||
await tester.pumpWidget(
|
||||
@ -2409,7 +2409,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'Double tap shows handles and toolbar if selection is not collapsed',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
final TextEditingController controller = TextEditingController(
|
||||
text: 'abc def ghi',
|
||||
);
|
||||
@ -2438,7 +2438,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'Double tap shows toolbar but not handles if selection is collapsed',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
final TextEditingController controller = TextEditingController(
|
||||
text: 'abc def ghi',
|
||||
);
|
||||
@ -2467,7 +2467,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'Mouse long press does not show handles nor toolbar',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
final TextEditingController controller = TextEditingController(
|
||||
text: 'abc def ghi',
|
||||
);
|
||||
@ -2499,7 +2499,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'Mouse double tap does not show handles nor toolbar',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
final TextEditingController controller = TextEditingController(
|
||||
text: 'abc def ghi',
|
||||
);
|
||||
|
@ -137,22 +137,22 @@ void main() {
|
||||
);
|
||||
|
||||
testWidgets("Theme has default IconThemeData, which is derived from the theme's primary color", (WidgetTester tester) async {
|
||||
const Color primaryColor = CupertinoColors.destructiveRed;
|
||||
const CupertinoThemeData themeData = CupertinoThemeData(primaryColor: primaryColor);
|
||||
const Color primaryColor = CupertinoColors.destructiveRed;
|
||||
const CupertinoThemeData themeData = CupertinoThemeData(primaryColor: primaryColor);
|
||||
|
||||
final IconThemeData resultingIconTheme = await testIconTheme(tester, themeData);
|
||||
final IconThemeData resultingIconTheme = await testIconTheme(tester, themeData);
|
||||
|
||||
expect(resultingIconTheme.color, themeData.primaryColor);
|
||||
expect(resultingIconTheme.color, themeData.primaryColor);
|
||||
});
|
||||
|
||||
testWidgets('IconTheme.of creates a dependency on iconTheme', (WidgetTester tester) async {
|
||||
IconThemeData iconTheme = await testIconTheme(tester, const CupertinoThemeData(primaryColor: CupertinoColors.destructiveRed));
|
||||
IconThemeData iconTheme = await testIconTheme(tester, const CupertinoThemeData(primaryColor: CupertinoColors.destructiveRed));
|
||||
|
||||
expect(buildCount, 1);
|
||||
expect(iconTheme.color, CupertinoColors.destructiveRed);
|
||||
expect(buildCount, 1);
|
||||
expect(iconTheme.color, CupertinoColors.destructiveRed);
|
||||
|
||||
iconTheme = await testIconTheme(tester, const CupertinoThemeData(primaryColor: CupertinoColors.activeOrange));
|
||||
expect(buildCount, 2);
|
||||
expect(iconTheme.color, CupertinoColors.activeOrange);
|
||||
iconTheme = await testIconTheme(tester, const CupertinoThemeData(primaryColor: CupertinoColors.activeOrange));
|
||||
expect(buildCount, 2);
|
||||
expect(iconTheme.color, CupertinoColors.activeOrange);
|
||||
});
|
||||
}
|
||||
|
@ -37,7 +37,10 @@ void main() {
|
||||
final VoidCallback listener = () { log.add('listener'); };
|
||||
final VoidCallback listener1 = () { log.add('listener1'); };
|
||||
final VoidCallback listener2 = () { log.add('listener2'); };
|
||||
final VoidCallback badListener = () { log.add('badListener'); throw null; };
|
||||
final VoidCallback badListener = () {
|
||||
log.add('badListener');
|
||||
throw null;
|
||||
};
|
||||
|
||||
final TestNotifier test = TestNotifier();
|
||||
|
||||
|
@ -60,8 +60,8 @@ Future<void> main() async {
|
||||
library: 'error handling test',
|
||||
context: ErrorDescription('testing the error handling logic'),
|
||||
informationCollector: () sync* {
|
||||
yield ErrorDescription('line 1 of extra information');
|
||||
yield ErrorHint('line 2 of extra information\n');
|
||||
yield ErrorDescription('line 1 of extra information');
|
||||
yield ErrorHint('line 2 of extra information\n');
|
||||
},
|
||||
));
|
||||
expect(console.join('\n'), matches(
|
||||
|
@ -443,17 +443,26 @@ void main() {
|
||||
return ByteData(5); // 0x0000000000
|
||||
});
|
||||
bool data;
|
||||
data = await rootBundle.loadStructuredData<bool>('test', (String value) async { expect(value, '\x00\x00\x00\x00\x00'); return true; });
|
||||
data = await rootBundle.loadStructuredData<bool>('test', (String value) async {
|
||||
expect(value, '\x00\x00\x00\x00\x00');
|
||||
return true;
|
||||
});
|
||||
expect(data, isTrue);
|
||||
expect(completed, isTrue);
|
||||
completed = false;
|
||||
data = await rootBundle.loadStructuredData('test', (String value) async { expect(true, isFalse); return null; });
|
||||
data = await rootBundle.loadStructuredData('test', (String value) async {
|
||||
expect(true, isFalse);
|
||||
return null;
|
||||
});
|
||||
expect(data, isTrue);
|
||||
expect(completed, isFalse);
|
||||
result = await binding.testExtension('evict', <String, String>{'value': 'test'});
|
||||
expect(result, <String, String>{'value': ''});
|
||||
expect(completed, isFalse);
|
||||
data = await rootBundle.loadStructuredData<bool>('test', (String value) async { expect(value, '\x00\x00\x00\x00\x00'); return false; });
|
||||
data = await rootBundle.loadStructuredData<bool>('test', (String value) async {
|
||||
expect(value, '\x00\x00\x00\x00\x00');
|
||||
return false;
|
||||
});
|
||||
expect(data, isFalse);
|
||||
expect(completed, isTrue);
|
||||
ServicesBinding.instance.defaultBinaryMessenger.setMockMessageHandler('flutter/assets', null);
|
||||
|
@ -894,266 +894,280 @@ void main() {
|
||||
recognized.clear();
|
||||
});
|
||||
|
||||
testGesture('On multiple pointers, DragGestureRecognizer is canceled '
|
||||
'when all pointers are canceled (FIFO)', (GestureTester tester) {
|
||||
// This test simulates the following scenario:
|
||||
// P1 down, P2 down, P1 up, P2 up
|
||||
final List<String> logs = <String>[];
|
||||
final HorizontalDragGestureRecognizer hori = HorizontalDragGestureRecognizer()
|
||||
..onDown = (DragDownDetails details) { logs.add('downH'); }
|
||||
..onStart = (DragStartDetails details) { logs.add('startH'); }
|
||||
..onUpdate = (DragUpdateDetails details) { logs.add('updateH'); }
|
||||
..onEnd = (DragEndDetails details) { logs.add('endH'); }
|
||||
..onCancel = () { logs.add('cancelH'); };
|
||||
// Competitor
|
||||
final TapGestureRecognizer vert = TapGestureRecognizer()
|
||||
..onTapDown = (TapDownDetails details) { logs.add('downT'); }
|
||||
..onTapUp = (TapUpDetails details) { logs.add('upT'); }
|
||||
..onTapCancel = () {};
|
||||
addTearDown(hori.dispose);
|
||||
addTearDown(vert.dispose);
|
||||
testGesture(
|
||||
'On multiple pointers, DragGestureRecognizer is canceled '
|
||||
'when all pointers are canceled (FIFO)',
|
||||
(GestureTester tester) {
|
||||
// This test simulates the following scenario:
|
||||
// P1 down, P2 down, P1 up, P2 up
|
||||
final List<String> logs = <String>[];
|
||||
final HorizontalDragGestureRecognizer hori = HorizontalDragGestureRecognizer()
|
||||
..onDown = (DragDownDetails details) { logs.add('downH'); }
|
||||
..onStart = (DragStartDetails details) { logs.add('startH'); }
|
||||
..onUpdate = (DragUpdateDetails details) { logs.add('updateH'); }
|
||||
..onEnd = (DragEndDetails details) { logs.add('endH'); }
|
||||
..onCancel = () { logs.add('cancelH'); };
|
||||
// Competitor
|
||||
final TapGestureRecognizer vert = TapGestureRecognizer()
|
||||
..onTapDown = (TapDownDetails details) { logs.add('downT'); }
|
||||
..onTapUp = (TapUpDetails details) { logs.add('upT'); }
|
||||
..onTapCancel = () {};
|
||||
addTearDown(hori.dispose);
|
||||
addTearDown(vert.dispose);
|
||||
|
||||
final TestPointer pointer1 = TestPointer(4, PointerDeviceKind.touch);
|
||||
final TestPointer pointer2 = TestPointer(5, PointerDeviceKind.touch);
|
||||
final TestPointer pointer1 = TestPointer(4, PointerDeviceKind.touch);
|
||||
final TestPointer pointer2 = TestPointer(5, PointerDeviceKind.touch);
|
||||
|
||||
final PointerDownEvent down1 = pointer1.down(const Offset(10.0, 10.0));
|
||||
final PointerDownEvent down2 = pointer2.down(const Offset(11.0, 10.0));
|
||||
final PointerDownEvent down1 = pointer1.down(const Offset(10.0, 10.0));
|
||||
final PointerDownEvent down2 = pointer2.down(const Offset(11.0, 10.0));
|
||||
|
||||
hori.addPointer(down1);
|
||||
vert.addPointer(down1);
|
||||
tester.route(down1);
|
||||
tester.closeArena(pointer1.pointer);
|
||||
expect(logs, <String>['downH']);
|
||||
logs.clear();
|
||||
hori.addPointer(down1);
|
||||
vert.addPointer(down1);
|
||||
tester.route(down1);
|
||||
tester.closeArena(pointer1.pointer);
|
||||
expect(logs, <String>['downH']);
|
||||
logs.clear();
|
||||
|
||||
hori.addPointer(down2);
|
||||
vert.addPointer(down2);
|
||||
tester.route(down2);
|
||||
tester.closeArena(pointer2.pointer);
|
||||
expect(logs, <String>[]);
|
||||
logs.clear();
|
||||
hori.addPointer(down2);
|
||||
vert.addPointer(down2);
|
||||
tester.route(down2);
|
||||
tester.closeArena(pointer2.pointer);
|
||||
expect(logs, <String>[]);
|
||||
logs.clear();
|
||||
|
||||
tester.route(pointer1.up());
|
||||
GestureBinding.instance.gestureArena.sweep(pointer1.pointer);
|
||||
expect(logs, <String>['downT', 'upT']);
|
||||
logs.clear();
|
||||
tester.route(pointer1.up());
|
||||
GestureBinding.instance.gestureArena.sweep(pointer1.pointer);
|
||||
expect(logs, <String>['downT', 'upT']);
|
||||
logs.clear();
|
||||
|
||||
tester.route(pointer2.up());
|
||||
GestureBinding.instance.gestureArena.sweep(pointer2.pointer);
|
||||
expect(logs, <String>['cancelH']);
|
||||
logs.clear();
|
||||
});
|
||||
tester.route(pointer2.up());
|
||||
GestureBinding.instance.gestureArena.sweep(pointer2.pointer);
|
||||
expect(logs, <String>['cancelH']);
|
||||
logs.clear();
|
||||
},
|
||||
);
|
||||
|
||||
testGesture('On multiple pointers, DragGestureRecognizer is canceled '
|
||||
'when all pointers are canceled (FILO)', (GestureTester tester) {
|
||||
// This test simulates the following scenario:
|
||||
// P1 down, P2 down, P1 up, P2 up
|
||||
final List<String> logs = <String>[];
|
||||
final HorizontalDragGestureRecognizer hori = HorizontalDragGestureRecognizer()
|
||||
..onDown = (DragDownDetails details) { logs.add('downH'); }
|
||||
..onStart = (DragStartDetails details) { logs.add('startH'); }
|
||||
..onUpdate = (DragUpdateDetails details) { logs.add('updateH'); }
|
||||
..onEnd = (DragEndDetails details) { logs.add('endH'); }
|
||||
..onCancel = () { logs.add('cancelH'); };
|
||||
// Competitor
|
||||
final TapGestureRecognizer vert = TapGestureRecognizer()
|
||||
..onTapDown = (TapDownDetails details) { logs.add('downT'); }
|
||||
..onTapUp = (TapUpDetails details) { logs.add('upT'); }
|
||||
..onTapCancel = () {};
|
||||
addTearDown(hori.dispose);
|
||||
addTearDown(vert.dispose);
|
||||
testGesture(
|
||||
'On multiple pointers, DragGestureRecognizer is canceled '
|
||||
'when all pointers are canceled (FILO)',
|
||||
(GestureTester tester) {
|
||||
// This test simulates the following scenario:
|
||||
// P1 down, P2 down, P1 up, P2 up
|
||||
final List<String> logs = <String>[];
|
||||
final HorizontalDragGestureRecognizer hori = HorizontalDragGestureRecognizer()
|
||||
..onDown = (DragDownDetails details) { logs.add('downH'); }
|
||||
..onStart = (DragStartDetails details) { logs.add('startH'); }
|
||||
..onUpdate = (DragUpdateDetails details) { logs.add('updateH'); }
|
||||
..onEnd = (DragEndDetails details) { logs.add('endH'); }
|
||||
..onCancel = () { logs.add('cancelH'); };
|
||||
// Competitor
|
||||
final TapGestureRecognizer vert = TapGestureRecognizer()
|
||||
..onTapDown = (TapDownDetails details) { logs.add('downT'); }
|
||||
..onTapUp = (TapUpDetails details) { logs.add('upT'); }
|
||||
..onTapCancel = () {};
|
||||
addTearDown(hori.dispose);
|
||||
addTearDown(vert.dispose);
|
||||
|
||||
final TestPointer pointer1 = TestPointer(4, PointerDeviceKind.touch);
|
||||
final TestPointer pointer2 = TestPointer(5, PointerDeviceKind.touch);
|
||||
final TestPointer pointer1 = TestPointer(4, PointerDeviceKind.touch);
|
||||
final TestPointer pointer2 = TestPointer(5, PointerDeviceKind.touch);
|
||||
|
||||
final PointerDownEvent down1 = pointer1.down(const Offset(10.0, 10.0));
|
||||
final PointerDownEvent down2 = pointer2.down(const Offset(11.0, 10.0));
|
||||
final PointerDownEvent down1 = pointer1.down(const Offset(10.0, 10.0));
|
||||
final PointerDownEvent down2 = pointer2.down(const Offset(11.0, 10.0));
|
||||
|
||||
hori.addPointer(down1);
|
||||
vert.addPointer(down1);
|
||||
tester.route(down1);
|
||||
tester.closeArena(pointer1.pointer);
|
||||
expect(logs, <String>['downH']);
|
||||
logs.clear();
|
||||
hori.addPointer(down1);
|
||||
vert.addPointer(down1);
|
||||
tester.route(down1);
|
||||
tester.closeArena(pointer1.pointer);
|
||||
expect(logs, <String>['downH']);
|
||||
logs.clear();
|
||||
|
||||
hori.addPointer(down2);
|
||||
vert.addPointer(down2);
|
||||
tester.route(down2);
|
||||
tester.closeArena(pointer2.pointer);
|
||||
expect(logs, <String>[]);
|
||||
logs.clear();
|
||||
hori.addPointer(down2);
|
||||
vert.addPointer(down2);
|
||||
tester.route(down2);
|
||||
tester.closeArena(pointer2.pointer);
|
||||
expect(logs, <String>[]);
|
||||
logs.clear();
|
||||
|
||||
tester.route(pointer2.up());
|
||||
GestureBinding.instance.gestureArena.sweep(pointer2.pointer);
|
||||
// Tap is not triggered because pointer2 is not its primary pointer
|
||||
expect(logs, <String>[]);
|
||||
logs.clear();
|
||||
tester.route(pointer2.up());
|
||||
GestureBinding.instance.gestureArena.sweep(pointer2.pointer);
|
||||
// Tap is not triggered because pointer2 is not its primary pointer
|
||||
expect(logs, <String>[]);
|
||||
logs.clear();
|
||||
|
||||
tester.route(pointer1.up());
|
||||
GestureBinding.instance.gestureArena.sweep(pointer1.pointer);
|
||||
expect(logs, <String>['cancelH', 'downT', 'upT']);
|
||||
logs.clear();
|
||||
tester.route(pointer1.up());
|
||||
GestureBinding.instance.gestureArena.sweep(pointer1.pointer);
|
||||
expect(logs, <String>['cancelH', 'downT', 'upT']);
|
||||
logs.clear();
|
||||
},
|
||||
);
|
||||
|
||||
});
|
||||
testGesture(
|
||||
'On multiple pointers, DragGestureRecognizer is accepted when the '
|
||||
'first pointer is accepted',
|
||||
(GestureTester tester) {
|
||||
// This test simulates the following scenario:
|
||||
// P1 down, P2 down, P1 moves away, P2 up
|
||||
final List<String> logs = <String>[];
|
||||
final HorizontalDragGestureRecognizer hori = HorizontalDragGestureRecognizer()
|
||||
..onDown = (DragDownDetails details) { logs.add('downH'); }
|
||||
..onStart = (DragStartDetails details) { logs.add('startH'); }
|
||||
..onUpdate = (DragUpdateDetails details) { logs.add('updateH'); }
|
||||
..onEnd = (DragEndDetails details) { logs.add('endH'); }
|
||||
..onCancel = () { logs.add('cancelH'); };
|
||||
// Competitor
|
||||
final TapGestureRecognizer vert = TapGestureRecognizer()
|
||||
..onTapDown = (TapDownDetails details) { logs.add('downT'); }
|
||||
..onTapUp = (TapUpDetails details) { logs.add('upT'); }
|
||||
..onTapCancel = () {};
|
||||
addTearDown(hori.dispose);
|
||||
addTearDown(vert.dispose);
|
||||
|
||||
testGesture('On multiple pointers, DragGestureRecognizer is accepted when the '
|
||||
'first pointer is accepted', (GestureTester tester) {
|
||||
// This test simulates the following scenario:
|
||||
// P1 down, P2 down, P1 moves away, P2 up
|
||||
final List<String> logs = <String>[];
|
||||
final HorizontalDragGestureRecognizer hori = HorizontalDragGestureRecognizer()
|
||||
..onDown = (DragDownDetails details) { logs.add('downH'); }
|
||||
..onStart = (DragStartDetails details) { logs.add('startH'); }
|
||||
..onUpdate = (DragUpdateDetails details) { logs.add('updateH'); }
|
||||
..onEnd = (DragEndDetails details) { logs.add('endH'); }
|
||||
..onCancel = () { logs.add('cancelH'); };
|
||||
// Competitor
|
||||
final TapGestureRecognizer vert = TapGestureRecognizer()
|
||||
..onTapDown = (TapDownDetails details) { logs.add('downT'); }
|
||||
..onTapUp = (TapUpDetails details) { logs.add('upT'); }
|
||||
..onTapCancel = () {};
|
||||
addTearDown(hori.dispose);
|
||||
addTearDown(vert.dispose);
|
||||
final TestPointer pointer1 = TestPointer(4, PointerDeviceKind.touch);
|
||||
final TestPointer pointer2 = TestPointer(5, PointerDeviceKind.touch);
|
||||
|
||||
final TestPointer pointer1 = TestPointer(4, PointerDeviceKind.touch);
|
||||
final TestPointer pointer2 = TestPointer(5, PointerDeviceKind.touch);
|
||||
final PointerDownEvent down1 = pointer1.down(const Offset(10.0, 10.0));
|
||||
final PointerDownEvent down2 = pointer2.down(const Offset(11.0, 10.0));
|
||||
|
||||
final PointerDownEvent down1 = pointer1.down(const Offset(10.0, 10.0));
|
||||
final PointerDownEvent down2 = pointer2.down(const Offset(11.0, 10.0));
|
||||
hori.addPointer(down1);
|
||||
vert.addPointer(down1);
|
||||
tester.route(down1);
|
||||
tester.closeArena(pointer1.pointer);
|
||||
expect(logs, <String>['downH']);
|
||||
logs.clear();
|
||||
|
||||
hori.addPointer(down1);
|
||||
vert.addPointer(down1);
|
||||
tester.route(down1);
|
||||
tester.closeArena(pointer1.pointer);
|
||||
expect(logs, <String>['downH']);
|
||||
logs.clear();
|
||||
hori.addPointer(down2);
|
||||
vert.addPointer(down2);
|
||||
tester.route(down2);
|
||||
tester.closeArena(pointer2.pointer);
|
||||
expect(logs, <String>[]);
|
||||
logs.clear();
|
||||
|
||||
hori.addPointer(down2);
|
||||
vert.addPointer(down2);
|
||||
tester.route(down2);
|
||||
tester.closeArena(pointer2.pointer);
|
||||
expect(logs, <String>[]);
|
||||
logs.clear();
|
||||
tester.route(pointer1.move(const Offset(100, 100)));
|
||||
expect(logs, <String>['startH']);
|
||||
logs.clear();
|
||||
|
||||
tester.route(pointer1.move(const Offset(100, 100)));
|
||||
expect(logs, <String>['startH']);
|
||||
logs.clear();
|
||||
tester.route(pointer2.up());
|
||||
GestureBinding.instance.gestureArena.sweep(pointer2.pointer);
|
||||
expect(logs, <String>[]);
|
||||
logs.clear();
|
||||
|
||||
tester.route(pointer2.up());
|
||||
GestureBinding.instance.gestureArena.sweep(pointer2.pointer);
|
||||
expect(logs, <String>[]);
|
||||
logs.clear();
|
||||
tester.route(pointer1.up());
|
||||
GestureBinding.instance.gestureArena.sweep(pointer1.pointer);
|
||||
expect(logs, <String>['endH']);
|
||||
logs.clear();
|
||||
},
|
||||
);
|
||||
|
||||
tester.route(pointer1.up());
|
||||
GestureBinding.instance.gestureArena.sweep(pointer1.pointer);
|
||||
expect(logs, <String>['endH']);
|
||||
logs.clear();
|
||||
});
|
||||
testGesture(
|
||||
'On multiple pointers, canceled pointers (due to up) do not '
|
||||
'prevent later pointers getting accepted',
|
||||
(GestureTester tester) {
|
||||
// This test simulates the following scenario:
|
||||
// P1 down, P2 down, P1 Up, P2 moves away
|
||||
final List<String> logs = <String>[];
|
||||
final HorizontalDragGestureRecognizer hori = HorizontalDragGestureRecognizer()
|
||||
..onDown = (DragDownDetails details) { logs.add('downH'); }
|
||||
..onStart = (DragStartDetails details) { logs.add('startH'); }
|
||||
..onUpdate = (DragUpdateDetails details) { logs.add('updateH'); }
|
||||
..onEnd = (DragEndDetails details) { logs.add('endH'); }
|
||||
..onCancel = () { logs.add('cancelH'); };
|
||||
// Competitor
|
||||
final TapGestureRecognizer vert = TapGestureRecognizer()
|
||||
..onTapDown = (TapDownDetails details) { logs.add('downT'); }
|
||||
..onTapUp = (TapUpDetails details) { logs.add('upT'); }
|
||||
..onTapCancel = () {};
|
||||
addTearDown(hori.dispose);
|
||||
addTearDown(vert.dispose);
|
||||
|
||||
testGesture('On multiple pointers, canceled pointers (due to up) do not '
|
||||
'prevent later pointers getting accepted', (GestureTester tester) {
|
||||
// This test simulates the following scenario:
|
||||
// P1 down, P2 down, P1 Up, P2 moves away
|
||||
final List<String> logs = <String>[];
|
||||
final HorizontalDragGestureRecognizer hori = HorizontalDragGestureRecognizer()
|
||||
..onDown = (DragDownDetails details) { logs.add('downH'); }
|
||||
..onStart = (DragStartDetails details) { logs.add('startH'); }
|
||||
..onUpdate = (DragUpdateDetails details) { logs.add('updateH'); }
|
||||
..onEnd = (DragEndDetails details) { logs.add('endH'); }
|
||||
..onCancel = () { logs.add('cancelH'); };
|
||||
// Competitor
|
||||
final TapGestureRecognizer vert = TapGestureRecognizer()
|
||||
..onTapDown = (TapDownDetails details) { logs.add('downT'); }
|
||||
..onTapUp = (TapUpDetails details) { logs.add('upT'); }
|
||||
..onTapCancel = () {};
|
||||
addTearDown(hori.dispose);
|
||||
addTearDown(vert.dispose);
|
||||
final TestPointer pointer1 = TestPointer(4, PointerDeviceKind.touch);
|
||||
final TestPointer pointer2 = TestPointer(5, PointerDeviceKind.touch);
|
||||
|
||||
final TestPointer pointer1 = TestPointer(4, PointerDeviceKind.touch);
|
||||
final TestPointer pointer2 = TestPointer(5, PointerDeviceKind.touch);
|
||||
final PointerDownEvent down1 = pointer1.down(const Offset(10.0, 10.0));
|
||||
final PointerDownEvent down2 = pointer2.down(const Offset(11.0, 10.0));
|
||||
|
||||
final PointerDownEvent down1 = pointer1.down(const Offset(10.0, 10.0));
|
||||
final PointerDownEvent down2 = pointer2.down(const Offset(11.0, 10.0));
|
||||
hori.addPointer(down1);
|
||||
vert.addPointer(down1);
|
||||
tester.route(down1);
|
||||
tester.closeArena(pointer1.pointer);
|
||||
expect(logs, <String>['downH']);
|
||||
logs.clear();
|
||||
|
||||
hori.addPointer(down1);
|
||||
vert.addPointer(down1);
|
||||
tester.route(down1);
|
||||
tester.closeArena(pointer1.pointer);
|
||||
expect(logs, <String>['downH']);
|
||||
logs.clear();
|
||||
hori.addPointer(down2);
|
||||
vert.addPointer(down2);
|
||||
tester.route(down2);
|
||||
tester.closeArena(pointer2.pointer);
|
||||
expect(logs, <String>[]);
|
||||
logs.clear();
|
||||
|
||||
hori.addPointer(down2);
|
||||
vert.addPointer(down2);
|
||||
tester.route(down2);
|
||||
tester.closeArena(pointer2.pointer);
|
||||
expect(logs, <String>[]);
|
||||
logs.clear();
|
||||
tester.route(pointer1.up());
|
||||
GestureBinding.instance.gestureArena.sweep(pointer1.pointer);
|
||||
expect(logs, <String>['downT', 'upT']);
|
||||
logs.clear();
|
||||
|
||||
tester.route(pointer1.up());
|
||||
GestureBinding.instance.gestureArena.sweep(pointer1.pointer);
|
||||
expect(logs, <String>['downT', 'upT']);
|
||||
logs.clear();
|
||||
tester.route(pointer2.move(const Offset(100, 100)));
|
||||
expect(logs, <String>['startH']);
|
||||
logs.clear();
|
||||
|
||||
tester.route(pointer2.move(const Offset(100, 100)));
|
||||
expect(logs, <String>['startH']);
|
||||
logs.clear();
|
||||
tester.route(pointer2.up());
|
||||
GestureBinding.instance.gestureArena.sweep(pointer2.pointer);
|
||||
expect(logs, <String>['endH']);
|
||||
logs.clear();
|
||||
},
|
||||
);
|
||||
|
||||
tester.route(pointer2.up());
|
||||
GestureBinding.instance.gestureArena.sweep(pointer2.pointer);
|
||||
expect(logs, <String>['endH']);
|
||||
logs.clear();
|
||||
});
|
||||
testGesture(
|
||||
'On multiple pointers, canceled pointers (due to buttons) do not '
|
||||
'prevent later pointers getting accepted',
|
||||
(GestureTester tester) {
|
||||
// This test simulates the following scenario:
|
||||
// P1 down, P2 down, P1 change buttons, P2 moves away
|
||||
final List<String> logs = <String>[];
|
||||
final HorizontalDragGestureRecognizer hori = HorizontalDragGestureRecognizer()
|
||||
..onDown = (DragDownDetails details) { logs.add('downH'); }
|
||||
..onStart = (DragStartDetails details) { logs.add('startH'); }
|
||||
..onUpdate = (DragUpdateDetails details) { logs.add('updateH'); }
|
||||
..onEnd = (DragEndDetails details) { logs.add('endH'); }
|
||||
..onCancel = () { logs.add('cancelH'); };
|
||||
// Competitor
|
||||
final TapGestureRecognizer vert = TapGestureRecognizer()
|
||||
..onTapDown = (TapDownDetails details) { logs.add('downT'); }
|
||||
..onTapUp = (TapUpDetails details) { logs.add('upT'); }
|
||||
..onTapCancel = () {};
|
||||
addTearDown(hori.dispose);
|
||||
addTearDown(vert.dispose);
|
||||
|
||||
testGesture('On multiple pointers, canceled pointers (due to buttons) do not '
|
||||
'prevent later pointers getting accepted', (GestureTester tester) {
|
||||
// This test simulates the following scenario:
|
||||
// P1 down, P2 down, P1 change buttons, P2 moves away
|
||||
final List<String> logs = <String>[];
|
||||
final HorizontalDragGestureRecognizer hori = HorizontalDragGestureRecognizer()
|
||||
..onDown = (DragDownDetails details) { logs.add('downH'); }
|
||||
..onStart = (DragStartDetails details) { logs.add('startH'); }
|
||||
..onUpdate = (DragUpdateDetails details) { logs.add('updateH'); }
|
||||
..onEnd = (DragEndDetails details) { logs.add('endH'); }
|
||||
..onCancel = () { logs.add('cancelH'); };
|
||||
// Competitor
|
||||
final TapGestureRecognizer vert = TapGestureRecognizer()
|
||||
..onTapDown = (TapDownDetails details) { logs.add('downT'); }
|
||||
..onTapUp = (TapUpDetails details) { logs.add('upT'); }
|
||||
..onTapCancel = () {};
|
||||
addTearDown(hori.dispose);
|
||||
addTearDown(vert.dispose);
|
||||
final TestPointer pointer1 = TestPointer(1, PointerDeviceKind.touch);
|
||||
final TestPointer pointer2 = TestPointer(2, PointerDeviceKind.touch);
|
||||
|
||||
final TestPointer pointer1 = TestPointer(1, PointerDeviceKind.touch);
|
||||
final TestPointer pointer2 = TestPointer(2, PointerDeviceKind.touch);
|
||||
final PointerDownEvent down1 = pointer1.down(const Offset(10.0, 10.0));
|
||||
final PointerDownEvent down2 = pointer2.down(const Offset(11.0, 10.0));
|
||||
|
||||
final PointerDownEvent down1 = pointer1.down(const Offset(10.0, 10.0));
|
||||
final PointerDownEvent down2 = pointer2.down(const Offset(11.0, 10.0));
|
||||
hori.addPointer(down1);
|
||||
vert.addPointer(down1);
|
||||
tester.route(down1);
|
||||
tester.closeArena(pointer1.pointer);
|
||||
|
||||
hori.addPointer(down1);
|
||||
vert.addPointer(down1);
|
||||
tester.route(down1);
|
||||
tester.closeArena(pointer1.pointer);
|
||||
hori.addPointer(down2);
|
||||
vert.addPointer(down2);
|
||||
tester.route(down2);
|
||||
tester.closeArena(pointer2.pointer);
|
||||
expect(logs, <String>['downH']);
|
||||
logs.clear();
|
||||
|
||||
hori.addPointer(down2);
|
||||
vert.addPointer(down2);
|
||||
tester.route(down2);
|
||||
tester.closeArena(pointer2.pointer);
|
||||
expect(logs, <String>['downH']);
|
||||
logs.clear();
|
||||
// Pointer 1 changes buttons, which cancel tap, leaving drag the only
|
||||
// remaining member of arena 1, therefore drag is accepted.
|
||||
tester.route(pointer1.move(const Offset(9.9, 9.9), buttons: kSecondaryButton));
|
||||
expect(logs, <String>['startH']);
|
||||
logs.clear();
|
||||
|
||||
// Pointer 1 changes buttons, which cancel tap, leaving drag the only
|
||||
// remaining member of arena 1, therefore drag is accepted.
|
||||
tester.route(pointer1.move(const Offset(9.9, 9.9), buttons: kSecondaryButton));
|
||||
expect(logs, <String>['startH']);
|
||||
logs.clear();
|
||||
tester.route(pointer2.move(const Offset(100, 100)));
|
||||
expect(logs, <String>['updateH']);
|
||||
logs.clear();
|
||||
|
||||
tester.route(pointer2.move(const Offset(100, 100)));
|
||||
expect(logs, <String>['updateH']);
|
||||
logs.clear();
|
||||
|
||||
tester.route(pointer2.up());
|
||||
GestureBinding.instance.gestureArena.sweep(pointer2.pointer);
|
||||
expect(logs, <String>['endH']);
|
||||
logs.clear();
|
||||
});
|
||||
tester.route(pointer2.up());
|
||||
GestureBinding.instance.gestureArena.sweep(pointer2.pointer);
|
||||
expect(logs, <String>['endH']);
|
||||
logs.clear();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ void main() {
|
||||
isInHitRegionTwo = false;
|
||||
tracker = MouseTracker(
|
||||
GestureBinding.instance.pointerRouter,
|
||||
(Offset _) sync* {
|
||||
(Offset _) sync* {
|
||||
if (isInHitRegionOne)
|
||||
yield annotation;
|
||||
else if (isInHitRegionTwo)
|
||||
|
@ -35,34 +35,34 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('BackButton onPressed overrides default pop behavior', (WidgetTester tester) async {
|
||||
bool backPressed = false;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: const Material(child: Text('Home')),
|
||||
routes: <String, WidgetBuilder>{
|
||||
'/next': (BuildContext context) {
|
||||
return Material(
|
||||
child: Center(
|
||||
child: BackButton(onPressed: () => backPressed = true),
|
||||
),
|
||||
);
|
||||
},
|
||||
bool backPressed = false;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: const Material(child: Text('Home')),
|
||||
routes: <String, WidgetBuilder>{
|
||||
'/next': (BuildContext context) {
|
||||
return Material(
|
||||
child: Center(
|
||||
child: BackButton(onPressed: () => backPressed = true),
|
||||
),
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
},
|
||||
)
|
||||
);
|
||||
|
||||
tester.state<NavigatorState>(find.byType(Navigator)).pushNamed('/next');
|
||||
tester.state<NavigatorState>(find.byType(Navigator)).pushNamed('/next');
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.byType(BackButton));
|
||||
await tester.tap(find.byType(BackButton));
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// We're still on the second page.
|
||||
expect(find.text('Home'), findsNothing);
|
||||
// But the custom callback is called.
|
||||
expect(backPressed, true);
|
||||
// We're still on the second page.
|
||||
expect(find.text('Home'), findsNothing);
|
||||
// But the custom callback is called.
|
||||
expect(backPressed, true);
|
||||
});
|
||||
|
||||
testWidgets('BackButton icon', (WidgetTester tester) async {
|
||||
|
@ -239,145 +239,157 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'Chip does not constrain size of label widget if it does not exceed '
|
||||
'the available space', (WidgetTester tester) async {
|
||||
const double labelWidth = 50.0;
|
||||
const double labelHeight = 30.0;
|
||||
final Key labelKey = UniqueKey();
|
||||
'Chip does not constrain size of label widget if it does not exceed '
|
||||
'the available space',
|
||||
(WidgetTester tester) async {
|
||||
const double labelWidth = 50.0;
|
||||
const double labelHeight = 30.0;
|
||||
final Key labelKey = UniqueKey();
|
||||
|
||||
await tester.pumpWidget(
|
||||
_wrapForChip(
|
||||
child: Center(
|
||||
child: Container(
|
||||
width: 500.0,
|
||||
height: 500.0,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Chip(
|
||||
label: Container(
|
||||
key: labelKey,
|
||||
width: labelWidth,
|
||||
height: labelHeight,
|
||||
await tester.pumpWidget(
|
||||
_wrapForChip(
|
||||
child: Center(
|
||||
child: Container(
|
||||
width: 500.0,
|
||||
height: 500.0,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Chip(
|
||||
label: Container(
|
||||
key: labelKey,
|
||||
width: labelWidth,
|
||||
height: labelHeight,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final Size labelSize = tester.getSize(find.byKey(labelKey));
|
||||
expect(labelSize.width, labelWidth);
|
||||
expect(labelSize.height, labelHeight);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'Chip constrains the size of the label widget when it exceeds the '
|
||||
'available space', (WidgetTester tester) async {
|
||||
await _testConstrainedLabel(tester);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'Chip constrains the size of the label widget when it exceeds the '
|
||||
'available space and the avatar is present', (WidgetTester tester) async {
|
||||
await _testConstrainedLabel(
|
||||
tester,
|
||||
avatar: const CircleAvatar(child: Text('A')),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'Chip constrains the size of the label widget when it exceeds the '
|
||||
'available space and the delete icon is present', (WidgetTester tester) async {
|
||||
await _testConstrainedLabel(
|
||||
tester,
|
||||
onDeleted: () { },
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'Chip constrains the size of the label widget when it exceeds the '
|
||||
'available space and both avatar and delete icons are present', (WidgetTester tester) async {
|
||||
await _testConstrainedLabel(
|
||||
tester,
|
||||
avatar: const CircleAvatar(child: Text('A')),
|
||||
onDeleted: () { },
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'Chip constrains the avatar, label, and delete icons to the bounds of '
|
||||
'the chip when it exceeds the available space', (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/11523
|
||||
Widget chipBuilder (String text, {Widget avatar, VoidCallback onDeleted}) {
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Container(
|
||||
width: 150,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Chip(
|
||||
avatar: avatar,
|
||||
label: Text(text),
|
||||
onDeleted: onDeleted,
|
||||
),
|
||||
]
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void chipRectContains(Rect chipRect, Rect rect) {
|
||||
expect(chipRect.contains(rect.topLeft), true);
|
||||
expect(chipRect.contains(rect.topRight), true);
|
||||
expect(chipRect.contains(rect.bottomLeft), true);
|
||||
expect(chipRect.contains(rect.bottomRight), true);
|
||||
}
|
||||
final Size labelSize = tester.getSize(find.byKey(labelKey));
|
||||
expect(labelSize.width, labelWidth);
|
||||
expect(labelSize.height, labelHeight);
|
||||
},
|
||||
);
|
||||
|
||||
Rect chipRect;
|
||||
Rect avatarRect;
|
||||
Rect labelRect;
|
||||
Rect deleteIconRect;
|
||||
const String text = 'Very long text that will be clipped';
|
||||
testWidgets(
|
||||
'Chip constrains the size of the label widget when it exceeds the '
|
||||
'available space',
|
||||
(WidgetTester tester) async {
|
||||
await _testConstrainedLabel(tester);
|
||||
},
|
||||
);
|
||||
|
||||
await tester.pumpWidget(chipBuilder(text));
|
||||
testWidgets(
|
||||
'Chip constrains the size of the label widget when it exceeds the '
|
||||
'available space and the avatar is present',
|
||||
(WidgetTester tester) async {
|
||||
await _testConstrainedLabel(
|
||||
tester,
|
||||
avatar: const CircleAvatar(child: Text('A')),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
chipRect = tester.getRect(find.byType(Chip));
|
||||
labelRect = tester.getRect(find.text(text));
|
||||
chipRectContains(chipRect, labelRect);
|
||||
testWidgets(
|
||||
'Chip constrains the size of the label widget when it exceeds the '
|
||||
'available space and the delete icon is present',
|
||||
(WidgetTester tester) async {
|
||||
await _testConstrainedLabel(
|
||||
tester,
|
||||
onDeleted: () { },
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
await tester.pumpWidget(chipBuilder(
|
||||
text,
|
||||
avatar: const CircleAvatar(child: Text('A')),
|
||||
));
|
||||
await tester.pumpAndSettle();
|
||||
testWidgets(
|
||||
'Chip constrains the size of the label widget when it exceeds the '
|
||||
'available space and both avatar and delete icons are present',
|
||||
(WidgetTester tester) async {
|
||||
await _testConstrainedLabel(
|
||||
tester,
|
||||
avatar: const CircleAvatar(child: Text('A')),
|
||||
onDeleted: () { },
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
chipRect = tester.getRect(find.byType(Chip));
|
||||
avatarRect = tester.getRect(find.byType(CircleAvatar));
|
||||
chipRectContains(chipRect, avatarRect);
|
||||
testWidgets(
|
||||
'Chip constrains the avatar, label, and delete icons to the bounds of '
|
||||
'the chip when it exceeds the available space',
|
||||
(WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/11523
|
||||
Widget chipBuilder (String text, {Widget avatar, VoidCallback onDeleted}) {
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Container(
|
||||
width: 150,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Chip(
|
||||
avatar: avatar,
|
||||
label: Text(text),
|
||||
onDeleted: onDeleted,
|
||||
),
|
||||
]
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
labelRect = tester.getRect(find.text(text));
|
||||
chipRectContains(chipRect, labelRect);
|
||||
void chipRectContains(Rect chipRect, Rect rect) {
|
||||
expect(chipRect.contains(rect.topLeft), true);
|
||||
expect(chipRect.contains(rect.topRight), true);
|
||||
expect(chipRect.contains(rect.bottomLeft), true);
|
||||
expect(chipRect.contains(rect.bottomRight), true);
|
||||
}
|
||||
|
||||
await tester.pumpWidget(chipBuilder(
|
||||
text,
|
||||
avatar: const CircleAvatar(child: Text('A')),
|
||||
onDeleted: () {},
|
||||
));
|
||||
await tester.pumpAndSettle();
|
||||
Rect chipRect;
|
||||
Rect avatarRect;
|
||||
Rect labelRect;
|
||||
Rect deleteIconRect;
|
||||
const String text = 'Very long text that will be clipped';
|
||||
|
||||
chipRect = tester.getRect(find.byType(Chip));
|
||||
avatarRect = tester.getRect(find.byType(CircleAvatar));
|
||||
chipRectContains(chipRect, avatarRect);
|
||||
await tester.pumpWidget(chipBuilder(text));
|
||||
|
||||
labelRect = tester.getRect(find.text(text));
|
||||
chipRectContains(chipRect, labelRect);
|
||||
chipRect = tester.getRect(find.byType(Chip));
|
||||
labelRect = tester.getRect(find.text(text));
|
||||
chipRectContains(chipRect, labelRect);
|
||||
|
||||
deleteIconRect = tester.getRect(find.byIcon(Icons.cancel));
|
||||
chipRectContains(chipRect, deleteIconRect);
|
||||
});
|
||||
await tester.pumpWidget(chipBuilder(
|
||||
text,
|
||||
avatar: const CircleAvatar(child: Text('A')),
|
||||
));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
chipRect = tester.getRect(find.byType(Chip));
|
||||
avatarRect = tester.getRect(find.byType(CircleAvatar));
|
||||
chipRectContains(chipRect, avatarRect);
|
||||
|
||||
labelRect = tester.getRect(find.text(text));
|
||||
chipRectContains(chipRect, labelRect);
|
||||
|
||||
await tester.pumpWidget(chipBuilder(
|
||||
text,
|
||||
avatar: const CircleAvatar(child: Text('A')),
|
||||
onDeleted: () {},
|
||||
));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
chipRect = tester.getRect(find.byType(Chip));
|
||||
avatarRect = tester.getRect(find.byType(CircleAvatar));
|
||||
chipRectContains(chipRect, avatarRect);
|
||||
|
||||
labelRect = tester.getRect(find.text(text));
|
||||
chipRectContains(chipRect, labelRect);
|
||||
|
||||
deleteIconRect = tester.getRect(find.byIcon(Icons.cancel));
|
||||
chipRectContains(chipRect, deleteIconRect);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('Chip in row works ok', (WidgetTester tester) async {
|
||||
const TextStyle style = TextStyle(fontFamily: 'Ahem', fontSize: 10.0);
|
||||
@ -807,12 +819,12 @@ void main() {
|
||||
StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
|
||||
return RawChip(
|
||||
onDeleted: deletable
|
||||
? () {
|
||||
setState(() {
|
||||
wasDeleted = true;
|
||||
});
|
||||
}
|
||||
: null,
|
||||
? () {
|
||||
setState(() {
|
||||
wasDeleted = true;
|
||||
});
|
||||
}
|
||||
: null,
|
||||
deleteIcon: Container(width: 40.0, height: 40.0, key: deleteButtonKey),
|
||||
label: Text('Chip', key: labelKey),
|
||||
shape: const StadiumBorder(),
|
||||
@ -923,12 +935,12 @@ void main() {
|
||||
return RawChip(
|
||||
avatar: avatar,
|
||||
onSelected: selectable != null
|
||||
? (bool value) {
|
||||
setState(() {
|
||||
selected = value;
|
||||
});
|
||||
}
|
||||
: null,
|
||||
? (bool value) {
|
||||
setState(() {
|
||||
selected = value;
|
||||
});
|
||||
}
|
||||
: null,
|
||||
selected: selected,
|
||||
label: Text('Chip', key: labelKey),
|
||||
shape: const StadiumBorder(),
|
||||
@ -1005,12 +1017,12 @@ void main() {
|
||||
StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
|
||||
return RawChip(
|
||||
onSelected: selectable != null
|
||||
? (bool value) {
|
||||
setState(() {
|
||||
selected = value;
|
||||
});
|
||||
}
|
||||
: null,
|
||||
? (bool value) {
|
||||
setState(() {
|
||||
selected = value;
|
||||
});
|
||||
}
|
||||
: null,
|
||||
selected: selected,
|
||||
label: Text('Chip', key: labelKey),
|
||||
shape: const StadiumBorder(),
|
||||
@ -1082,12 +1094,12 @@ void main() {
|
||||
return RawChip(
|
||||
avatar: avatar,
|
||||
onSelected: selectable != null
|
||||
? (bool value) {
|
||||
setState(() {
|
||||
selected = value;
|
||||
});
|
||||
}
|
||||
: null,
|
||||
? (bool value) {
|
||||
setState(() {
|
||||
selected = value;
|
||||
});
|
||||
}
|
||||
: null,
|
||||
selected: selected,
|
||||
label: Text('Chip', key: labelKey),
|
||||
shape: const StadiumBorder(),
|
||||
@ -1229,19 +1241,19 @@ void main() {
|
||||
selected: isSelectable && value,
|
||||
label: Text('$value'),
|
||||
onSelected: isSelectable
|
||||
? (bool newValue) {
|
||||
setState(() {
|
||||
value = newValue;
|
||||
});
|
||||
}
|
||||
: null,
|
||||
? (bool newValue) {
|
||||
setState(() {
|
||||
value = newValue;
|
||||
});
|
||||
}
|
||||
: null,
|
||||
onPressed: isPressable
|
||||
? () {
|
||||
setState(() {
|
||||
value = true;
|
||||
});
|
||||
}
|
||||
: null,
|
||||
? () {
|
||||
setState(() {
|
||||
value = true;
|
||||
});
|
||||
}
|
||||
: null,
|
||||
);
|
||||
}),
|
||||
),
|
||||
|
@ -176,16 +176,17 @@ void main() {
|
||||
await tester.pumpWidget(wrap(
|
||||
child: StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
return ExpandIcon(
|
||||
isExpanded: expanded,
|
||||
onPressed: (bool isExpanded) {
|
||||
setState(() {
|
||||
expanded = !isExpanded;
|
||||
});
|
||||
},
|
||||
color: Colors.indigo,
|
||||
);
|
||||
}),
|
||||
return ExpandIcon(
|
||||
isExpanded: expanded,
|
||||
onPressed: (bool isExpanded) {
|
||||
setState(() {
|
||||
expanded = !isExpanded;
|
||||
});
|
||||
},
|
||||
color: Colors.indigo,
|
||||
);
|
||||
},
|
||||
),
|
||||
));
|
||||
await tester.pumpAndSettle();
|
||||
iconTheme = tester.firstWidget(find.byType(IconTheme).last);
|
||||
@ -201,17 +202,18 @@ void main() {
|
||||
await tester.pumpWidget(wrap(
|
||||
child: StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
return ExpandIcon(
|
||||
isExpanded: expanded,
|
||||
onPressed: (bool isExpanded) {
|
||||
setState(() {
|
||||
expanded = !isExpanded;
|
||||
});
|
||||
},
|
||||
color: Colors.indigo,
|
||||
expandedColor: Colors.teal,
|
||||
);
|
||||
}),
|
||||
return ExpandIcon(
|
||||
isExpanded: expanded,
|
||||
onPressed: (bool isExpanded) {
|
||||
setState(() {
|
||||
expanded = !isExpanded;
|
||||
});
|
||||
},
|
||||
color: Colors.indigo,
|
||||
expandedColor: Colors.teal,
|
||||
);
|
||||
},
|
||||
),
|
||||
));
|
||||
await tester.pumpAndSettle();
|
||||
iconTheme = tester.firstWidget(find.byType(IconTheme).last);
|
||||
|
@ -636,132 +636,135 @@ void main() {
|
||||
expect(callbackResults['isExpanded'], equals(false));
|
||||
});
|
||||
|
||||
testWidgets('didUpdateWidget accounts for toggling between ExpansionPanelList'
|
||||
'and ExpansionPaneList.radio', (WidgetTester tester) async {
|
||||
bool isRadioList = false;
|
||||
final List<bool> _panelExpansionState = <bool>[
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
];
|
||||
testWidgets(
|
||||
'didUpdateWidget accounts for toggling between ExpansionPanelList'
|
||||
'and ExpansionPaneList.radio',
|
||||
(WidgetTester tester) async {
|
||||
bool isRadioList = false;
|
||||
final List<bool> _panelExpansionState = <bool>[
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
];
|
||||
|
||||
ExpansionPanelList buildRadioExpansionPanelList() {
|
||||
return ExpansionPanelList.radio(
|
||||
initialOpenPanelValue: 2,
|
||||
children: <ExpansionPanelRadio>[
|
||||
ExpansionPanelRadio(
|
||||
headerBuilder: (BuildContext context, bool isExpanded) {
|
||||
return Text(isExpanded ? 'B' : 'A');
|
||||
},
|
||||
body: const SizedBox(height: 100.0),
|
||||
value: 0,
|
||||
),
|
||||
ExpansionPanelRadio(
|
||||
headerBuilder: (BuildContext context, bool isExpanded) {
|
||||
return Text(isExpanded ? 'D' : 'C');
|
||||
},
|
||||
body: const SizedBox(height: 100.0),
|
||||
value: 1,
|
||||
),
|
||||
ExpansionPanelRadio(
|
||||
headerBuilder: (BuildContext context, bool isExpanded) {
|
||||
return Text(isExpanded ? 'F' : 'E');
|
||||
},
|
||||
body: const SizedBox(height: 100.0),
|
||||
value: 2,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
ExpansionPanelList buildExpansionPanelList(Function setState) {
|
||||
return ExpansionPanelList(
|
||||
expansionCallback: (int index, _) => setState(() { _panelExpansionState[index] = !_panelExpansionState[index]; }),
|
||||
children: <ExpansionPanel>[
|
||||
ExpansionPanel(
|
||||
isExpanded: _panelExpansionState[0],
|
||||
headerBuilder: (BuildContext context, bool isExpanded) {
|
||||
return Text(isExpanded ? 'B' : 'A');
|
||||
},
|
||||
body: const SizedBox(height: 100.0),
|
||||
),
|
||||
ExpansionPanel(
|
||||
isExpanded: _panelExpansionState[1],
|
||||
headerBuilder: (BuildContext context, bool isExpanded) {
|
||||
return Text(isExpanded ? 'D' : 'C');
|
||||
},
|
||||
body: const SizedBox(height: 100.0),
|
||||
),
|
||||
ExpansionPanel(
|
||||
isExpanded: _panelExpansionState[2],
|
||||
headerBuilder: (BuildContext context, bool isExpanded) {
|
||||
return Text(isExpanded ? 'F' : 'E');
|
||||
},
|
||||
body: const SizedBox(height: 100.0),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
await tester.pumpWidget(
|
||||
StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
body: SingleChildScrollView(
|
||||
child: isRadioList
|
||||
? buildRadioExpansionPanelList()
|
||||
: buildExpansionPanelList(setState)
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () => setState(() { isRadioList = !isRadioList; }),
|
||||
),
|
||||
ExpansionPanelList buildRadioExpansionPanelList() {
|
||||
return ExpansionPanelList.radio(
|
||||
initialOpenPanelValue: 2,
|
||||
children: <ExpansionPanelRadio>[
|
||||
ExpansionPanelRadio(
|
||||
headerBuilder: (BuildContext context, bool isExpanded) {
|
||||
return Text(isExpanded ? 'B' : 'A');
|
||||
},
|
||||
body: const SizedBox(height: 100.0),
|
||||
value: 0,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
ExpansionPanelRadio(
|
||||
headerBuilder: (BuildContext context, bool isExpanded) {
|
||||
return Text(isExpanded ? 'D' : 'C');
|
||||
},
|
||||
body: const SizedBox(height: 100.0),
|
||||
value: 1,
|
||||
),
|
||||
ExpansionPanelRadio(
|
||||
headerBuilder: (BuildContext context, bool isExpanded) {
|
||||
return Text(isExpanded ? 'F' : 'E');
|
||||
},
|
||||
body: const SizedBox(height: 100.0),
|
||||
value: 2,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
expect(find.text('A'), findsOneWidget);
|
||||
expect(find.text('B'), findsNothing);
|
||||
expect(find.text('C'), findsOneWidget);
|
||||
expect(find.text('D'), findsNothing);
|
||||
expect(find.text('E'), findsOneWidget);
|
||||
expect(find.text('F'), findsNothing);
|
||||
ExpansionPanelList buildExpansionPanelList(Function setState) {
|
||||
return ExpansionPanelList(
|
||||
expansionCallback: (int index, _) => setState(() { _panelExpansionState[index] = !_panelExpansionState[index]; }),
|
||||
children: <ExpansionPanel>[
|
||||
ExpansionPanel(
|
||||
isExpanded: _panelExpansionState[0],
|
||||
headerBuilder: (BuildContext context, bool isExpanded) {
|
||||
return Text(isExpanded ? 'B' : 'A');
|
||||
},
|
||||
body: const SizedBox(height: 100.0),
|
||||
),
|
||||
ExpansionPanel(
|
||||
isExpanded: _panelExpansionState[1],
|
||||
headerBuilder: (BuildContext context, bool isExpanded) {
|
||||
return Text(isExpanded ? 'D' : 'C');
|
||||
},
|
||||
body: const SizedBox(height: 100.0),
|
||||
),
|
||||
ExpansionPanel(
|
||||
isExpanded: _panelExpansionState[2],
|
||||
headerBuilder: (BuildContext context, bool isExpanded) {
|
||||
return Text(isExpanded ? 'F' : 'E');
|
||||
},
|
||||
body: const SizedBox(height: 100.0),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
await tester.tap(find.byType(ExpandIcon).at(0));
|
||||
await tester.tap(find.byType(ExpandIcon).at(1));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pumpWidget(
|
||||
StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
body: SingleChildScrollView(
|
||||
child: isRadioList
|
||||
? buildRadioExpansionPanelList()
|
||||
: buildExpansionPanelList(setState)
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () => setState(() { isRadioList = !isRadioList; }),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text('A'), findsNothing);
|
||||
expect(find.text('B'), findsOneWidget);
|
||||
expect(find.text('C'), findsNothing);
|
||||
expect(find.text('D'), findsOneWidget);
|
||||
expect(find.text('E'), findsOneWidget);
|
||||
expect(find.text('F'), findsNothing);
|
||||
expect(find.text('A'), findsOneWidget);
|
||||
expect(find.text('B'), findsNothing);
|
||||
expect(find.text('C'), findsOneWidget);
|
||||
expect(find.text('D'), findsNothing);
|
||||
expect(find.text('E'), findsOneWidget);
|
||||
expect(find.text('F'), findsNothing);
|
||||
|
||||
// ExpansionPanelList --> ExpansionPanelList.radio
|
||||
await tester.tap(find.byType(FloatingActionButton));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byType(ExpandIcon).at(0));
|
||||
await tester.tap(find.byType(ExpandIcon).at(1));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('A'), findsOneWidget);
|
||||
expect(find.text('B'), findsNothing);
|
||||
expect(find.text('C'), findsOneWidget);
|
||||
expect(find.text('D'), findsNothing);
|
||||
expect(find.text('E'), findsNothing);
|
||||
expect(find.text('F'), findsOneWidget);
|
||||
expect(find.text('A'), findsNothing);
|
||||
expect(find.text('B'), findsOneWidget);
|
||||
expect(find.text('C'), findsNothing);
|
||||
expect(find.text('D'), findsOneWidget);
|
||||
expect(find.text('E'), findsOneWidget);
|
||||
expect(find.text('F'), findsNothing);
|
||||
|
||||
// ExpansionPanelList.radio --> ExpansionPanelList
|
||||
await tester.tap(find.byType(FloatingActionButton));
|
||||
await tester.pumpAndSettle();
|
||||
// ExpansionPanelList --> ExpansionPanelList.radio
|
||||
await tester.tap(find.byType(FloatingActionButton));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('A'), findsNothing);
|
||||
expect(find.text('B'), findsOneWidget);
|
||||
expect(find.text('C'), findsNothing);
|
||||
expect(find.text('D'), findsOneWidget);
|
||||
expect(find.text('E'), findsOneWidget);
|
||||
expect(find.text('F'), findsNothing);
|
||||
});
|
||||
expect(find.text('A'), findsOneWidget);
|
||||
expect(find.text('B'), findsNothing);
|
||||
expect(find.text('C'), findsOneWidget);
|
||||
expect(find.text('D'), findsNothing);
|
||||
expect(find.text('E'), findsNothing);
|
||||
expect(find.text('F'), findsOneWidget);
|
||||
|
||||
// ExpansionPanelList.radio --> ExpansionPanelList
|
||||
await tester.tap(find.byType(FloatingActionButton));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('A'), findsNothing);
|
||||
expect(find.text('B'), findsOneWidget);
|
||||
expect(find.text('C'), findsNothing);
|
||||
expect(find.text('D'), findsOneWidget);
|
||||
expect(find.text('E'), findsOneWidget);
|
||||
expect(find.text('F'), findsNothing);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('No duplicate global keys at layout/build time', (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/13780
|
||||
|
@ -29,8 +29,7 @@ void main() {
|
||||
expect(popupMenuTheme.textStyle, null);
|
||||
});
|
||||
|
||||
testWidgets('Default PopupMenuThemeData debugFillProperties',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('Default PopupMenuThemeData debugFillProperties', (WidgetTester tester) async {
|
||||
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
|
||||
const PopupMenuThemeData().debugFillProperties(builder);
|
||||
|
||||
@ -42,8 +41,7 @@ void main() {
|
||||
expect(description, <String>[]);
|
||||
});
|
||||
|
||||
testWidgets('PopupMenuThemeData implements debugFillProperties',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('PopupMenuThemeData implements debugFillProperties', (WidgetTester tester) async {
|
||||
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
|
||||
PopupMenuThemeData(
|
||||
color: const Color(0xFFFFFFFF),
|
||||
|
@ -1559,51 +1559,51 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('Drawer opens correctly with custom edgeDragWidth', (WidgetTester tester) async {
|
||||
// The default edge drag width is 20.0.
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
drawer: const Drawer(
|
||||
child: Text('Drawer'),
|
||||
),
|
||||
body: const Text('Scaffold body'),
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: const Text('Title'),
|
||||
),
|
||||
testWidgets('Drawer opens correctly with custom edgeDragWidth', (WidgetTester tester) async {
|
||||
// The default edge drag width is 20.0.
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
drawer: const Drawer(
|
||||
child: Text('Drawer'),
|
||||
),
|
||||
body: const Text('Scaffold body'),
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: const Text('Title'),
|
||||
),
|
||||
),
|
||||
);
|
||||
ScaffoldState scaffoldState = tester.state(find.byType(Scaffold));
|
||||
expect(scaffoldState.isDrawerOpen, false);
|
||||
),
|
||||
);
|
||||
ScaffoldState scaffoldState = tester.state(find.byType(Scaffold));
|
||||
expect(scaffoldState.isDrawerOpen, false);
|
||||
|
||||
await tester.dragFrom(const Offset(35, 100), const Offset(300, 0));
|
||||
await tester.pumpAndSettle();
|
||||
expect(scaffoldState.isDrawerOpen, false);
|
||||
await tester.dragFrom(const Offset(35, 100), const Offset(300, 0));
|
||||
await tester.pumpAndSettle();
|
||||
expect(scaffoldState.isDrawerOpen, false);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
drawer: const Drawer(
|
||||
child: Text('Drawer'),
|
||||
),
|
||||
drawerEdgeDragWidth: 40.0,
|
||||
body: const Text('Scaffold Body'),
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: const Text('Title'),
|
||||
),
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
drawer: const Drawer(
|
||||
child: Text('Drawer'),
|
||||
),
|
||||
drawerEdgeDragWidth: 40.0,
|
||||
body: const Text('Scaffold Body'),
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: const Text('Title'),
|
||||
),
|
||||
),
|
||||
);
|
||||
scaffoldState = tester.state(find.byType(Scaffold));
|
||||
expect(scaffoldState.isDrawerOpen, false);
|
||||
),
|
||||
);
|
||||
scaffoldState = tester.state(find.byType(Scaffold));
|
||||
expect(scaffoldState.isDrawerOpen, false);
|
||||
|
||||
await tester.dragFrom(const Offset(35, 100), const Offset(300, 0));
|
||||
await tester.pumpAndSettle();
|
||||
expect(scaffoldState.isDrawerOpen, true);
|
||||
});
|
||||
await tester.dragFrom(const Offset(35, 100), const Offset(300, 0));
|
||||
await tester.pumpAndSettle();
|
||||
expect(scaffoldState.isDrawerOpen, true);
|
||||
});
|
||||
|
||||
testWidgets('Nested scaffold body insets', (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/20295
|
||||
|
@ -1548,8 +1548,7 @@ void main() {
|
||||
expect(renderObject.size.height, 200);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'Slider implements debugFillProperties', (WidgetTester tester) async {
|
||||
testWidgets('Slider implements debugFillProperties', (WidgetTester tester) async {
|
||||
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
|
||||
|
||||
const Slider(
|
||||
|
@ -6887,7 +6887,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'Tap in empty text field does not show handles nor toolbar',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
final TextEditingController controller = TextEditingController();
|
||||
|
||||
await tester.pumpWidget(
|
||||
@ -6932,7 +6932,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'Long press in empty text field shows handles and toolbar',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
final TextEditingController controller = TextEditingController();
|
||||
|
||||
await tester.pumpWidget(
|
||||
@ -6979,7 +6979,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'Double tap in empty text field shows toolbar but not handles',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
final TextEditingController controller = TextEditingController();
|
||||
|
||||
await tester.pumpWidget(
|
||||
@ -7004,7 +7004,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'Mouse tap does not show handles nor toolbar',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
final TextEditingController controller = TextEditingController(
|
||||
text: 'abc def ghi',
|
||||
);
|
||||
@ -7037,7 +7037,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'Mouse long press does not show handles nor toolbar',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
final TextEditingController controller = TextEditingController(
|
||||
text: 'abc def ghi',
|
||||
);
|
||||
@ -7070,7 +7070,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'Mouse double tap does not show handles nor toolbar',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
final TextEditingController controller = TextEditingController(
|
||||
text: 'abc def ghi',
|
||||
);
|
||||
|
@ -176,7 +176,10 @@ void main() {
|
||||
child: Center(
|
||||
child: TextFormField(
|
||||
autovalidate: true,
|
||||
validator: (String value) { _validateCalled++; return null; },
|
||||
validator: (String value) {
|
||||
_validateCalled++;
|
||||
return null;
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -199,7 +202,10 @@ void main() {
|
||||
child: TextFormField(
|
||||
enabled: true,
|
||||
autovalidate: true,
|
||||
validator: (String value) { _validateCalled += 1; return null; },
|
||||
validator: (String value) {
|
||||
_validateCalled += 1;
|
||||
return null;
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -58,7 +58,7 @@ void main() {
|
||||
expect(theme.data.borderWidth, null);
|
||||
});
|
||||
|
||||
testWidgets('Default ToggleButtonsThemeData debugFillProperties', (WidgetTester tester) async {
|
||||
testWidgets('Default ToggleButtonsThemeData debugFillProperties', (WidgetTester tester) async {
|
||||
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
|
||||
const ToggleButtonsThemeData().debugFillProperties(builder);
|
||||
|
||||
@ -90,12 +90,12 @@ void main() {
|
||||
borderWidth: 2.0,
|
||||
).debugFillProperties(builder);
|
||||
|
||||
final List<String> description = builder.properties
|
||||
final List<String> description = builder.properties
|
||||
.where((DiagnosticsNode node) => !node.isFiltered(DiagnosticLevel.info))
|
||||
.map((DiagnosticsNode node) => node.toString())
|
||||
.toList();
|
||||
|
||||
expect(description, <String>[
|
||||
expect(description, <String>[
|
||||
'textStyle.inherit: true',
|
||||
'textStyle.size: 10.0',
|
||||
'constraints: BoxConstraints(0.0<=w<=Infinity, 10.0<=h<=20.0)',
|
||||
|
@ -115,8 +115,7 @@ void main() {
|
||||
}));
|
||||
});
|
||||
|
||||
test(
|
||||
'When high-res device and high-res asset not present in bundle then return main variant', () {
|
||||
test('When high-res device and high-res asset not present in bundle then return main variant', () {
|
||||
const String mainAssetPath = 'assets/normalFolder/normalFile.png';
|
||||
|
||||
final Map<String, List<String>> assetBundleMap =
|
||||
|
@ -113,7 +113,7 @@ class LoadErrorImageProvider extends ImageProvider<LoadErrorImageProvider> {
|
||||
throw Error();
|
||||
}
|
||||
|
||||
@override
|
||||
@override
|
||||
Future<LoadErrorImageProvider> obtainKey(ImageConfiguration configuration) {
|
||||
return SynchronousFuture<LoadErrorImageProvider>(this);
|
||||
}
|
||||
@ -127,7 +127,7 @@ class LoadErrorCompleterImageProvider extends ImageProvider<LoadErrorCompleterIm
|
||||
return OneFrameImageStreamCompleter(completer.future);
|
||||
}
|
||||
|
||||
@override
|
||||
@override
|
||||
Future<LoadErrorCompleterImageProvider> obtainKey(ImageConfiguration configuration) {
|
||||
return SynchronousFuture<LoadErrorCompleterImageProvider>(this);
|
||||
}
|
||||
|
@ -7,7 +7,10 @@ import '../flutter_test_alternative.dart';
|
||||
|
||||
class RenderTestBox extends RenderBox {
|
||||
double value = 0.0;
|
||||
double next() { value += 1.0; return value; }
|
||||
double next() {
|
||||
value += 1.0;
|
||||
return value;
|
||||
}
|
||||
@override
|
||||
double computeMinIntrinsicWidth(double height) => next();
|
||||
@override
|
||||
|
@ -312,7 +312,7 @@ class FakeIosPlatformViewsController {
|
||||
|
||||
class FakeHtmlPlatformViewsController {
|
||||
FakeHtmlPlatformViewsController() {
|
||||
SystemChannels.platform_views.setMockMethodCallHandler(_onMethodCall);
|
||||
SystemChannels.platform_views.setMockMethodCallHandler(_onMethodCall);
|
||||
}
|
||||
|
||||
Iterable<FakeHtmlPlatformView> get views => _views.values;
|
||||
|
@ -226,11 +226,11 @@ void main() {
|
||||
const Intent(ValueKey<String>('foo')).debugFillProperties(builder);
|
||||
|
||||
final List<String> description = builder.properties
|
||||
.where((DiagnosticsNode node) {
|
||||
return !node.isFiltered(DiagnosticLevel.info);
|
||||
})
|
||||
.map((DiagnosticsNode node) => node.toString())
|
||||
.toList();
|
||||
.where((DiagnosticsNode node) {
|
||||
return !node.isFiltered(DiagnosticLevel.info);
|
||||
})
|
||||
.map((DiagnosticsNode node) => node.toString())
|
||||
.toList();
|
||||
|
||||
expect(description, equals(<String>['key: [<\'foo\'>]']));
|
||||
});
|
||||
@ -257,11 +257,11 @@ void main() {
|
||||
Actions(actions: const <LocalKey, ActionFactory>{}, child: Container()).debugFillProperties(builder);
|
||||
|
||||
final List<String> description = builder.properties
|
||||
.where((DiagnosticsNode node) {
|
||||
return !node.isFiltered(DiagnosticLevel.info);
|
||||
})
|
||||
.map((DiagnosticsNode node) => node.toString())
|
||||
.toList();
|
||||
.where((DiagnosticsNode node) {
|
||||
return !node.isFiltered(DiagnosticLevel.info);
|
||||
})
|
||||
.map((DiagnosticsNode node) => node.toString())
|
||||
.toList();
|
||||
|
||||
expect(description[0], equalsIgnoringHashCodes('dispatcher: ActionDispatcher#00000'));
|
||||
expect(description[1], equals('actions: {}'));
|
||||
@ -278,11 +278,11 @@ void main() {
|
||||
).debugFillProperties(builder);
|
||||
|
||||
final List<String> description = builder.properties
|
||||
.where((DiagnosticsNode node) {
|
||||
return !node.isFiltered(DiagnosticLevel.info);
|
||||
})
|
||||
.map((DiagnosticsNode node) => node.toString())
|
||||
.toList();
|
||||
.where((DiagnosticsNode node) {
|
||||
return !node.isFiltered(DiagnosticLevel.info);
|
||||
})
|
||||
.map((DiagnosticsNode node) => node.toString())
|
||||
.toList();
|
||||
|
||||
expect(description[0], equalsIgnoringHashCodes('dispatcher: ActionDispatcher#00000'));
|
||||
expect(description[1], equals('actions: {[<\'bar\'>]: Closure: () => TestAction}'));
|
||||
|
@ -982,8 +982,7 @@ void main() {
|
||||
feedback: Text('Dragging'),
|
||||
),
|
||||
DragTarget<int>(
|
||||
builder:
|
||||
(BuildContext context, List<int> data, List<dynamic> rejects) {
|
||||
builder: (BuildContext context, List<int> data, List<dynamic> rejects) {
|
||||
return Container(
|
||||
height: 100.0,
|
||||
child: rejects.isNotEmpty
|
||||
@ -1041,8 +1040,7 @@ void main() {
|
||||
},
|
||||
),
|
||||
DragTarget<int>(
|
||||
builder:
|
||||
(BuildContext context, List<int> data, List<dynamic> rejects) {
|
||||
builder: (BuildContext context, List<int> data, List<dynamic> rejects) {
|
||||
return Container(
|
||||
height: 100.0,
|
||||
child: rejects.isNotEmpty
|
||||
|
@ -1055,12 +1055,12 @@ Future<void> main() async {
|
||||
bool _isVisible(Element node) {
|
||||
bool isVisible = true;
|
||||
node.visitAncestorElements((Element ancestor) {
|
||||
final RenderObject r = ancestor.renderObject;
|
||||
if (r is RenderOpacity && r.opacity == 0) {
|
||||
isVisible = false;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
final RenderObject r = ancestor.renderObject;
|
||||
if (r is RenderOpacity && r.opacity == 0) {
|
||||
isVisible = false;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
return isVisible;
|
||||
}
|
||||
@ -2222,39 +2222,40 @@ Future<void> main() async {
|
||||
}
|
||||
);
|
||||
|
||||
// Load image before measuring the `Rect` of the `RenderImage`.
|
||||
imageProvider.complete();
|
||||
await tester.pump();
|
||||
final RenderImage renderImage = tester.renderObject(
|
||||
find.descendant(of: find.byKey(imageKey1), matching: find.byType(RawImage))
|
||||
);
|
||||
// Load image before measuring the `Rect` of the `RenderImage`.
|
||||
imageProvider.complete();
|
||||
await tester.pump();
|
||||
final RenderImage renderImage = tester.renderObject(
|
||||
find.descendant(of: find.byKey(imageKey1), matching: find.byType(RawImage))
|
||||
);
|
||||
|
||||
// Before push image1 should be laid out correctly.
|
||||
expect(renderImage.size, const Size(100, 100));
|
||||
// Before push image1 should be laid out correctly.
|
||||
expect(renderImage.size, const Size(100, 100));
|
||||
|
||||
navigatorKey.currentState.push(route2);
|
||||
await tester.pump();
|
||||
navigatorKey.currentState.push(route2);
|
||||
await tester.pump();
|
||||
|
||||
final TestGesture gesture = await tester.startGesture(const Offset(0.01, 300));
|
||||
await tester.pump();
|
||||
final TestGesture gesture = await tester.startGesture(const Offset(0.01, 300));
|
||||
await tester.pump();
|
||||
|
||||
// Move (almost) across the screen, to make the animation as close to finish
|
||||
// as possible.
|
||||
await gesture.moveTo(const Offset(800, 200));
|
||||
await tester.pump();
|
||||
// Move (almost) across the screen, to make the animation as close to finish
|
||||
// as possible.
|
||||
await gesture.moveTo(const Offset(800, 200));
|
||||
await tester.pump();
|
||||
|
||||
// image1 should snap to the top left corner of the Row widget.
|
||||
expect(
|
||||
tester.getRect(find.byKey(imageKey1, skipOffstage: false)),
|
||||
rectMoreOrLessEquals(tester.getTopLeft(find.widgetWithText(Row, '1')) & const Size(100, 100), epsilon: 0.01),
|
||||
);
|
||||
// image1 should snap to the top left corner of the Row widget.
|
||||
expect(
|
||||
tester.getRect(find.byKey(imageKey1, skipOffstage: false)),
|
||||
rectMoreOrLessEquals(tester.getTopLeft(find.widgetWithText(Row, '1')) & const Size(100, 100), epsilon: 0.01),
|
||||
);
|
||||
|
||||
// Text should respect the correct final size of image1.
|
||||
expect(
|
||||
tester.getTopRight(find.byKey(imageKey1, skipOffstage: false)).dx,
|
||||
moreOrLessEquals(tester.getTopLeft(find.text('1')).dx, epsilon: 0.01),
|
||||
);
|
||||
});
|
||||
// Text should respect the correct final size of image1.
|
||||
expect(
|
||||
tester.getTopRight(find.byKey(imageKey1, skipOffstage: false)).dx,
|
||||
moreOrLessEquals(tester.getTopLeft(find.text('1')).dx, epsilon: 0.01),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/issues/40239.
|
||||
testWidgets(
|
||||
|
@ -190,8 +190,8 @@ void main() {
|
||||
|
||||
// Make child wider and higher than the viewport.
|
||||
setState(() {
|
||||
childWidth = 900.0;
|
||||
childHeight = 900.0;
|
||||
childWidth = 900.0;
|
||||
childHeight = 900.0;
|
||||
});
|
||||
|
||||
await tester.pump();
|
||||
@ -294,9 +294,7 @@ void main() {
|
||||
expect(built, 2);
|
||||
});
|
||||
|
||||
testWidgets('SliverLayoutBuilder and Inherited -- do not rebuild when not using inherited',
|
||||
(WidgetTester tester) async {
|
||||
|
||||
testWidgets('SliverLayoutBuilder and Inherited -- do not rebuild when not using inherited', (WidgetTester tester) async {
|
||||
int built = 0;
|
||||
final Widget target = Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
|
@ -58,7 +58,7 @@ void main() {
|
||||
events.add(event);
|
||||
},
|
||||
onPointerUp: (PointerUpEvent event) {
|
||||
events.add(event);
|
||||
events.add(event);
|
||||
},
|
||||
onPointerMove: (PointerMoveEvent event) {
|
||||
events.add(event);
|
||||
|
@ -413,7 +413,7 @@ void main() {
|
||||
// │ │
|
||||
// ────────────────────────────
|
||||
testWidgets('non-rect partially overlapping, wrong painting order, check disabled', (WidgetTester tester) async {
|
||||
final List<Widget> children = <Widget>[
|
||||
final List<Widget> children = <Widget>[
|
||||
Positioned.fromRect(
|
||||
rect: const Rect.fromLTWH(150, 150, 150, 150),
|
||||
child: Container(
|
||||
|
@ -622,8 +622,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'Android view can claim gesture after all pointers are up', (WidgetTester tester) async {
|
||||
testWidgets('Android view can claim gesture after all pointers are up', (WidgetTester tester) async {
|
||||
final int currentViewId = platformViewsRegistry.getNextPlatformViewId();
|
||||
final FakeAndroidPlatformViewsController viewsController = FakeAndroidPlatformViewsController();
|
||||
viewsController.registerViewType('webview');
|
||||
@ -1762,8 +1761,7 @@ void main() {
|
||||
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'PlatformViewSurface can claim gesture after all pointers are up', (WidgetTester tester) async {
|
||||
testWidgets('PlatformViewSurface can claim gesture after all pointers are up', (WidgetTester tester) async {
|
||||
bool verticalDragAcceptedByParent = false;
|
||||
// The long press recognizer rejects the gesture after the PlatformViewSurface gets the pointer up event.
|
||||
// This test makes sure that the PlatformViewSurface can win the gesture after it got the pointer up event.
|
||||
|
@ -35,8 +35,7 @@ class OnTapPage extends StatelessWidget {
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('Push and Pop should send platform messages',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('Push and Pop should send platform messages', (WidgetTester tester) async {
|
||||
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
|
||||
'/': (BuildContext context) => OnTapPage(
|
||||
id: '/',
|
||||
@ -52,8 +51,7 @@ void main() {
|
||||
|
||||
final List<MethodCall> log = <MethodCall>[];
|
||||
|
||||
SystemChannels.navigation
|
||||
.setMockMethodCallHandler((MethodCall methodCall) async {
|
||||
SystemChannels.navigation.setMockMethodCallHandler((MethodCall methodCall) async {
|
||||
log.add(methodCall);
|
||||
});
|
||||
|
||||
@ -103,8 +101,7 @@ void main() {
|
||||
));
|
||||
});
|
||||
|
||||
testWidgets('Replace should send platform messages',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('Replace should send platform messages', (WidgetTester tester) async {
|
||||
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
|
||||
'/': (BuildContext context) => OnTapPage(
|
||||
id: '/',
|
||||
@ -121,8 +118,7 @@ void main() {
|
||||
|
||||
final List<MethodCall> log = <MethodCall>[];
|
||||
|
||||
SystemChannels.navigation
|
||||
.setMockMethodCallHandler((MethodCall methodCall) async {
|
||||
SystemChannels.navigation.setMockMethodCallHandler((MethodCall methodCall) async {
|
||||
log.add(methodCall);
|
||||
});
|
||||
|
||||
|
@ -350,7 +350,10 @@ void main() {
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: NotificationListener<OverscrollNotification>(
|
||||
onNotification: (OverscrollNotification message) { scrolled = true; return false; },
|
||||
onNotification: (OverscrollNotification message) {
|
||||
scrolled = true;
|
||||
return false;
|
||||
},
|
||||
child: ListView(
|
||||
primary: true,
|
||||
children: const <Widget>[],
|
||||
@ -368,7 +371,10 @@ void main() {
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: NotificationListener<OverscrollNotification>(
|
||||
onNotification: (OverscrollNotification message) { scrolled = true; return false; },
|
||||
onNotification: (OverscrollNotification message) {
|
||||
scrolled = true;
|
||||
return false;
|
||||
},
|
||||
child: ListView(
|
||||
primary: false,
|
||||
children: const <Widget>[],
|
||||
@ -386,7 +392,10 @@ void main() {
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: NotificationListener<OverscrollNotification>(
|
||||
onNotification: (OverscrollNotification message) { scrolled = true; return false; },
|
||||
onNotification: (OverscrollNotification message) {
|
||||
scrolled = true;
|
||||
return false;
|
||||
},
|
||||
child: ListView(
|
||||
primary: false,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
@ -405,7 +414,10 @@ void main() {
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: NotificationListener<OverscrollNotification>(
|
||||
onNotification: (OverscrollNotification message) { scrolled = true; return false; },
|
||||
onNotification: (OverscrollNotification message) {
|
||||
scrolled = true;
|
||||
return false;
|
||||
},
|
||||
child: ListView(
|
||||
primary: true,
|
||||
physics: const ScrollPhysics(),
|
||||
|
@ -1379,8 +1379,7 @@ void main() {
|
||||
final FocusNode focusNode = FocusNode();
|
||||
|
||||
String clipboardContent = '';
|
||||
SystemChannels.platform
|
||||
.setMockMethodCallHandler((MethodCall methodCall) async {
|
||||
SystemChannels.platform.setMockMethodCallHandler((MethodCall methodCall) async {
|
||||
if (methodCall.method == 'Clipboard.setData')
|
||||
clipboardContent = methodCall.arguments['text'];
|
||||
else if (methodCall.method == 'Clipboard.getData')
|
||||
@ -2308,7 +2307,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'tap moves cursor to the edge of the word it tapped on (iOS)',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.iOS),
|
||||
@ -2340,7 +2339,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'tap moves cursor to the position tapped (Android)',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: Material(
|
||||
@ -2372,7 +2371,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'two slow taps do not trigger a word selection (iOS)',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.iOS),
|
||||
@ -2407,7 +2406,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'double tap selects word and first tap of double tap moves cursor (iOS)',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.iOS),
|
||||
@ -2453,7 +2452,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'double tap selects word and first tap of double tap moves cursor and shows toolbar (Android)',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: Material(
|
||||
@ -2498,7 +2497,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'double tap on top of cursor also selects word (Android)',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: Material(
|
||||
@ -2547,7 +2546,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'double tap hold selects word (iOS)',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.iOS),
|
||||
@ -2594,7 +2593,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'tap after a double tap select is not affected (iOS)',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.iOS),
|
||||
@ -2641,7 +2640,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'long press moves cursor to the exact long press position and shows toolbar (iOS)',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.iOS),
|
||||
@ -2674,7 +2673,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'long press selects word and shows toolbar (Android)',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
@ -2706,7 +2705,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'long press tap cannot initiate a double tap (iOS)',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.iOS),
|
||||
@ -2742,7 +2741,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'long press drag moves the cursor under the drag and shows toolbar on lift (iOS)',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.iOS),
|
||||
@ -2898,7 +2897,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'long tap after a double tap select is not affected (iOS)',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.iOS),
|
||||
@ -2942,7 +2941,7 @@ void main() {
|
||||
//convert
|
||||
testWidgets(
|
||||
'double tap after a long tap is not affected (iOS)',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.iOS),
|
||||
@ -2984,7 +2983,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'double tap chains work (iOS)',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.iOS),
|
||||
@ -3238,7 +3237,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'strut basic single line',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.android),
|
||||
@ -3261,7 +3260,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'strut TextStyle increases height',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.android),
|
||||
@ -3308,7 +3307,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'strut basic multi line',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.android),
|
||||
@ -3332,7 +3331,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'strut no force small strut',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.android),
|
||||
@ -3364,7 +3363,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'strut no force large strut',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.android),
|
||||
@ -3393,7 +3392,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'strut height override',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.android),
|
||||
@ -3422,7 +3421,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'strut forces field taller',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.android),
|
||||
@ -3636,7 +3635,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'Mouse tap does not show handles nor toolbar',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: Material(
|
||||
@ -3665,7 +3664,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'Mouse long press does not show handles nor toolbar',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: Material(
|
||||
@ -3694,7 +3693,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'Mouse double tap does not show handles nor toolbar',
|
||||
(WidgetTester tester) async {
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: Material(
|
||||
|
@ -193,9 +193,9 @@ void main() {
|
||||
Actions(
|
||||
actions: <LocalKey, ActionFactory>{
|
||||
TestAction.key: () => TestAction(onInvoke: (FocusNode node, Intent intent) {
|
||||
invoked = true;
|
||||
return true;
|
||||
}),
|
||||
invoked = true;
|
||||
return true;
|
||||
}),
|
||||
},
|
||||
child: Shortcuts(
|
||||
manager: testManager,
|
||||
|
@ -34,7 +34,7 @@ Future<void> testSliverFixedExtentList(WidgetTester tester, List<String> items)
|
||||
SliverFixedExtentList(
|
||||
itemExtent: 900,
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, int index) {
|
||||
(BuildContext context, int index) {
|
||||
return Center(
|
||||
key: ValueKey<String>(items[index]),
|
||||
child: KeepAlive(
|
||||
@ -268,7 +268,9 @@ void main() {
|
||||
expect(find.text('4'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('SliverGrid Correctly layout children after rearranging', (WidgetTester tester) async {
|
||||
testWidgets(
|
||||
'SliverGrid Correctly layout children after rearranging',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(const TestSliverGrid(
|
||||
<Widget>[
|
||||
Text('item0', key: Key('0')),
|
||||
@ -299,7 +301,9 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('SliverFixedExtentList Correctly layout children after rearranging', (WidgetTester tester) async {
|
||||
testWidgets(
|
||||
'SliverFixedExtentList Correctly layout children after rearranging',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(const TestSliverFixedExtentList(
|
||||
<Widget>[
|
||||
Text('item0', key: Key('0')),
|
||||
@ -363,7 +367,7 @@ void main() {
|
||||
SliverFixedExtentList(
|
||||
itemExtent: 200,
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, int index) {
|
||||
(BuildContext context, int index) {
|
||||
if (index <= 6) {
|
||||
return Center(child: Text('Page $index'));
|
||||
}
|
||||
@ -395,7 +399,7 @@ void main() {
|
||||
SliverFixedExtentList(
|
||||
itemExtent: 200,
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, int index) {
|
||||
(BuildContext context, int index) {
|
||||
if (index <= 6) {
|
||||
return Center(child: Text('Page $index'));
|
||||
}
|
||||
|
@ -551,8 +551,7 @@ void main() {
|
||||
});
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/issues/37032.
|
||||
testWidgets("selection handle's GestureDetector should not cover the entire screen",
|
||||
(WidgetTester tester) async {
|
||||
testWidgets("selection handle's GestureDetector should not cover the entire screen", (WidgetTester tester) async {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
|
||||
final TextEditingController controller = TextEditingController(text: 'a');
|
||||
|
||||
|
@ -86,7 +86,7 @@ class _AndroidBuilderImpl extends AndroidBuilder {
|
||||
@required AndroidBuildInfo androidBuildInfo,
|
||||
@required String target,
|
||||
}) async {
|
||||
if (!project.android.isUsingGradle) {
|
||||
if (!project.android.isUsingGradle) {
|
||||
throwToolExit(
|
||||
'The build process for Android has changed, and the current project configuration '
|
||||
'is no longer valid. Please consult\n\n'
|
||||
|
@ -275,7 +275,7 @@ class FlutterWebTestBootstrapBuilder implements Builder {
|
||||
assetPath, contents, Runtime.builtIn.map((Runtime runtime) => runtime.name).toSet());
|
||||
|
||||
if (metadata.testOn.evaluate(SuitePlatform(Runtime.chrome))) {
|
||||
await buildStep.writeAsString(id.addExtension('.browser_test.dart'), '''
|
||||
await buildStep.writeAsString(id.addExtension('.browser_test.dart'), '''
|
||||
import 'dart:ui' as ui;
|
||||
import 'dart:html';
|
||||
import 'dart:js';
|
||||
|
@ -284,7 +284,8 @@ String _filterOverrideWarnings(String message) {
|
||||
// ! front_end 0.1.0-alpha.0 from path ../../bin/cache/dart-sdk/lib/front_end
|
||||
if (message == 'Warning: You are using these overridden dependencies:') {
|
||||
return null;
|
||||
} if (message.contains(_analyzerWarning)) {
|
||||
}
|
||||
if (message.contains(_analyzerWarning)) {
|
||||
return null;
|
||||
}
|
||||
return message;
|
||||
|
@ -505,7 +505,7 @@ class ValidationResult {
|
||||
return terminal.color(leadingBox, TerminalColor.green);
|
||||
case ValidationType.notAvailable:
|
||||
case ValidationType.partial:
|
||||
return terminal.color(leadingBox, TerminalColor.yellow);
|
||||
return terminal.color(leadingBox, TerminalColor.yellow);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -61,8 +61,7 @@ class FuchsiaSdk {
|
||||
Stream<String> syslogs(String id) {
|
||||
Process process;
|
||||
try {
|
||||
final StreamController<String> controller =
|
||||
StreamController<String>(onCancel: () {
|
||||
final StreamController<String> controller = StreamController<String>(onCancel: () {
|
||||
process.kill();
|
||||
});
|
||||
if (fuchsiaArtifacts.sshConfig == null ||
|
||||
|
@ -38,7 +38,7 @@ Future<void> buildMacOS({
|
||||
await processPodsIfNeeded(flutterProject.macos, getMacOSBuildDirectory(), buildInfo.mode);
|
||||
// If the xcfilelists do not exist, create empty version.
|
||||
if (!flutterProject.macos.inputFileList.existsSync()) {
|
||||
flutterProject.macos.inputFileList.createSync(recursive: true);
|
||||
flutterProject.macos.inputFileList.createSync(recursive: true);
|
||||
}
|
||||
if (!flutterProject.macos.outputFileList.existsSync()) {
|
||||
flutterProject.macos.outputFileList.createSync(recursive: true);
|
||||
|
@ -85,7 +85,7 @@ class MDnsObservatoryDiscovery {
|
||||
buffer.writeln('There are multiple observatory ports available.');
|
||||
buffer.writeln('Rerun this command with one of the following passed in as the appId:');
|
||||
buffer.writeln('');
|
||||
for (final String uniqueDomainName in uniqueDomainNames) {
|
||||
for (final String uniqueDomainName in uniqueDomainNames) {
|
||||
buffer.writeln(' flutter attach --app-id ${uniqueDomainName.replaceAll('.$dartObservatoryName', '')}');
|
||||
}
|
||||
throwToolExit(buffer.toString());
|
||||
|
@ -534,17 +534,17 @@ Future<void> injectPlugins(FlutterProject project, {bool checkProjects = false})
|
||||
await _writeMacOSPluginRegistrant(project, plugins);
|
||||
}
|
||||
for (final XcodeBasedProject subproject in <XcodeBasedProject>[project.ios, project.macos]) {
|
||||
if (!project.isModule && (!checkProjects || subproject.existsSync())) {
|
||||
final CocoaPods cocoaPods = CocoaPods();
|
||||
if (plugins.isNotEmpty) {
|
||||
await cocoaPods.setupPodfile(subproject);
|
||||
if (!project.isModule && (!checkProjects || subproject.existsSync())) {
|
||||
final CocoaPods cocoaPods = CocoaPods();
|
||||
if (plugins.isNotEmpty) {
|
||||
await cocoaPods.setupPodfile(subproject);
|
||||
}
|
||||
/// The user may have a custom maintained Podfile that they're running `pod install`
|
||||
/// on themselves.
|
||||
else if (subproject.podfile.existsSync() && subproject.podfileLock.existsSync()) {
|
||||
cocoaPods.addPodsDependencyToFlutterXcconfig(subproject);
|
||||
}
|
||||
}
|
||||
/// The user may have a custom maintained Podfile that they're running `pod install`
|
||||
/// on themselves.
|
||||
else if (subproject.podfile.existsSync() && subproject.podfileLock.existsSync()) {
|
||||
cocoaPods.addPodsDependencyToFlutterXcconfig(subproject);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (featureFlags.isWebEnabled && project.web.existsSync()) {
|
||||
await _writeWebPluginRegistrant(project, plugins);
|
||||
|
@ -102,7 +102,7 @@ FlutterPlatform installHook({
|
||||
platformPluginRegistration ??= (FlutterPlatform platform) {
|
||||
hack.registerPlatformPlugin(
|
||||
<Runtime>[Runtime.vm],
|
||||
() {
|
||||
() {
|
||||
return platform;
|
||||
},
|
||||
);
|
||||
@ -417,7 +417,8 @@ class FlutterPlatform extends PlatformPlugin {
|
||||
await server.close(force: true);
|
||||
});
|
||||
final Completer<WebSocket> webSocket = Completer<WebSocket>();
|
||||
server.listen((HttpRequest request) {
|
||||
server.listen(
|
||||
(HttpRequest request) {
|
||||
if (!webSocket.isCompleted) {
|
||||
webSocket.complete(WebSocketTransformer.upgrade(request));
|
||||
}
|
||||
|
@ -282,17 +282,18 @@ class FlutterWebPlatform extends PlatformPlugin {
|
||||
|
||||
@override
|
||||
Future<void> close() => _closeMemo.runOnce(() async {
|
||||
final List<Future<dynamic>> futures = _browserManagers.values
|
||||
.map<Future<dynamic>>((Future<BrowserManager> future) async {
|
||||
final BrowserManager result = await future;
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
await result.close();
|
||||
}).toList();
|
||||
futures.add(_server.close());
|
||||
await Future.wait<void>(futures);
|
||||
});
|
||||
final List<Future<dynamic>> futures = _browserManagers.values
|
||||
.map<Future<dynamic>>((Future<BrowserManager> future) async {
|
||||
final BrowserManager result = await future;
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
await result.close();
|
||||
})
|
||||
.toList();
|
||||
futures.add(_server.close());
|
||||
await Future.wait<void>(futures);
|
||||
});
|
||||
}
|
||||
|
||||
class OneOffHandler {
|
||||
@ -414,18 +415,19 @@ class BrowserManager {
|
||||
// Whenever we get a message, no matter which child channel it's for, we the
|
||||
// know browser is still running code which means the user isn't debugging.
|
||||
_channel = MultiChannel<dynamic>(
|
||||
webSocket.cast<String>().transform(jsonDocument).changeStream((Stream<Object> stream) {
|
||||
return stream.map((Object message) {
|
||||
if (!_closed) {
|
||||
_timer.reset();
|
||||
}
|
||||
for (RunnerSuiteController controller in _controllers) {
|
||||
controller.setDebugging(false);
|
||||
}
|
||||
webSocket.cast<String>().transform(jsonDocument).changeStream((Stream<Object> stream) {
|
||||
return stream.map((Object message) {
|
||||
if (!_closed) {
|
||||
_timer.reset();
|
||||
}
|
||||
for (RunnerSuiteController controller in _controllers) {
|
||||
controller.setDebugging(false);
|
||||
}
|
||||
|
||||
return message;
|
||||
});
|
||||
}));
|
||||
return message;
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
_environment = _loadBrowserEnvironment();
|
||||
_channel.stream.listen(_onMessage, onDone: close);
|
||||
@ -579,10 +581,11 @@ class BrowserManager {
|
||||
final VirtualChannel<dynamic> virtualChannel = _channel.virtualChannel();
|
||||
final int suiteChannelID = virtualChannel.id;
|
||||
final StreamChannel<dynamic> suiteChannel = virtualChannel.transformStream(
|
||||
StreamTransformer<dynamic, dynamic>.fromHandlers(handleDone: (EventSink<dynamic> sink) {
|
||||
closeIframe();
|
||||
sink.close();
|
||||
}));
|
||||
StreamTransformer<dynamic, dynamic>.fromHandlers(handleDone: (EventSink<dynamic> sink) {
|
||||
closeIframe();
|
||||
sink.close();
|
||||
}),
|
||||
);
|
||||
|
||||
return await _pool.withResource<RunnerSuite>(() async {
|
||||
_channel.sink.add(<String, Object>{
|
||||
|
@ -66,7 +66,7 @@ class FlutterVersion {
|
||||
final String remote = channel.substring(0, slash);
|
||||
_repositoryUrl = _runGit('git ls-remote --get-url $remote');
|
||||
_channel = channel.substring(slash + 1);
|
||||
} else if (channel.isEmpty) {
|
||||
} else if (channel.isEmpty) {
|
||||
_channel = 'unknown';
|
||||
} else {
|
||||
_channel = channel;
|
||||
|
@ -467,13 +467,13 @@ abstract class ServiceObject {
|
||||
switch (type) {
|
||||
case 'Event':
|
||||
serviceObject = ServiceEvent._empty(owner);
|
||||
break;
|
||||
break;
|
||||
case 'FlutterView':
|
||||
serviceObject = FlutterView._empty(owner.vm);
|
||||
break;
|
||||
break;
|
||||
case 'Isolate':
|
||||
serviceObject = Isolate._empty(owner.vm);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
// If we don't have a model object for this service object type, as a
|
||||
// fallback return a ServiceMap object.
|
||||
@ -811,7 +811,7 @@ class VM extends ServiceObjectOwner {
|
||||
final String mapId = map['id'];
|
||||
|
||||
switch (type) {
|
||||
case 'Isolate': {
|
||||
case 'Isolate':
|
||||
// Check cache.
|
||||
Isolate isolate = _isolateCache[mapId];
|
||||
if (isolate == null) {
|
||||
@ -829,9 +829,7 @@ class VM extends ServiceObjectOwner {
|
||||
isolate.updateFromMap(map);
|
||||
}
|
||||
return isolate;
|
||||
}
|
||||
break;
|
||||
case 'FlutterView': {
|
||||
case 'FlutterView':
|
||||
FlutterView view = _viewCache[mapId];
|
||||
if (view == null) {
|
||||
// Add new view to the cache.
|
||||
@ -841,8 +839,6 @@ class VM extends ServiceObjectOwner {
|
||||
view.updateFromMap(map);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw VMServiceObjectLoadError(
|
||||
'VM.getFromMap called for something other than an isolate', map);
|
||||
|
@ -138,9 +138,11 @@ Use the 'android' tool to install them:
|
||||
hardware = 'goldfish';
|
||||
buildCharacteristics = 'unused';
|
||||
exitCode = -1;
|
||||
when(mockProcessManager.run(argThat(contains('getprop')),
|
||||
stderrEncoding: anyNamed('stderrEncoding'),
|
||||
stdoutEncoding: anyNamed('stdoutEncoding'))).thenAnswer((_) {
|
||||
when(mockProcessManager.run(
|
||||
argThat(contains('getprop')),
|
||||
stderrEncoding: anyNamed('stderrEncoding'),
|
||||
stdoutEncoding: anyNamed('stdoutEncoding'),
|
||||
)).thenAnswer((_) {
|
||||
final StringBuffer buf = StringBuffer()
|
||||
..writeln('[ro.hardware]: [$hardware]')..writeln(
|
||||
'[ro.build.characteristics]: [$buildCharacteristics]');
|
||||
@ -215,9 +217,11 @@ Use the 'android' tool to install them:
|
||||
setUp(() {
|
||||
hardware = 'unknown';
|
||||
buildCharacteristics = 'unused';
|
||||
when(mockProcessManager.run(argThat(contains('getprop')),
|
||||
stderrEncoding: anyNamed('stderrEncoding'),
|
||||
stdoutEncoding: anyNamed('stdoutEncoding'))).thenAnswer((_) {
|
||||
when(mockProcessManager.run(
|
||||
argThat(contains('getprop')),
|
||||
stderrEncoding: anyNamed('stderrEncoding'),
|
||||
stdoutEncoding: anyNamed('stdoutEncoding'),
|
||||
)).thenAnswer((_) {
|
||||
final StringBuffer buf = StringBuffer()
|
||||
..writeln('[ro.hardware]: [$hardware]')
|
||||
..writeln('[ro.build.characteristics]: [$buildCharacteristics]');
|
||||
@ -312,9 +316,11 @@ flutter:
|
||||
setUp(() {
|
||||
hardware = 'goldfish'; // Known emulator
|
||||
socketWasCreated = false;
|
||||
when(mockProcessManager.run(argThat(contains('getprop')),
|
||||
stderrEncoding: anyNamed('stderrEncoding'),
|
||||
stdoutEncoding: anyNamed('stdoutEncoding'))).thenAnswer((_) {
|
||||
when(mockProcessManager.run(
|
||||
argThat(contains('getprop')),
|
||||
stderrEncoding: anyNamed('stderrEncoding'),
|
||||
stdoutEncoding: anyNamed('stdoutEncoding'),
|
||||
)).thenAnswer((_) {
|
||||
final StringBuffer buf = StringBuffer()
|
||||
..writeln('[ro.hardware]: [$hardware]');
|
||||
final ProcessResult result = ProcessResult(1, 0, buf.toString(), '');
|
||||
|
@ -483,8 +483,7 @@ $assetsSection
|
||||
});
|
||||
|
||||
group('AssetBundle assets from scanned paths', () {
|
||||
testUsingContext(
|
||||
'Two assets are bundled when scanning their directory', () async {
|
||||
testUsingContext('Two assets are bundled when scanning their directory', () async {
|
||||
establishFlutterRoot();
|
||||
writeEmptySchemaFile(fs);
|
||||
|
||||
@ -514,8 +513,7 @@ $assetsSection
|
||||
FileSystem: () => testFileSystem,
|
||||
});
|
||||
|
||||
testUsingContext(
|
||||
'Two assets are bundled when listing one and scanning second directory', () async {
|
||||
testUsingContext('Two assets are bundled when listing one and scanning second directory', () async {
|
||||
establishFlutterRoot();
|
||||
writeEmptySchemaFile(fs);
|
||||
|
||||
@ -545,8 +543,7 @@ $assetsSection
|
||||
FileSystem: () => testFileSystem,
|
||||
});
|
||||
|
||||
testUsingContext(
|
||||
'One asset is bundled with variant, scanning wrong directory', () async {
|
||||
testUsingContext('One asset is bundled with variant, scanning wrong directory', () async {
|
||||
establishFlutterRoot();
|
||||
writeEmptySchemaFile(fs);
|
||||
|
||||
@ -573,8 +570,7 @@ $assetsSection
|
||||
});
|
||||
|
||||
group('AssetBundle assets from scanned paths with MemoryFileSystem', () {
|
||||
testUsingContext(
|
||||
'One asset is bundled with variant, scanning directory', () async {
|
||||
testUsingContext('One asset is bundled with variant, scanning directory', () async {
|
||||
establishFlutterRoot();
|
||||
writeEmptySchemaFile(fs);
|
||||
|
||||
@ -603,8 +599,7 @@ $assetsSection
|
||||
FileSystem: () => testFileSystem,
|
||||
});
|
||||
|
||||
testUsingContext(
|
||||
'No asset is bundled with variant, no assets or directories are listed', () async {
|
||||
testUsingContext('No asset is bundled with variant, no assets or directories are listed', () async {
|
||||
establishFlutterRoot();
|
||||
writeEmptySchemaFile(fs);
|
||||
|
||||
@ -632,8 +627,7 @@ $assetsSection
|
||||
FileSystem: () => testFileSystem,
|
||||
});
|
||||
|
||||
testUsingContext(
|
||||
'Expect error generating manifest, wrong non-existing directory is listed', () async {
|
||||
testUsingContext('Expect error generating manifest, wrong non-existing directory is listed', () async {
|
||||
establishFlutterRoot();
|
||||
writeEmptySchemaFile(fs);
|
||||
|
||||
|
@ -29,10 +29,10 @@ Future<void> syncAndAsyncError() {
|
||||
|
||||
Future<void> delayedThrow(FakeAsync time) {
|
||||
final Future<void> result =
|
||||
Future<void>.delayed(const Duration(milliseconds: 10))
|
||||
Future<void>.delayed(const Duration(milliseconds: 10))
|
||||
.then((_) {
|
||||
throw 'Delayed Doom';
|
||||
});
|
||||
throw 'Delayed Doom';
|
||||
});
|
||||
time.elapse(const Duration(seconds: 1));
|
||||
time.flushMicrotasks();
|
||||
return result;
|
||||
@ -154,9 +154,9 @@ void main() {
|
||||
await FakeAsync().run((FakeAsync time) {
|
||||
unawaited(runZoned(() async {
|
||||
final Future<void> f = asyncGuard<void>(() => delayedThrow(time))
|
||||
.catchError((Object e, StackTrace s) {
|
||||
caughtByCatchError = true;
|
||||
});
|
||||
.catchError((Object e, StackTrace s) {
|
||||
caughtByCatchError = true;
|
||||
});
|
||||
try {
|
||||
await f;
|
||||
} on String {
|
||||
@ -189,10 +189,12 @@ void main() {
|
||||
final Completer<void> completer = Completer<void>();
|
||||
await FakeAsync().run((FakeAsync time) {
|
||||
unawaited(runZoned(() async {
|
||||
final Future<void> f = asyncGuard<void>(() => delayedThrow(time),
|
||||
onError: (Object e, StackTrace s) {
|
||||
caughtByOnError = true;
|
||||
});
|
||||
final Future<void> f = asyncGuard<void>(
|
||||
() => delayedThrow(time),
|
||||
onError: (Object e, StackTrace s) {
|
||||
caughtByOnError = true;
|
||||
},
|
||||
);
|
||||
try {
|
||||
await f;
|
||||
} catch (e) {
|
||||
|
@ -151,7 +151,7 @@ void main() {
|
||||
});
|
||||
|
||||
testUsingContext('default character choice without displayAcceptedCharacters', () async {
|
||||
terminalUnderTest.usesTerminalUi = true;
|
||||
terminalUnderTest.usesTerminalUi = true;
|
||||
mockStdInStream = Stream<String>.fromFutures(<Future<String>>[
|
||||
Future<String>.value('\n'), // Not in accepted list
|
||||
]).asBroadcastStream();
|
||||
|
@ -60,13 +60,13 @@ void main() {
|
||||
} else if (platform.isLinux) {
|
||||
hostPlatform = HostPlatform.linux_x64;
|
||||
} else if (platform.isMacOS) {
|
||||
hostPlatform = HostPlatform.darwin_x64;
|
||||
hostPlatform = HostPlatform.darwin_x64;
|
||||
} else {
|
||||
assert(false);
|
||||
}
|
||||
final String skyEngineLine = platform.isWindows
|
||||
? r'sky_engine:file:///C:/bin/cache/pkg/sky_engine/lib/'
|
||||
: 'sky_engine:file:///bin/cache/pkg/sky_engine/lib/';
|
||||
final String skyEngineLine = platform.isWindows
|
||||
? r'sky_engine:file:///C:/bin/cache/pkg/sky_engine/lib/'
|
||||
: 'sky_engine:file:///bin/cache/pkg/sky_engine/lib/';
|
||||
fs.file('.packages')
|
||||
..createSync()
|
||||
..writeAsStringSync('''
|
||||
@ -368,9 +368,10 @@ class FakeKernelCompiler implements KernelCompiler {
|
||||
String fileSystemScheme,
|
||||
bool targetProductVm = false,
|
||||
String platformDill,
|
||||
String initializeFromDill}) async {
|
||||
fs.file(outputFilePath).createSync(recursive: true);
|
||||
return CompilerOutput(outputFilePath, 0, null);
|
||||
String initializeFromDill,
|
||||
}) async {
|
||||
fs.file(outputFilePath).createSync(recursive: true);
|
||||
return CompilerOutput(outputFilePath, 0, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,9 +32,9 @@ void main() {
|
||||
|
||||
test('Can run a build', () => testbed.run(() async {
|
||||
when(mockBuildSystem.build(any, any, buildSystemConfig: anyNamed('buildSystemConfig')))
|
||||
.thenAnswer((Invocation invocation) async {
|
||||
return BuildResult(success: true);
|
||||
});
|
||||
.thenAnswer((Invocation invocation) async {
|
||||
return BuildResult(success: true);
|
||||
});
|
||||
final CommandRunner<void> commandRunner = createTestCommandRunner(AssembleCommand());
|
||||
await commandRunner.run(<String>['assemble', '-o Output', 'debug_macos_bundle_flutter_assets']);
|
||||
final BufferLogger bufferLogger = logger;
|
||||
@ -44,9 +44,9 @@ void main() {
|
||||
|
||||
test('Throws ToolExit if not provided with output', () => testbed.run(() async {
|
||||
when(mockBuildSystem.build(any, any, buildSystemConfig: anyNamed('buildSystemConfig')))
|
||||
.thenAnswer((Invocation invocation) async {
|
||||
return BuildResult(success: true);
|
||||
});
|
||||
.thenAnswer((Invocation invocation) async {
|
||||
return BuildResult(success: true);
|
||||
});
|
||||
final CommandRunner<void> commandRunner = createTestCommandRunner(AssembleCommand());
|
||||
|
||||
expect(commandRunner.run(<String>['assemble', 'debug_macos_bundle_flutter_assets']), throwsA(isInstanceOf<ToolExit>()));
|
||||
@ -54,9 +54,9 @@ void main() {
|
||||
|
||||
test('Throws ToolExit if called with non-existent rule', () => testbed.run(() async {
|
||||
when(mockBuildSystem.build(any, any, buildSystemConfig: anyNamed('buildSystemConfig')))
|
||||
.thenAnswer((Invocation invocation) async {
|
||||
return BuildResult(success: true);
|
||||
});
|
||||
.thenAnswer((Invocation invocation) async {
|
||||
return BuildResult(success: true);
|
||||
});
|
||||
final CommandRunner<void> commandRunner = createTestCommandRunner(AssembleCommand());
|
||||
|
||||
expect(commandRunner.run(<String>['assemble', '-o Output', 'undefined']), throwsA(isInstanceOf<ToolExit>()));
|
||||
@ -64,13 +64,13 @@ void main() {
|
||||
|
||||
test('Only writes input and output files when the values change', () => testbed.run(() async {
|
||||
when(mockBuildSystem.build(any, any, buildSystemConfig: anyNamed('buildSystemConfig')))
|
||||
.thenAnswer((Invocation invocation) async {
|
||||
return BuildResult(
|
||||
success: true,
|
||||
inputFiles: <File>[fs.file('foo')..createSync()],
|
||||
outputFiles: <File>[fs.file('bar')..createSync()],
|
||||
);
|
||||
});
|
||||
.thenAnswer((Invocation invocation) async {
|
||||
return BuildResult(
|
||||
success: true,
|
||||
inputFiles: <File>[fs.file('foo')..createSync()],
|
||||
outputFiles: <File>[fs.file('bar')..createSync()],
|
||||
);
|
||||
});
|
||||
|
||||
final CommandRunner<void> commandRunner = createTestCommandRunner(AssembleCommand());
|
||||
await commandRunner.run(<String>['assemble', '-o Output', '--build-outputs=outputs', '--build-inputs=inputs', 'debug_macos_bundle_flutter_assets']);
|
||||
@ -90,12 +90,12 @@ void main() {
|
||||
|
||||
|
||||
when(mockBuildSystem.build(any, any, buildSystemConfig: anyNamed('buildSystemConfig')))
|
||||
.thenAnswer((Invocation invocation) async {
|
||||
return BuildResult(
|
||||
success: true,
|
||||
inputFiles: <File>[fs.file('foo'), fs.file('fizz')..createSync()],
|
||||
outputFiles: <File>[fs.file('bar'), fs.file(fs.path.join('.dart_tool', 'fizz2'))..createSync(recursive: true)]);
|
||||
});
|
||||
.thenAnswer((Invocation invocation) async {
|
||||
return BuildResult(
|
||||
success: true,
|
||||
inputFiles: <File>[fs.file('foo'), fs.file('fizz')..createSync()],
|
||||
outputFiles: <File>[fs.file('bar'), fs.file(fs.path.join('.dart_tool', 'fizz2'))..createSync(recursive: true)]);
|
||||
});
|
||||
await commandRunner.run(<String>['assemble', '-o Output', '--build-outputs=outputs', '--build-inputs=inputs', 'debug_macos_bundle_flutter_assets']);
|
||||
|
||||
expect(inputs.readAsStringSync(), contains('foo'));
|
||||
|
@ -47,8 +47,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('Fuchsia build fails gracefully when', () {
|
||||
testUsingContext('there is no Fuchsia project',
|
||||
() async {
|
||||
testUsingContext('there is no Fuchsia project', () async {
|
||||
final BuildCommand command = BuildCommand();
|
||||
applyMocksToCommand(command);
|
||||
expect(
|
||||
|
@ -52,7 +52,7 @@ void main() {
|
||||
macosPlatform = MockPlatform();
|
||||
notMacosPlatform = MockPlatform();
|
||||
when(mockProcess.exitCode).thenAnswer((Invocation invocation) async {
|
||||
return 0;
|
||||
return 0;
|
||||
});
|
||||
when(mockProcess.stderr).thenAnswer((Invocation invocation) {
|
||||
return const Stream<List<int>>.empty();
|
||||
|
@ -733,10 +733,10 @@ class AsyncCrashingValidator extends DoctorValidator {
|
||||
@override
|
||||
Future<ValidationResult> validate() {
|
||||
const Duration delay = Duration(seconds: 1);
|
||||
final Future<ValidationResult> result = Future<ValidationResult>
|
||||
.delayed(delay).then((_) {
|
||||
throw 'fatal error';
|
||||
});
|
||||
final Future<ValidationResult> result = Future<ValidationResult>.delayed(delay)
|
||||
.then((_) {
|
||||
throw 'fatal error';
|
||||
});
|
||||
_time.elapse(const Duration(seconds: 1));
|
||||
_time.flushMicrotasks();
|
||||
return result;
|
||||
|
@ -230,7 +230,7 @@ Future<ProcessResult> _runFlutterTest(
|
||||
}
|
||||
} else {
|
||||
// Test just a specific test file.
|
||||
testPath = fs.path.join(testDirectory, '${testName}_test.dart');
|
||||
testPath = fs.path.join(testDirectory, '${testName}_test.dart');
|
||||
final File testFile = fs.file(testPath);
|
||||
if (!testFile.existsSync()) {
|
||||
fail('missing test file: $testFile');
|
||||
|
@ -274,17 +274,17 @@ Future<void> verifyCrashReportSent(RequestInfo crashInfo, {
|
||||
|
||||
class MockCrashReportSender extends MockClient {
|
||||
MockCrashReportSender(RequestInfo crashInfo) : super((Request request) async {
|
||||
MockCrashReportSender.sendCalls++;
|
||||
crashInfo.method = request.method;
|
||||
crashInfo.uri = request.url;
|
||||
MockCrashReportSender.sendCalls++;
|
||||
crashInfo.method = request.method;
|
||||
crashInfo.uri = request.url;
|
||||
|
||||
// A very ad-hoc multipart request parser. Good enough for this test.
|
||||
String boundary = request.headers['Content-Type'];
|
||||
boundary = boundary.substring(boundary.indexOf('boundary=') + 9);
|
||||
crashInfo.fields = Map<String, String>.fromIterable(
|
||||
utf8.decode(request.bodyBytes)
|
||||
.split('--$boundary')
|
||||
.map<List<String>>((String part) {
|
||||
// A very ad-hoc multipart request parser. Good enough for this test.
|
||||
String boundary = request.headers['Content-Type'];
|
||||
boundary = boundary.substring(boundary.indexOf('boundary=') + 9);
|
||||
crashInfo.fields = Map<String, String>.fromIterable(
|
||||
utf8.decode(request.bodyBytes)
|
||||
.split('--$boundary')
|
||||
.map<List<String>>((String part) {
|
||||
final Match nameMatch = RegExp(r'name="(.*)"').firstMatch(part);
|
||||
if (nameMatch == null) {
|
||||
return null;
|
||||
@ -293,29 +293,28 @@ class MockCrashReportSender extends MockClient {
|
||||
final String value = part.split('\n').skip(2).join('\n').trim();
|
||||
return <String>[name, value];
|
||||
})
|
||||
.where((List<String> pair) => pair != null),
|
||||
key: (dynamic key) {
|
||||
final List<String> pair = key;
|
||||
return pair[0];
|
||||
},
|
||||
value: (dynamic value) {
|
||||
final List<String> pair = value;
|
||||
return pair[1];
|
||||
},
|
||||
);
|
||||
.where((List<String> pair) => pair != null),
|
||||
key: (dynamic key) {
|
||||
final List<String> pair = key;
|
||||
return pair[0];
|
||||
},
|
||||
value: (dynamic value) {
|
||||
final List<String> pair = value;
|
||||
return pair[1];
|
||||
},
|
||||
);
|
||||
|
||||
return Response(
|
||||
'test-report-id',
|
||||
200,
|
||||
);
|
||||
});
|
||||
return Response(
|
||||
'test-report-id',
|
||||
200,
|
||||
);
|
||||
});
|
||||
|
||||
static int sendCalls = 0;
|
||||
}
|
||||
|
||||
class CrashingCrashReportSender extends MockClient {
|
||||
CrashingCrashReportSender(Object exception)
|
||||
: super((Request request) async {
|
||||
CrashingCrashReportSender(Object exception) : super((Request request) async {
|
||||
throw exception;
|
||||
});
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user