Unverified Commit cabe09a5 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Revert "Add flag to ThemeData to expand tap targets of certain material widgets (#18369)" (#19053)

This reverts commit 989f5741.
parent 581df52a
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'button_theme.dart'; import 'button_theme.dart';
...@@ -12,7 +11,6 @@ import 'constants.dart'; ...@@ -12,7 +11,6 @@ import 'constants.dart';
import 'ink_well.dart'; import 'ink_well.dart';
import 'material.dart'; import 'material.dart';
import 'theme.dart'; import 'theme.dart';
import 'theme_data.dart';
/// Creates a button based on [Semantics], [Material], and [InkWell] /// Creates a button based on [Semantics], [Material], and [InkWell]
/// widgets. /// widgets.
...@@ -40,14 +38,13 @@ class RawMaterialButton extends StatefulWidget { ...@@ -40,14 +38,13 @@ class RawMaterialButton extends StatefulWidget {
this.elevation = 2.0, this.elevation = 2.0,
this.highlightElevation = 8.0, this.highlightElevation = 8.0,
this.disabledElevation = 0.0, this.disabledElevation = 0.0,
this.outerPadding,
this.padding = EdgeInsets.zero, this.padding = EdgeInsets.zero,
this.constraints = const BoxConstraints(minWidth: 88.0, minHeight: 36.0), this.constraints = const BoxConstraints(minWidth: 88.0, minHeight: 36.0),
this.shape = const RoundedRectangleBorder(), this.shape = const RoundedRectangleBorder(),
this.animationDuration = kThemeChangeDuration, this.animationDuration = kThemeChangeDuration,
MaterialTapTargetSize materialTapTargetSize,
this.child, this.child,
}) : this.materialTapTargetSize = materialTapTargetSize ?? MaterialTapTargetSize.padded, }) : assert(shape != null),
assert(shape != null),
assert(elevation != null), assert(elevation != null),
assert(highlightElevation != null), assert(highlightElevation != null),
assert(disabledElevation != null), assert(disabledElevation != null),
...@@ -61,6 +58,10 @@ class RawMaterialButton extends StatefulWidget { ...@@ -61,6 +58,10 @@ class RawMaterialButton extends StatefulWidget {
/// If this is set to null, the button will be disabled, see [enabled]. /// If this is set to null, the button will be disabled, see [enabled].
final VoidCallback onPressed; final VoidCallback onPressed;
/// Padding to increase the size of the gesture detector which doesn't
/// increase the visible material of the button.
final EdgeInsets outerPadding;
/// Called by the underlying [InkWell] widget's [InkWell.onHighlightChanged] /// Called by the underlying [InkWell] widget's [InkWell.onHighlightChanged]
/// callback. /// callback.
final ValueChanged<bool> onHighlightChanged; final ValueChanged<bool> onHighlightChanged;
...@@ -137,15 +138,6 @@ class RawMaterialButton extends StatefulWidget { ...@@ -137,15 +138,6 @@ class RawMaterialButton extends StatefulWidget {
/// property to a non-null value. /// property to a non-null value.
bool get enabled => onPressed != null; bool get enabled => onPressed != null;
/// Configures the minimum size of the tap target.
///
/// Defaults to [MaterialTapTargetSize.padded].
///
/// See also:
///
/// * [MaterialTapTargetSize], for a description of how this affects tap targets.
final MaterialTapTargetSize materialTapTargetSize;
@override @override
_RawMaterialButtonState createState() => new _RawMaterialButtonState(); _RawMaterialButtonState createState() => new _RawMaterialButtonState();
} }
...@@ -194,23 +186,18 @@ class _RawMaterialButtonState extends State<RawMaterialButton> { ...@@ -194,23 +186,18 @@ class _RawMaterialButtonState extends State<RawMaterialButton> {
), ),
), ),
); );
BoxConstraints constraints;
switch (widget.materialTapTargetSize) { if (widget.outerPadding != null) {
case MaterialTapTargetSize.padded: result = new GestureDetector(
constraints = const BoxConstraints(minWidth: 48.0, minHeight: 48.0); behavior: HitTestBehavior.translucent,
break; excludeFromSemantics: true,
case MaterialTapTargetSize.shrinkWrap: onTap: widget.onPressed,
constraints = const BoxConstraints(); child: new Padding(
break; padding: widget.outerPadding,
child: result
),
);
} }
result = new _ButtonRedirectingHitDetectionWidget(
constraints: constraints,
child: new Center(
child: result,
widthFactor: 1.0,
heightFactor: 1.0,
),
);
return new Semantics( return new Semantics(
container: true, container: true,
...@@ -261,7 +248,6 @@ class MaterialButton extends StatelessWidget { ...@@ -261,7 +248,6 @@ class MaterialButton extends StatelessWidget {
this.minWidth, this.minWidth,
this.height, this.height,
this.padding, this.padding,
this.materialTapTargetSize,
@required this.onPressed, @required this.onPressed,
this.child this.child
}) : super(key: key); }) : super(key: key);
...@@ -367,15 +353,6 @@ class MaterialButton extends StatelessWidget { ...@@ -367,15 +353,6 @@ class MaterialButton extends StatelessWidget {
/// {@macro flutter.widgets.child} /// {@macro flutter.widgets.child}
final Widget child; final Widget child;
/// Configures the minimum size of the tap target.
///
/// Defaults to [ThemeData.materialTapTargetSize].
///
/// See also:
///
/// * [MaterialTapTargetSize], for a description of how this affects tap targets.
final MaterialTapTargetSize materialTapTargetSize;
/// Whether the button is enabled or disabled. Buttons are disabled by default. To /// Whether the button is enabled or disabled. Buttons are disabled by default. To
/// enable a button, set its [onPressed] property to a non-null value. /// enable a button, set its [onPressed] property to a non-null value.
bool get enabled => onPressed != null; bool get enabled => onPressed != null;
...@@ -435,7 +412,6 @@ class MaterialButton extends StatelessWidget { ...@@ -435,7 +412,6 @@ class MaterialButton extends StatelessWidget {
), ),
shape: buttonTheme.shape, shape: buttonTheme.shape,
child: child, child: child,
materialTapTargetSize: materialTapTargetSize ?? theme.materialTapTargetSize,
); );
} }
...@@ -445,38 +421,3 @@ class MaterialButton extends StatelessWidget { ...@@ -445,38 +421,3 @@ class MaterialButton extends StatelessWidget {
properties.add(new FlagProperty('enabled', value: enabled, ifFalse: 'disabled')); properties.add(new FlagProperty('enabled', value: enabled, ifFalse: 'disabled'));
} }
} }
/// Redirects the position passed to [RenderBox.hitTest] to the center of the widget.
///
/// The primary purpose of this widget is to allow padding around [Material] widgets
/// to trigger the child ink feature without increasing the size of the material.
class _ButtonRedirectingHitDetectionWidget extends SingleChildRenderObjectWidget {
const _ButtonRedirectingHitDetectionWidget({
Key key,
Widget child,
this.constraints
}) : super(key: key, child: child);
final BoxConstraints constraints;
@override
RenderObject createRenderObject(BuildContext context) {
return new _RenderButtonRedirectingHitDetection(constraints);
}
@override
void updateRenderObject(BuildContext context, covariant _RenderButtonRedirectingHitDetection renderObject) {
renderObject.additionalConstraints = constraints;
}
}
class _RenderButtonRedirectingHitDetection extends RenderConstrainedBox {
_RenderButtonRedirectingHitDetection (BoxConstraints additionalConstraints) : super(additionalConstraints: additionalConstraints);
@override
bool hitTest(HitTestResult result, {Offset position}) {
if (!size.contains(position))
return false;
return child.hitTest(result, position: size.center(Offset.zero));
}
}
...@@ -10,7 +10,6 @@ import 'package:flutter/widgets.dart'; ...@@ -10,7 +10,6 @@ import 'package:flutter/widgets.dart';
import 'constants.dart'; import 'constants.dart';
import 'debug.dart'; import 'debug.dart';
import 'theme.dart'; import 'theme.dart';
import 'theme_data.dart';
import 'toggleable.dart'; import 'toggleable.dart';
/// A material design checkbox. /// A material design checkbox.
...@@ -59,7 +58,6 @@ class Checkbox extends StatefulWidget { ...@@ -59,7 +58,6 @@ class Checkbox extends StatefulWidget {
this.tristate = false, this.tristate = false,
@required this.onChanged, @required this.onChanged,
this.activeColor, this.activeColor,
this.materialTapTargetSize,
}) : assert(tristate != null), }) : assert(tristate != null),
assert(tristate || value != null), assert(tristate || value != null),
super(key: key); super(key: key);
...@@ -115,15 +113,6 @@ class Checkbox extends StatefulWidget { ...@@ -115,15 +113,6 @@ class Checkbox extends StatefulWidget {
/// If tristate is false (the default), [value] must not be null. /// If tristate is false (the default), [value] must not be null.
final bool tristate; final bool tristate;
/// Configures the minimum size of the tap target.
///
/// Defaults to [ThemeData.materialTapTargetSize].
///
/// See also:
///
/// * [MaterialTapTargetSize], for a description of how this affects tap targets.
final MaterialTapTargetSize materialTapTargetSize;
/// The width of a checkbox widget. /// The width of a checkbox widget.
static const double width = 18.0; static const double width = 18.0;
...@@ -136,23 +125,12 @@ class _CheckboxState extends State<Checkbox> with TickerProviderStateMixin { ...@@ -136,23 +125,12 @@ class _CheckboxState extends State<Checkbox> with TickerProviderStateMixin {
Widget build(BuildContext context) { Widget build(BuildContext context) {
assert(debugCheckHasMaterial(context)); assert(debugCheckHasMaterial(context));
final ThemeData themeData = Theme.of(context); final ThemeData themeData = Theme.of(context);
Size size;
switch (widget.materialTapTargetSize ?? themeData.materialTapTargetSize) {
case MaterialTapTargetSize.padded:
size = const Size(2 * kRadialReactionRadius + 8.0, 2 * kRadialReactionRadius + 8.0);
break;
case MaterialTapTargetSize.shrinkWrap:
size = const Size(2 * kRadialReactionRadius, 2 * kRadialReactionRadius);
break;
}
final BoxConstraints additionalConstraints = new BoxConstraints.tight(size);
return new _CheckboxRenderObjectWidget( return new _CheckboxRenderObjectWidget(
value: widget.value, value: widget.value,
tristate: widget.tristate, tristate: widget.tristate,
activeColor: widget.activeColor ?? themeData.toggleableActiveColor, activeColor: widget.activeColor ?? themeData.toggleableActiveColor,
inactiveColor: widget.onChanged != null ? themeData.unselectedWidgetColor : themeData.disabledColor, inactiveColor: widget.onChanged != null ? themeData.unselectedWidgetColor : themeData.disabledColor,
onChanged: widget.onChanged, onChanged: widget.onChanged,
additionalConstraints: additionalConstraints,
vsync: this, vsync: this,
); );
} }
...@@ -167,7 +145,6 @@ class _CheckboxRenderObjectWidget extends LeafRenderObjectWidget { ...@@ -167,7 +145,6 @@ class _CheckboxRenderObjectWidget extends LeafRenderObjectWidget {
@required this.inactiveColor, @required this.inactiveColor,
@required this.onChanged, @required this.onChanged,
@required this.vsync, @required this.vsync,
@required this.additionalConstraints,
}) : assert(tristate != null), }) : assert(tristate != null),
assert(tristate || value != null), assert(tristate || value != null),
assert(activeColor != null), assert(activeColor != null),
...@@ -181,7 +158,6 @@ class _CheckboxRenderObjectWidget extends LeafRenderObjectWidget { ...@@ -181,7 +158,6 @@ class _CheckboxRenderObjectWidget extends LeafRenderObjectWidget {
final Color inactiveColor; final Color inactiveColor;
final ValueChanged<bool> onChanged; final ValueChanged<bool> onChanged;
final TickerProvider vsync; final TickerProvider vsync;
final BoxConstraints additionalConstraints;
@override @override
_RenderCheckbox createRenderObject(BuildContext context) => new _RenderCheckbox( _RenderCheckbox createRenderObject(BuildContext context) => new _RenderCheckbox(
...@@ -191,7 +167,6 @@ class _CheckboxRenderObjectWidget extends LeafRenderObjectWidget { ...@@ -191,7 +167,6 @@ class _CheckboxRenderObjectWidget extends LeafRenderObjectWidget {
inactiveColor: inactiveColor, inactiveColor: inactiveColor,
onChanged: onChanged, onChanged: onChanged,
vsync: vsync, vsync: vsync,
additionalConstraints: additionalConstraints,
); );
@override @override
...@@ -202,7 +177,6 @@ class _CheckboxRenderObjectWidget extends LeafRenderObjectWidget { ...@@ -202,7 +177,6 @@ class _CheckboxRenderObjectWidget extends LeafRenderObjectWidget {
..activeColor = activeColor ..activeColor = activeColor
..inactiveColor = inactiveColor ..inactiveColor = inactiveColor
..onChanged = onChanged ..onChanged = onChanged
..additionalConstraints = additionalConstraints
..vsync = vsync; ..vsync = vsync;
} }
} }
...@@ -217,7 +191,6 @@ class _RenderCheckbox extends RenderToggleable { ...@@ -217,7 +191,6 @@ class _RenderCheckbox extends RenderToggleable {
bool tristate, bool tristate,
Color activeColor, Color activeColor,
Color inactiveColor, Color inactiveColor,
BoxConstraints additionalConstraints,
ValueChanged<bool> onChanged, ValueChanged<bool> onChanged,
@required TickerProvider vsync, @required TickerProvider vsync,
}): _oldValue = value, }): _oldValue = value,
...@@ -227,7 +200,7 @@ class _RenderCheckbox extends RenderToggleable { ...@@ -227,7 +200,7 @@ class _RenderCheckbox extends RenderToggleable {
activeColor: activeColor, activeColor: activeColor,
inactiveColor: inactiveColor, inactiveColor: inactiveColor,
onChanged: onChanged, onChanged: onChanged,
additionalConstraints: additionalConstraints, size: const Size(2 * kRadialReactionRadius, 2 * kRadialReactionRadius),
vsync: vsync, vsync: vsync,
); );
......
...@@ -7,7 +7,6 @@ import 'package:flutter/widgets.dart'; ...@@ -7,7 +7,6 @@ import 'package:flutter/widgets.dart';
import 'checkbox.dart'; import 'checkbox.dart';
import 'list_tile.dart'; import 'list_tile.dart';
import 'theme.dart'; import 'theme.dart';
import 'theme_data.dart';
/// A [ListTile] with a [Checkbox]. In other words, a checkbox with a label. /// A [ListTile] with a [Checkbox]. In other words, a checkbox with a label.
/// ///
...@@ -174,7 +173,6 @@ class CheckboxListTile extends StatelessWidget { ...@@ -174,7 +173,6 @@ class CheckboxListTile extends StatelessWidget {
value: value, value: value,
onChanged: onChanged, onChanged: onChanged,
activeColor: activeColor, activeColor: activeColor,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
); );
Widget leading, trailing; Widget leading, trailing;
switch (controlAffinity) { switch (controlAffinity) {
......
...@@ -17,7 +17,6 @@ import 'ink_well.dart'; ...@@ -17,7 +17,6 @@ import 'ink_well.dart';
import 'material.dart'; import 'material.dart';
import 'material_localizations.dart'; import 'material_localizations.dart';
import 'theme.dart'; import 'theme.dart';
import 'theme_data.dart';
import 'tooltip.dart'; import 'tooltip.dart';
// Some design constants // Some design constants
...@@ -100,15 +99,6 @@ abstract class ChipAttributes { ...@@ -100,15 +99,6 @@ abstract class ChipAttributes {
/// By default, this is 4 logical pixels at the beginning and the end of the /// By default, this is 4 logical pixels at the beginning and the end of the
/// label, and zero on top and bottom. /// label, and zero on top and bottom.
EdgeInsetsGeometry get labelPadding; EdgeInsetsGeometry get labelPadding;
/// Configures the minimum size of the tap target.
///
/// Defaults to [ThemeData.materialTapTargetSize].
///
/// See also:
///
/// * [MaterialTapTargetSize], for a description of how this affects tap targets.
MaterialTapTargetSize get materialTapTargetSize;
} }
/// An interface for material design chips that can be deleted. /// An interface for material design chips that can be deleted.
...@@ -433,7 +423,6 @@ class Chip extends StatelessWidget implements ChipAttributes, DeletableChipAttri ...@@ -433,7 +423,6 @@ class Chip extends StatelessWidget implements ChipAttributes, DeletableChipAttri
this.shape, this.shape,
this.backgroundColor, this.backgroundColor,
this.padding, this.padding,
this.materialTapTargetSize,
}) : assert(label != null), }) : assert(label != null),
super(key: key); super(key: key);
...@@ -459,8 +448,6 @@ class Chip extends StatelessWidget implements ChipAttributes, DeletableChipAttri ...@@ -459,8 +448,6 @@ class Chip extends StatelessWidget implements ChipAttributes, DeletableChipAttri
final Color deleteIconColor; final Color deleteIconColor;
@override @override
final String deleteButtonTooltipMessage; final String deleteButtonTooltipMessage;
@override
final MaterialTapTargetSize materialTapTargetSize;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -478,7 +465,6 @@ class Chip extends StatelessWidget implements ChipAttributes, DeletableChipAttri ...@@ -478,7 +465,6 @@ class Chip extends StatelessWidget implements ChipAttributes, DeletableChipAttri
shape: shape, shape: shape,
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
padding: padding, padding: padding,
materialTapTargetSize: materialTapTargetSize,
isEnabled: true, isEnabled: true,
); );
} }
...@@ -561,7 +547,6 @@ class InputChip extends StatelessWidget ...@@ -561,7 +547,6 @@ class InputChip extends StatelessWidget
this.shape, this.shape,
this.backgroundColor, this.backgroundColor,
this.padding, this.padding,
this.materialTapTargetSize,
}) : assert(selected != null), }) : assert(selected != null),
assert(isEnabled != null), assert(isEnabled != null),
assert(label != null), assert(label != null),
...@@ -603,8 +588,6 @@ class InputChip extends StatelessWidget ...@@ -603,8 +588,6 @@ class InputChip extends StatelessWidget
final Color backgroundColor; final Color backgroundColor;
@override @override
final EdgeInsetsGeometry padding; final EdgeInsetsGeometry padding;
@override
final MaterialTapTargetSize materialTapTargetSize;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -628,7 +611,6 @@ class InputChip extends StatelessWidget ...@@ -628,7 +611,6 @@ class InputChip extends StatelessWidget
shape: shape, shape: shape,
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
padding: padding, padding: padding,
materialTapTargetSize: materialTapTargetSize,
isEnabled: isEnabled && (onSelected != null || onDeleted != null || onPressed != null), isEnabled: isEnabled && (onSelected != null || onDeleted != null || onPressed != null),
); );
} }
...@@ -707,7 +689,6 @@ class ChoiceChip extends StatelessWidget ...@@ -707,7 +689,6 @@ class ChoiceChip extends StatelessWidget
this.shape, this.shape,
this.backgroundColor, this.backgroundColor,
this.padding, this.padding,
this.materialTapTargetSize,
}) : assert(selected != null), }) : assert(selected != null),
assert(label != null), assert(label != null),
super(key: key); super(key: key);
...@@ -736,8 +717,6 @@ class ChoiceChip extends StatelessWidget ...@@ -736,8 +717,6 @@ class ChoiceChip extends StatelessWidget
final Color backgroundColor; final Color backgroundColor;
@override @override
final EdgeInsetsGeometry padding; final EdgeInsetsGeometry padding;
@override
final MaterialTapTargetSize materialTapTargetSize;
@override @override
bool get isEnabled => onSelected != null; bool get isEnabled => onSelected != null;
...@@ -762,7 +741,6 @@ class ChoiceChip extends StatelessWidget ...@@ -762,7 +741,6 @@ class ChoiceChip extends StatelessWidget
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
padding: padding, padding: padding,
isEnabled: isEnabled, isEnabled: isEnabled,
materialTapTargetSize: materialTapTargetSize,
); );
} }
} }
...@@ -874,7 +852,6 @@ class FilterChip extends StatelessWidget ...@@ -874,7 +852,6 @@ class FilterChip extends StatelessWidget
this.shape, this.shape,
this.backgroundColor, this.backgroundColor,
this.padding, this.padding,
this.materialTapTargetSize,
}) : assert(selected != null), }) : assert(selected != null),
assert(label != null), assert(label != null),
super(key: key); super(key: key);
...@@ -903,8 +880,6 @@ class FilterChip extends StatelessWidget ...@@ -903,8 +880,6 @@ class FilterChip extends StatelessWidget
final Color backgroundColor; final Color backgroundColor;
@override @override
final EdgeInsetsGeometry padding; final EdgeInsetsGeometry padding;
@override
final MaterialTapTargetSize materialTapTargetSize;
@override @override
bool get isEnabled => onSelected != null; bool get isEnabled => onSelected != null;
...@@ -926,7 +901,6 @@ class FilterChip extends StatelessWidget ...@@ -926,7 +901,6 @@ class FilterChip extends StatelessWidget
selectedColor: selectedColor, selectedColor: selectedColor,
padding: padding, padding: padding,
isEnabled: isEnabled, isEnabled: isEnabled,
materialTapTargetSize: materialTapTargetSize,
); );
} }
} }
...@@ -992,7 +966,6 @@ class ActionChip extends StatelessWidget implements ChipAttributes, TappableChip ...@@ -992,7 +966,6 @@ class ActionChip extends StatelessWidget implements ChipAttributes, TappableChip
this.shape, this.shape,
this.backgroundColor, this.backgroundColor,
this.padding, this.padding,
this.materialTapTargetSize,
}) : assert(label != null), }) : assert(label != null),
assert( assert(
onPressed != null, onPressed != null,
...@@ -1019,8 +992,6 @@ class ActionChip extends StatelessWidget implements ChipAttributes, TappableChip ...@@ -1019,8 +992,6 @@ class ActionChip extends StatelessWidget implements ChipAttributes, TappableChip
final Color backgroundColor; final Color backgroundColor;
@override @override
final EdgeInsetsGeometry padding; final EdgeInsetsGeometry padding;
@override
final MaterialTapTargetSize materialTapTargetSize;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -1036,7 +1007,6 @@ class ActionChip extends StatelessWidget implements ChipAttributes, TappableChip ...@@ -1036,7 +1007,6 @@ class ActionChip extends StatelessWidget implements ChipAttributes, TappableChip
padding: padding, padding: padding,
labelPadding: labelPadding, labelPadding: labelPadding,
isEnabled: true, isEnabled: true,
materialTapTargetSize: materialTapTargetSize
); );
} }
} }
...@@ -1106,7 +1076,6 @@ class RawChip extends StatefulWidget ...@@ -1106,7 +1076,6 @@ class RawChip extends StatefulWidget
this.tooltip, this.tooltip,
this.shape, this.shape,
this.backgroundColor, this.backgroundColor,
this.materialTapTargetSize,
}) : assert(label != null), }) : assert(label != null),
assert(isEnabled != null), assert(isEnabled != null),
deleteIcon = deleteIcon ?? _kDefaultDeleteIcon, deleteIcon = deleteIcon ?? _kDefaultDeleteIcon,
...@@ -1148,8 +1117,6 @@ class RawChip extends StatefulWidget ...@@ -1148,8 +1117,6 @@ class RawChip extends StatefulWidget
final Color backgroundColor; final Color backgroundColor;
@override @override
final EdgeInsetsGeometry padding; final EdgeInsetsGeometry padding;
@override
final MaterialTapTargetSize materialTapTargetSize;
/// Whether or not to show a check mark when [selected] is true. /// Whether or not to show a check mark when [selected] is true.
/// ///
...@@ -1401,7 +1368,7 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip ...@@ -1401,7 +1368,7 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
final TextDirection textDirection = Directionality.of(context); final TextDirection textDirection = Directionality.of(context);
final ShapeBorder shape = widget.shape ?? chipTheme.shape; final ShapeBorder shape = widget.shape ?? chipTheme.shape;
Widget result = new Material( return new Material(
elevation: isTapping ? _kPressElevation : 0.0, elevation: isTapping ? _kPressElevation : 0.0,
animationDuration: pressedAnimationDuration, animationDuration: pressedAnimationDuration,
shape: shape, shape: shape,
...@@ -1461,68 +1428,6 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip ...@@ -1461,68 +1428,6 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
), ),
), ),
); );
BoxConstraints constraints;
switch (widget.materialTapTargetSize ?? theme.materialTapTargetSize) {
case MaterialTapTargetSize.padded:
constraints = const BoxConstraints(minHeight: 48.0);
break;
case MaterialTapTargetSize.shrinkWrap:
constraints = const BoxConstraints();
break;
}
result = _ChipRedirectingHitDetectionWidget(
constraints: constraints,
child: new Center(
child: result,
widthFactor: 1.0,
heightFactor: 1.0,
),
);
return new Semantics(
container: true,
selected: widget.selected,
enabled: canTap ? widget.isEnabled : null,
child: result,
);
}
}
/// Redirects the [position.dy] passed to [RenderBox.hitTest] to the vertical
/// center of the widget.
///
/// The primary purpose of this widget is to allow padding around the [RawChip]
/// to trigger the child ink feature without increasing the size of the material.
class _ChipRedirectingHitDetectionWidget extends SingleChildRenderObjectWidget {
const _ChipRedirectingHitDetectionWidget({
Key key,
Widget child,
this.constraints,
}) : super(key: key, child: child);
final BoxConstraints constraints;
@override
RenderObject createRenderObject(BuildContext context) {
return new _RenderChipRedirectingHitDetection(constraints);
}
@override
void updateRenderObject(BuildContext context, covariant _RenderChipRedirectingHitDetection renderObject) {
renderObject.additionalConstraints = constraints;
}
}
class _RenderChipRedirectingHitDetection extends RenderConstrainedBox {
_RenderChipRedirectingHitDetection(BoxConstraints additionalConstraints) : super(additionalConstraints: additionalConstraints);
@override
bool hitTest(HitTestResult result, {Offset position}) {
if (!size.contains(position))
return false;
// Only redirects hit detection which occurs above and below the render object.
// In order to make this assumption true, I have removed the minimum width
// constraints, since any reasonable chip would be at least that wide.
return child.hitTest(result, position: new Offset(position.dx, size.height / 2));
} }
} }
...@@ -2027,28 +1932,6 @@ class _RenderChip extends RenderBox { ...@@ -2027,28 +1932,6 @@ class _RenderChip extends RenderBox {
return new Size(deleteIconWidth, deleteIconHeight); return new Size(deleteIconWidth, deleteIconHeight);
} }
@override
bool hitTest(HitTestResult result, {Offset position}) {
if (!size.contains(position))
return false;
RenderBox hitTestChild;
switch (textDirection) {
case TextDirection.ltr:
if (position.dx / size.width > 0.66)
hitTestChild = deleteIcon ?? label ?? avatar;
else
hitTestChild = label ?? avatar;
break;
case TextDirection.rtl:
if (position.dx / size.width < 0.33)
hitTestChild = deleteIcon ?? label ?? avatar;
else
hitTestChild = label ?? avatar;
break;
}
return hitTestChild?.hitTest(result, position: hitTestChild.size.center(Offset.zero)) ?? false;
}
@override @override
void performLayout() { void performLayout() {
final BoxConstraints contentConstraints = constraints.loosen(); final BoxConstraints contentConstraints = constraints.loosen();
...@@ -2367,4 +2250,20 @@ class _RenderChip extends RenderBox { ...@@ -2367,4 +2250,20 @@ class _RenderChip extends RenderBox {
@override @override
bool hitTestSelf(Offset position) => deleteButtonRect.contains(position) || pressRect.contains(position); bool hitTestSelf(Offset position) => deleteButtonRect.contains(position) || pressRect.contains(position);
@override
bool hitTestChildren(HitTestResult result, {@required Offset position}) {
assert(position != null);
if (deleteIcon != null && deleteButtonRect.contains(position)) {
// This simulates a position at the center of the delete icon if the hit
// on the chip is inside of the delete area.
return deleteIcon.hitTest(result, position: (Offset.zero & _boxSize(deleteIcon)).center);
}
for (RenderBox child in _children) {
if (child.hasSize && child.hitTest(result, position: position - _boxParentData(child).offset)) {
return true;
}
}
return false;
}
} }
...@@ -9,7 +9,6 @@ import 'button.dart'; ...@@ -9,7 +9,6 @@ import 'button.dart';
import 'button_theme.dart'; import 'button_theme.dart';
import 'colors.dart'; import 'colors.dart';
import 'theme.dart'; import 'theme.dart';
import 'theme_data.dart';
/// A material design "flat button". /// A material design "flat button".
/// ///
...@@ -63,7 +62,6 @@ class FlatButton extends StatelessWidget { ...@@ -63,7 +62,6 @@ class FlatButton extends StatelessWidget {
this.colorBrightness, this.colorBrightness,
this.padding, this.padding,
this.shape, this.shape,
this.materialTapTargetSize,
@required this.child, @required this.child,
}) : super(key: key); }) : super(key: key);
...@@ -87,7 +85,6 @@ class FlatButton extends StatelessWidget { ...@@ -87,7 +85,6 @@ class FlatButton extends StatelessWidget {
this.splashColor, this.splashColor,
this.colorBrightness, this.colorBrightness,
this.shape, this.shape,
this.materialTapTargetSize,
@required Widget icon, @required Widget icon,
@required Widget label, @required Widget label,
}) : assert(icon != null), }) : assert(icon != null),
...@@ -188,15 +185,6 @@ class FlatButton extends StatelessWidget { ...@@ -188,15 +185,6 @@ class FlatButton extends StatelessWidget {
/// Defaults to the theme's brightness, [ThemeData.brightness]. /// Defaults to the theme's brightness, [ThemeData.brightness].
final Brightness colorBrightness; final Brightness colorBrightness;
/// Configures the minimum size of the tap target.
///
/// Defaults to [ThemeData.materialTapTargetSize].
///
/// See also:
///
/// * [MaterialTapTargetSize], for a description of how this affects tap targets.
final MaterialTapTargetSize materialTapTargetSize;
/// The widget below this widget in the tree. /// The widget below this widget in the tree.
/// ///
/// Typically a [Text] widget in all caps. /// Typically a [Text] widget in all caps.
...@@ -302,7 +290,6 @@ class FlatButton extends StatelessWidget { ...@@ -302,7 +290,6 @@ class FlatButton extends StatelessWidget {
splashColor: _getSplashColor(theme, buttonTheme), splashColor: _getSplashColor(theme, buttonTheme),
elevation: 0.0, elevation: 0.0,
highlightElevation: 0.0, highlightElevation: 0.0,
materialTapTargetSize: materialTapTargetSize ?? theme.materialTapTargetSize,
padding: padding ?? buttonTheme.padding, padding: padding ?? buttonTheme.padding,
constraints: buttonTheme.constraints, constraints: buttonTheme.constraints,
shape: shape ?? buttonTheme.shape, shape: shape ?? buttonTheme.shape,
...@@ -324,6 +311,5 @@ class FlatButton extends StatelessWidget { ...@@ -324,6 +311,5 @@ class FlatButton extends StatelessWidget {
properties.add(new DiagnosticsProperty<Brightness>('colorBrightness', colorBrightness, defaultValue: null)); properties.add(new DiagnosticsProperty<Brightness>('colorBrightness', colorBrightness, defaultValue: null));
properties.add(new DiagnosticsProperty<EdgeInsetsGeometry>('padding', padding, defaultValue: null)); properties.add(new DiagnosticsProperty<EdgeInsetsGeometry>('padding', padding, defaultValue: null));
properties.add(new DiagnosticsProperty<ShapeBorder>('shape', shape, defaultValue: null)); properties.add(new DiagnosticsProperty<ShapeBorder>('shape', shape, defaultValue: null));
properties.add(new DiagnosticsProperty<MaterialTapTargetSize>('materialTapTargetSize', materialTapTargetSize, defaultValue: null));
} }
} }
...@@ -8,7 +8,6 @@ import 'package:flutter/widgets.dart'; ...@@ -8,7 +8,6 @@ import 'package:flutter/widgets.dart';
import 'button.dart'; import 'button.dart';
import 'scaffold.dart'; import 'scaffold.dart';
import 'theme.dart'; import 'theme.dart';
import 'theme_data.dart';
import 'tooltip.dart'; import 'tooltip.dart';
const BoxConstraints _kSizeConstraints = const BoxConstraints.tightFor( const BoxConstraints _kSizeConstraints = const BoxConstraints.tightFor(
...@@ -68,7 +67,6 @@ class FloatingActionButton extends StatefulWidget { ...@@ -68,7 +67,6 @@ class FloatingActionButton extends StatefulWidget {
@required this.onPressed, @required this.onPressed,
this.mini = false, this.mini = false,
this.shape = const CircleBorder(), this.shape = const CircleBorder(),
this.materialTapTargetSize,
this.isExtended = false, this.isExtended = false,
}) : assert(elevation != null), }) : assert(elevation != null),
assert(highlightElevation != null), assert(highlightElevation != null),
...@@ -94,7 +92,6 @@ class FloatingActionButton extends StatefulWidget { ...@@ -94,7 +92,6 @@ class FloatingActionButton extends StatefulWidget {
@required this.onPressed, @required this.onPressed,
this.shape = const StadiumBorder(), this.shape = const StadiumBorder(),
this.isExtended = true, this.isExtended = true,
this.materialTapTargetSize,
@required Widget icon, @required Widget icon,
@required Widget label, @required Widget label,
}) : assert(elevation != null), }) : assert(elevation != null),
...@@ -199,15 +196,6 @@ class FloatingActionButton extends StatefulWidget { ...@@ -199,15 +196,6 @@ class FloatingActionButton extends StatefulWidget {
/// floating action buttons are scaled and faded in. /// floating action buttons are scaled and faded in.
final bool isExtended; final bool isExtended;
/// Configures the minimum size of the tap target.
///
/// Defaults to [ThemeData.materialTapTargetSize].
///
/// See also:
///
/// * [MaterialTapTargetSize], for a description of how this affects tap targets.
final MaterialTapTargetSize materialTapTargetSize;
final BoxConstraints _sizeConstraints; final BoxConstraints _sizeConstraints;
@override @override
...@@ -253,7 +241,7 @@ class _FloatingActionButtonState extends State<FloatingActionButton> { ...@@ -253,7 +241,7 @@ class _FloatingActionButtonState extends State<FloatingActionButton> {
onHighlightChanged: _handleHighlightChanged, onHighlightChanged: _handleHighlightChanged,
elevation: _highlight ? widget.highlightElevation : widget.elevation, elevation: _highlight ? widget.highlightElevation : widget.elevation,
constraints: widget._sizeConstraints, constraints: widget._sizeConstraints,
materialTapTargetSize: widget.materialTapTargetSize ?? theme.materialTapTargetSize, outerPadding: widget.mini ? const EdgeInsets.all(4.0) : null,
fillColor: widget.backgroundColor ?? theme.accentColor, fillColor: widget.backgroundColor ?? theme.accentColor,
textStyle: theme.accentTextTheme.button.copyWith( textStyle: theme.accentTextTheme.button.copyWith(
color: foregroundColor, color: foregroundColor,
......
...@@ -31,7 +31,7 @@ abstract class InputBorder extends ShapeBorder { ...@@ -31,7 +31,7 @@ abstract class InputBorder extends ShapeBorder {
/// No input border. /// No input border.
/// ///
/// Use this value with [InputDecoration.border] to specify that no border /// Use this value with [InputDecoration.border] to specify that no border
/// should be drawn. The [InputDecoration.shrinkWrap] constructor sets /// should be drawn. The [InputDecoration.collapsed] constructor sets
/// its border to this value. /// its border to this value.
static const InputBorder none = const _NoInputBorder(); static const InputBorder none = const _NoInputBorder();
......
...@@ -8,7 +8,6 @@ import 'package:flutter/widgets.dart'; ...@@ -8,7 +8,6 @@ import 'package:flutter/widgets.dart';
import 'constants.dart'; import 'constants.dart';
import 'debug.dart'; import 'debug.dart';
import 'theme.dart'; import 'theme.dart';
import 'theme_data.dart';
import 'toggleable.dart'; import 'toggleable.dart';
const double _kOuterRadius = 8.0; const double _kOuterRadius = 8.0;
...@@ -55,8 +54,7 @@ class Radio<T> extends StatefulWidget { ...@@ -55,8 +54,7 @@ class Radio<T> extends StatefulWidget {
@required this.value, @required this.value,
@required this.groupValue, @required this.groupValue,
@required this.onChanged, @required this.onChanged,
this.activeColor, this.activeColor
this.materialTapTargetSize,
}) : super(key: key); }) : super(key: key);
/// The value represented by this radio button. /// The value represented by this radio button.
...@@ -98,15 +96,6 @@ class Radio<T> extends StatefulWidget { ...@@ -98,15 +96,6 @@ class Radio<T> extends StatefulWidget {
/// Defaults to [ThemeData.toggleableActiveColor]. /// Defaults to [ThemeData.toggleableActiveColor].
final Color activeColor; final Color activeColor;
/// Configures the minimum size of the tap target.
///
/// Defaults to [ThemeData.materialTapTargetSize].
///
/// See also:
///
/// * [MaterialTapTargetSize], for a description of how this affects tap targets.
final MaterialTapTargetSize materialTapTargetSize;
@override @override
_RadioState<T> createState() => new _RadioState<T>(); _RadioState<T> createState() => new _RadioState<T>();
} }
...@@ -127,22 +116,11 @@ class _RadioState<T> extends State<Radio<T>> with TickerProviderStateMixin { ...@@ -127,22 +116,11 @@ class _RadioState<T> extends State<Radio<T>> with TickerProviderStateMixin {
Widget build(BuildContext context) { Widget build(BuildContext context) {
assert(debugCheckHasMaterial(context)); assert(debugCheckHasMaterial(context));
final ThemeData themeData = Theme.of(context); final ThemeData themeData = Theme.of(context);
Size size;
switch (widget.materialTapTargetSize ?? themeData.materialTapTargetSize) {
case MaterialTapTargetSize.padded:
size = const Size(2 * kRadialReactionRadius + 8.0, 2 * kRadialReactionRadius + 8.0);
break;
case MaterialTapTargetSize.shrinkWrap:
size = const Size(2 * kRadialReactionRadius, 2 * kRadialReactionRadius);
break;
}
final BoxConstraints additionalConstraints = new BoxConstraints.tight(size);
return new _RadioRenderObjectWidget( return new _RadioRenderObjectWidget(
selected: widget.value == widget.groupValue, selected: widget.value == widget.groupValue,
activeColor: widget.activeColor ?? themeData.toggleableActiveColor, activeColor: widget.activeColor ?? themeData.toggleableActiveColor,
inactiveColor: _getInactiveColor(themeData), inactiveColor: _getInactiveColor(themeData),
onChanged: _enabled ? _handleChanged : null, onChanged: _enabled ? _handleChanged : null,
additionalConstraints: additionalConstraints,
vsync: this, vsync: this,
); );
} }
...@@ -154,7 +132,6 @@ class _RadioRenderObjectWidget extends LeafRenderObjectWidget { ...@@ -154,7 +132,6 @@ class _RadioRenderObjectWidget extends LeafRenderObjectWidget {
@required this.selected, @required this.selected,
@required this.activeColor, @required this.activeColor,
@required this.inactiveColor, @required this.inactiveColor,
@required this.additionalConstraints,
this.onChanged, this.onChanged,
@required this.vsync, @required this.vsync,
}) : assert(selected != null), }) : assert(selected != null),
...@@ -168,7 +145,6 @@ class _RadioRenderObjectWidget extends LeafRenderObjectWidget { ...@@ -168,7 +145,6 @@ class _RadioRenderObjectWidget extends LeafRenderObjectWidget {
final Color activeColor; final Color activeColor;
final ValueChanged<bool> onChanged; final ValueChanged<bool> onChanged;
final TickerProvider vsync; final TickerProvider vsync;
final BoxConstraints additionalConstraints;
@override @override
_RenderRadio createRenderObject(BuildContext context) => new _RenderRadio( _RenderRadio createRenderObject(BuildContext context) => new _RenderRadio(
...@@ -177,7 +153,6 @@ class _RadioRenderObjectWidget extends LeafRenderObjectWidget { ...@@ -177,7 +153,6 @@ class _RadioRenderObjectWidget extends LeafRenderObjectWidget {
inactiveColor: inactiveColor, inactiveColor: inactiveColor,
onChanged: onChanged, onChanged: onChanged,
vsync: vsync, vsync: vsync,
additionalConstraints: additionalConstraints,
); );
@override @override
...@@ -187,7 +162,6 @@ class _RadioRenderObjectWidget extends LeafRenderObjectWidget { ...@@ -187,7 +162,6 @@ class _RadioRenderObjectWidget extends LeafRenderObjectWidget {
..activeColor = activeColor ..activeColor = activeColor
..inactiveColor = inactiveColor ..inactiveColor = inactiveColor
..onChanged = onChanged ..onChanged = onChanged
..additionalConstraints = additionalConstraints
..vsync = vsync; ..vsync = vsync;
} }
} }
...@@ -198,7 +172,6 @@ class _RenderRadio extends RenderToggleable { ...@@ -198,7 +172,6 @@ class _RenderRadio extends RenderToggleable {
Color activeColor, Color activeColor,
Color inactiveColor, Color inactiveColor,
ValueChanged<bool> onChanged, ValueChanged<bool> onChanged,
BoxConstraints additionalConstraints,
@required TickerProvider vsync, @required TickerProvider vsync,
}): super( }): super(
value: value, value: value,
...@@ -206,7 +179,7 @@ class _RenderRadio extends RenderToggleable { ...@@ -206,7 +179,7 @@ class _RenderRadio extends RenderToggleable {
activeColor: activeColor, activeColor: activeColor,
inactiveColor: inactiveColor, inactiveColor: inactiveColor,
onChanged: onChanged, onChanged: onChanged,
additionalConstraints: additionalConstraints, size: const Size(2 * kRadialReactionRadius, 2 * kRadialReactionRadius),
vsync: vsync, vsync: vsync,
); );
......
...@@ -7,7 +7,6 @@ import 'package:flutter/widgets.dart'; ...@@ -7,7 +7,6 @@ import 'package:flutter/widgets.dart';
import 'list_tile.dart'; import 'list_tile.dart';
import 'radio.dart'; import 'radio.dart';
import 'theme.dart'; import 'theme.dart';
import 'theme_data.dart';
/// A [ListTile] with a [Radio]. In other words, a radio button with a label. /// A [ListTile] with a [Radio]. In other words, a radio button with a label.
/// ///
...@@ -199,7 +198,6 @@ class RadioListTile<T> extends StatelessWidget { ...@@ -199,7 +198,6 @@ class RadioListTile<T> extends StatelessWidget {
groupValue: groupValue, groupValue: groupValue,
onChanged: onChanged, onChanged: onChanged,
activeColor: activeColor, activeColor: activeColor,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
); );
Widget leading, trailing; Widget leading, trailing;
switch (controlAffinity) { switch (controlAffinity) {
......
...@@ -10,7 +10,6 @@ import 'button_theme.dart'; ...@@ -10,7 +10,6 @@ import 'button_theme.dart';
import 'colors.dart'; import 'colors.dart';
import 'constants.dart'; import 'constants.dart';
import 'theme.dart'; import 'theme.dart';
import 'theme_data.dart';
/// A material design "raised button". /// A material design "raised button".
/// ///
...@@ -63,7 +62,6 @@ class RaisedButton extends StatelessWidget { ...@@ -63,7 +62,6 @@ class RaisedButton extends StatelessWidget {
this.disabledElevation = 0.0, this.disabledElevation = 0.0,
this.padding, this.padding,
this.shape, this.shape,
this.materialTapTargetSize,
this.animationDuration = kThemeChangeDuration, this.animationDuration = kThemeChangeDuration,
this.child, this.child,
}) : assert(elevation != null), }) : assert(elevation != null),
...@@ -96,7 +94,6 @@ class RaisedButton extends StatelessWidget { ...@@ -96,7 +94,6 @@ class RaisedButton extends StatelessWidget {
this.highlightElevation = 8.0, this.highlightElevation = 8.0,
this.disabledElevation = 0.0, this.disabledElevation = 0.0,
this.shape, this.shape,
this.materialTapTargetSize,
this.animationDuration = kThemeChangeDuration, this.animationDuration = kThemeChangeDuration,
@required Widget icon, @required Widget icon,
@required Widget label, @required Widget label,
...@@ -292,15 +289,6 @@ class RaisedButton extends StatelessWidget { ...@@ -292,15 +289,6 @@ class RaisedButton extends StatelessWidget {
/// The default value is [kThemeChangeDuration]. /// The default value is [kThemeChangeDuration].
final Duration animationDuration; final Duration animationDuration;
/// Configures the minimum size of the tap target.
///
/// Defaults to [ThemeData.materialTapTargetSize].
///
/// See also:
///
/// * [MaterialTapTargetSize], for a description of how this affects tap targets.
final MaterialTapTargetSize materialTapTargetSize;
Brightness _getBrightness(ThemeData theme) { Brightness _getBrightness(ThemeData theme) {
return colorBrightness ?? theme.brightness; return colorBrightness ?? theme.brightness;
} }
...@@ -392,7 +380,6 @@ class RaisedButton extends StatelessWidget { ...@@ -392,7 +380,6 @@ class RaisedButton extends StatelessWidget {
shape: shape ?? buttonTheme.shape, shape: shape ?? buttonTheme.shape,
animationDuration: animationDuration, animationDuration: animationDuration,
child: child, child: child,
materialTapTargetSize: materialTapTargetSize ?? theme.materialTapTargetSize,
); );
} }
......
...@@ -12,17 +12,8 @@ import 'constants.dart'; ...@@ -12,17 +12,8 @@ import 'constants.dart';
import 'debug.dart'; import 'debug.dart';
import 'shadows.dart'; import 'shadows.dart';
import 'theme.dart'; import 'theme.dart';
import 'theme_data.dart';
import 'toggleable.dart'; import 'toggleable.dart';
const double _kTrackHeight = 14.0;
const double _kTrackWidth = 33.0;
const double _kTrackRadius = _kTrackHeight / 2.0;
const double _kThumbRadius = 10.0;
const double _kSwitchWidth = _kTrackWidth - 2 * _kTrackRadius + 2 * kRadialReactionRadius;
const double _kSwitchHeight = 2 * kRadialReactionRadius + 8.0;
const double _kSwitchHeightCollapsed = 2 * kRadialReactionRadius;
/// A material design switch. /// A material design switch.
/// ///
/// Used to toggle the on/off state of a single setting. /// Used to toggle the on/off state of a single setting.
...@@ -63,8 +54,7 @@ class Switch extends StatefulWidget { ...@@ -63,8 +54,7 @@ class Switch extends StatefulWidget {
this.inactiveThumbColor, this.inactiveThumbColor,
this.inactiveTrackColor, this.inactiveTrackColor,
this.activeThumbImage, this.activeThumbImage,
this.inactiveThumbImage, this.inactiveThumbImage
this.materialTapTargetSize,
}) : super(key: key); }) : super(key: key);
/// Whether this switch is on or off. /// Whether this switch is on or off.
...@@ -122,15 +112,6 @@ class Switch extends StatefulWidget { ...@@ -122,15 +112,6 @@ class Switch extends StatefulWidget {
/// An image to use on the thumb of this switch when the switch is off. /// An image to use on the thumb of this switch when the switch is off.
final ImageProvider inactiveThumbImage; final ImageProvider inactiveThumbImage;
/// Configures the minimum size of the tap target.
///
/// Defaults to [ThemeData.materialTapTargetSize].
///
/// See also:
///
/// * [MaterialTapTargetSize], for a description of how this affects tap targets.
final MaterialTapTargetSize materialTapTargetSize;
@override @override
_SwitchState createState() => new _SwitchState(); _SwitchState createState() => new _SwitchState();
...@@ -161,16 +142,6 @@ class _SwitchState extends State<Switch> with TickerProviderStateMixin { ...@@ -161,16 +142,6 @@ class _SwitchState extends State<Switch> with TickerProviderStateMixin {
inactiveThumbColor = widget.inactiveThumbColor ?? (isDark ? Colors.grey.shade800 : Colors.grey.shade400); inactiveThumbColor = widget.inactiveThumbColor ?? (isDark ? Colors.grey.shade800 : Colors.grey.shade400);
inactiveTrackColor = widget.inactiveTrackColor ?? (isDark ? Colors.white10 : Colors.black12); inactiveTrackColor = widget.inactiveTrackColor ?? (isDark ? Colors.white10 : Colors.black12);
} }
Size size;
switch (widget.materialTapTargetSize ?? themeData.materialTapTargetSize) {
case MaterialTapTargetSize.padded:
size = const Size(_kSwitchWidth, _kSwitchHeight);
break;
case MaterialTapTargetSize.shrinkWrap:
size = const Size(_kSwitchWidth, _kSwitchHeightCollapsed);
break;
}
final BoxConstraints additionalConstraints = new BoxConstraints.tight(size);
return new _SwitchRenderObjectWidget( return new _SwitchRenderObjectWidget(
value: widget.value, value: widget.value,
...@@ -182,7 +153,6 @@ class _SwitchState extends State<Switch> with TickerProviderStateMixin { ...@@ -182,7 +153,6 @@ class _SwitchState extends State<Switch> with TickerProviderStateMixin {
inactiveTrackColor: inactiveTrackColor, inactiveTrackColor: inactiveTrackColor,
configuration: createLocalImageConfiguration(context), configuration: createLocalImageConfiguration(context),
onChanged: widget.onChanged, onChanged: widget.onChanged,
additionalConstraints: additionalConstraints,
vsync: this, vsync: this,
); );
} }
...@@ -201,7 +171,6 @@ class _SwitchRenderObjectWidget extends LeafRenderObjectWidget { ...@@ -201,7 +171,6 @@ class _SwitchRenderObjectWidget extends LeafRenderObjectWidget {
this.configuration, this.configuration,
this.onChanged, this.onChanged,
this.vsync, this.vsync,
this.additionalConstraints,
}) : super(key: key); }) : super(key: key);
final bool value; final bool value;
...@@ -214,7 +183,6 @@ class _SwitchRenderObjectWidget extends LeafRenderObjectWidget { ...@@ -214,7 +183,6 @@ class _SwitchRenderObjectWidget extends LeafRenderObjectWidget {
final ImageConfiguration configuration; final ImageConfiguration configuration;
final ValueChanged<bool> onChanged; final ValueChanged<bool> onChanged;
final TickerProvider vsync; final TickerProvider vsync;
final BoxConstraints additionalConstraints;
@override @override
_RenderSwitch createRenderObject(BuildContext context) { _RenderSwitch createRenderObject(BuildContext context) {
...@@ -229,7 +197,6 @@ class _SwitchRenderObjectWidget extends LeafRenderObjectWidget { ...@@ -229,7 +197,6 @@ class _SwitchRenderObjectWidget extends LeafRenderObjectWidget {
configuration: configuration, configuration: configuration,
onChanged: onChanged, onChanged: onChanged,
textDirection: Directionality.of(context), textDirection: Directionality.of(context),
additionalConstraints: additionalConstraints,
vsync: vsync, vsync: vsync,
); );
} }
...@@ -247,11 +214,17 @@ class _SwitchRenderObjectWidget extends LeafRenderObjectWidget { ...@@ -247,11 +214,17 @@ class _SwitchRenderObjectWidget extends LeafRenderObjectWidget {
..configuration = configuration ..configuration = configuration
..onChanged = onChanged ..onChanged = onChanged
..textDirection = Directionality.of(context) ..textDirection = Directionality.of(context)
..additionalConstraints = additionalConstraints
..vsync = vsync; ..vsync = vsync;
} }
} }
const double _kTrackHeight = 14.0;
const double _kTrackWidth = 33.0;
const double _kTrackRadius = _kTrackHeight / 2.0;
const double _kThumbRadius = 10.0;
const double _kSwitchWidth = _kTrackWidth - 2 * _kTrackRadius + 2 * kRadialReactionRadius;
const double _kSwitchHeight = 2 * kRadialReactionRadius;
class _RenderSwitch extends RenderToggleable { class _RenderSwitch extends RenderToggleable {
_RenderSwitch({ _RenderSwitch({
bool value, bool value,
...@@ -262,7 +235,6 @@ class _RenderSwitch extends RenderToggleable { ...@@ -262,7 +235,6 @@ class _RenderSwitch extends RenderToggleable {
Color activeTrackColor, Color activeTrackColor,
Color inactiveTrackColor, Color inactiveTrackColor,
ImageConfiguration configuration, ImageConfiguration configuration,
BoxConstraints additionalConstraints,
@required TextDirection textDirection, @required TextDirection textDirection,
ValueChanged<bool> onChanged, ValueChanged<bool> onChanged,
@required TickerProvider vsync, @required TickerProvider vsync,
...@@ -279,7 +251,7 @@ class _RenderSwitch extends RenderToggleable { ...@@ -279,7 +251,7 @@ class _RenderSwitch extends RenderToggleable {
activeColor: activeColor, activeColor: activeColor,
inactiveColor: inactiveColor, inactiveColor: inactiveColor,
onChanged: onChanged, onChanged: onChanged,
additionalConstraints: additionalConstraints, size: const Size(_kSwitchWidth, _kSwitchHeight),
vsync: vsync, vsync: vsync,
) { ) {
_drag = new HorizontalDragGestureRecognizer() _drag = new HorizontalDragGestureRecognizer()
......
...@@ -7,7 +7,6 @@ import 'package:flutter/widgets.dart'; ...@@ -7,7 +7,6 @@ import 'package:flutter/widgets.dart';
import 'list_tile.dart'; import 'list_tile.dart';
import 'switch.dart'; import 'switch.dart';
import 'theme.dart'; import 'theme.dart';
import 'theme_data.dart';
/// A [ListTile] with a [Switch]. In other words, a switch with a label. /// A [ListTile] with a [Switch]. In other words, a switch with a label.
/// ///
...@@ -172,7 +171,6 @@ class SwitchListTile extends StatelessWidget { ...@@ -172,7 +171,6 @@ class SwitchListTile extends StatelessWidget {
activeColor: activeColor, activeColor: activeColor,
activeThumbImage: activeThumbImage, activeThumbImage: activeThumbImage,
inactiveThumbImage: inactiveThumbImage, inactiveThumbImage: inactiveThumbImage,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
); );
return new MergeSemantics( return new MergeSemantics(
child: ListTileTheme.merge( child: ListTileTheme.merge(
......
...@@ -36,42 +36,6 @@ const Color _kLightThemeSplashColor = const Color(0x66C8C8C8); ...@@ -36,42 +36,6 @@ const Color _kLightThemeSplashColor = const Color(0x66C8C8C8);
const Color _kDarkThemeHighlightColor = const Color(0x40CCCCCC); const Color _kDarkThemeHighlightColor = const Color(0x40CCCCCC);
const Color _kDarkThemeSplashColor = const Color(0x40CCCCCC); const Color _kDarkThemeSplashColor = const Color(0x40CCCCCC);
/// Configures the tap target and layout size of certain Material widgets.
///
/// Changing the value in [ThemeData.materialTapTargetSize] will affect the
/// accessibility experience.
///
/// Some of the impacted widgets include:
///
/// * [FloatingActionButton], only the mini tap target size is increased.
/// * [MaterialButton]
/// * [OutlineButton]
/// * [FlatButton]
/// * [RaisedButton]
/// * [TimePicker]
/// * [SnackBar]
/// * [Chip]
/// * [RawChip]
/// * [InputChip]
/// * [ChoiceChip]
/// * [FilterChip]
/// * [ActionChip]
/// * [Radio]
/// * [Switch]
/// * [Checkbox]
enum MaterialTapTargetSize {
/// Expands the minimum tap target size to 48px by 48px.
///
/// This is the default value of [ThemeData.materialHitTestSize] and the
/// recommended size to conform to Android accessibility scanner
/// recommendations.
padded,
/// Shrinks the tap target size to the minimum provided by the Material
/// specification.
shrinkWrap,
}
/// Holds the color and typography values for a material design theme. /// Holds the color and typography values for a material design theme.
/// ///
/// Use this class to configure a [Theme] widget. /// Use this class to configure a [Theme] widget.
...@@ -141,9 +105,7 @@ class ThemeData extends Diagnosticable { ...@@ -141,9 +105,7 @@ class ThemeData extends Diagnosticable {
SliderThemeData sliderTheme, SliderThemeData sliderTheme,
ChipThemeData chipTheme, ChipThemeData chipTheme,
TargetPlatform platform, TargetPlatform platform,
MaterialTapTargetSize materialTapTargetSize,
}) { }) {
materialTapTargetSize ??= MaterialTapTargetSize.padded;
brightness ??= Brightness.light; brightness ??= Brightness.light;
final bool isDark = brightness == Brightness.dark; final bool isDark = brightness == Brightness.dark;
primarySwatch ??= Colors.blue; primarySwatch ??= Colors.blue;
...@@ -246,7 +208,6 @@ class ThemeData extends Diagnosticable { ...@@ -246,7 +208,6 @@ class ThemeData extends Diagnosticable {
sliderTheme: sliderTheme, sliderTheme: sliderTheme,
chipTheme: chipTheme, chipTheme: chipTheme,
platform: platform, platform: platform,
materialTapTargetSize: materialTapTargetSize,
); );
} }
...@@ -296,7 +257,6 @@ class ThemeData extends Diagnosticable { ...@@ -296,7 +257,6 @@ class ThemeData extends Diagnosticable {
@required this.sliderTheme, @required this.sliderTheme,
@required this.chipTheme, @required this.chipTheme,
@required this.platform, @required this.platform,
@required this.materialTapTargetSize,
}) : assert(brightness != null), }) : assert(brightness != null),
assert(primaryColor != null), assert(primaryColor != null),
assert(primaryColorBrightness != null), assert(primaryColorBrightness != null),
...@@ -334,8 +294,7 @@ class ThemeData extends Diagnosticable { ...@@ -334,8 +294,7 @@ class ThemeData extends Diagnosticable {
assert(accentIconTheme != null), assert(accentIconTheme != null),
assert(sliderTheme != null), assert(sliderTheme != null),
assert(chipTheme != null), assert(chipTheme != null),
assert(platform != null), assert(platform != null);
assert(materialTapTargetSize != null);
/// A default light blue theme. /// A default light blue theme.
/// ///
...@@ -524,9 +483,6 @@ class ThemeData extends Diagnosticable { ...@@ -524,9 +483,6 @@ class ThemeData extends Diagnosticable {
/// Defaults to the current platform. /// Defaults to the current platform.
final TargetPlatform platform; final TargetPlatform platform;
/// Configures the hit test size of certain Material widgets.
final MaterialTapTargetSize materialTapTargetSize;
/// Creates a copy of this theme but with the given fields replaced with the new values. /// Creates a copy of this theme but with the given fields replaced with the new values.
ThemeData copyWith({ ThemeData copyWith({
Brightness brightness, Brightness brightness,
...@@ -568,7 +524,6 @@ class ThemeData extends Diagnosticable { ...@@ -568,7 +524,6 @@ class ThemeData extends Diagnosticable {
SliderThemeData sliderTheme, SliderThemeData sliderTheme,
ChipThemeData chipTheme, ChipThemeData chipTheme,
TargetPlatform platform, TargetPlatform platform,
MaterialTapTargetSize materialTapTargetSize,
}) { }) {
return new ThemeData.raw( return new ThemeData.raw(
brightness: brightness ?? this.brightness, brightness: brightness ?? this.brightness,
...@@ -610,7 +565,6 @@ class ThemeData extends Diagnosticable { ...@@ -610,7 +565,6 @@ class ThemeData extends Diagnosticable {
sliderTheme: sliderTheme ?? this.sliderTheme, sliderTheme: sliderTheme ?? this.sliderTheme,
chipTheme: chipTheme ?? this.chipTheme, chipTheme: chipTheme ?? this.chipTheme,
platform: platform ?? this.platform, platform: platform ?? this.platform,
materialTapTargetSize: materialTapTargetSize ?? this.materialTapTargetSize,
); );
} }
...@@ -738,7 +692,6 @@ class ThemeData extends Diagnosticable { ...@@ -738,7 +692,6 @@ class ThemeData extends Diagnosticable {
sliderTheme: SliderThemeData.lerp(a.sliderTheme, b.sliderTheme, t), sliderTheme: SliderThemeData.lerp(a.sliderTheme, b.sliderTheme, t),
chipTheme: ChipThemeData.lerp(a.chipTheme, b.chipTheme, t), chipTheme: ChipThemeData.lerp(a.chipTheme, b.chipTheme, t),
platform: t < 0.5 ? a.platform : b.platform, platform: t < 0.5 ? a.platform : b.platform,
materialTapTargetSize: t < 0.5 ? a.materialTapTargetSize : b.materialTapTargetSize,
); );
} }
...@@ -783,8 +736,7 @@ class ThemeData extends Diagnosticable { ...@@ -783,8 +736,7 @@ class ThemeData extends Diagnosticable {
(otherData.accentIconTheme == accentIconTheme) && (otherData.accentIconTheme == accentIconTheme) &&
(otherData.sliderTheme == sliderTheme) && (otherData.sliderTheme == sliderTheme) &&
(otherData.chipTheme == chipTheme) && (otherData.chipTheme == chipTheme) &&
(otherData.platform == platform) && (otherData.platform == platform);
(otherData.materialTapTargetSize == materialTapTargetSize);
} }
@override @override
...@@ -828,7 +780,6 @@ class ThemeData extends Diagnosticable { ...@@ -828,7 +780,6 @@ class ThemeData extends Diagnosticable {
sliderTheme, sliderTheme,
chipTheme, chipTheme,
platform, platform,
materialTapTargetSize
), ),
); );
} }
...@@ -873,7 +824,6 @@ class ThemeData extends Diagnosticable { ...@@ -873,7 +824,6 @@ class ThemeData extends Diagnosticable {
properties.add(new DiagnosticsProperty<IconThemeData>('accentIconTheme', accentIconTheme)); properties.add(new DiagnosticsProperty<IconThemeData>('accentIconTheme', accentIconTheme));
properties.add(new DiagnosticsProperty<SliderThemeData>('sliderTheme', sliderTheme)); properties.add(new DiagnosticsProperty<SliderThemeData>('sliderTheme', sliderTheme));
properties.add(new DiagnosticsProperty<ChipThemeData>('chipTheme', chipTheme)); properties.add(new DiagnosticsProperty<ChipThemeData>('chipTheme', chipTheme));
properties.add(new DiagnosticsProperty<MaterialTapTargetSize>('materialTapTargetSize', materialTapTargetSize));
} }
} }
......
...@@ -17,7 +17,6 @@ import 'feedback.dart'; ...@@ -17,7 +17,6 @@ import 'feedback.dart';
import 'flat_button.dart'; import 'flat_button.dart';
import 'material_localizations.dart'; import 'material_localizations.dart';
import 'theme.dart'; import 'theme.dart';
import 'theme_data.dart';
import 'time.dart'; import 'time.dart';
import 'typography.dart'; import 'typography.dart';
...@@ -30,15 +29,11 @@ enum _TimePickerMode { hour, minute } ...@@ -30,15 +29,11 @@ enum _TimePickerMode { hour, minute }
const double _kTimePickerHeaderPortraitHeight = 96.0; const double _kTimePickerHeaderPortraitHeight = 96.0;
const double _kTimePickerHeaderLandscapeWidth = 168.0; const double _kTimePickerHeaderLandscapeWidth = 168.0;
const double _kTimePickerWidthPortrait = 328.0; const double _kTimePickerWidthPortrait = 328.0;
const double _kTimePickerWidthLandscape = 512.0; const double _kTimePickerWidthLandscape = 512.0;
const double _kTimePickerHeightPortrait = 496.0; const double _kTimePickerHeightPortrait = 484.0;
const double _kTimePickerHeightLandscape = 316.0; const double _kTimePickerHeightLandscape = 304.0;
const double _kTimePickerHeightPortraitCollapsed = 484.0;
const double _kTimePickerHeightLandscapeCollapsed = 304.0;
/// The horizontal gap between the day period fragment and the fragment /// The horizontal gap between the day period fragment and the fragment
/// positioned next to it horizontally. /// positioned next to it horizontally.
...@@ -1580,25 +1575,12 @@ class _TimePickerDialogState extends State<_TimePickerDialog> { ...@@ -1580,25 +1575,12 @@ class _TimePickerDialogState extends State<_TimePickerDialog> {
), ),
); );
double timePickerHeightPortrait;
double timePickerHeightLandscape;
switch (theme.materialTapTargetSize) {
case MaterialTapTargetSize.padded:
timePickerHeightPortrait = _kTimePickerHeightPortrait;
timePickerHeightLandscape = _kTimePickerHeightLandscape;
break;
case MaterialTapTargetSize.shrinkWrap:
timePickerHeightPortrait = _kTimePickerHeightPortraitCollapsed;
timePickerHeightLandscape = _kTimePickerHeightLandscapeCollapsed;
break;
}
assert(orientation != null); assert(orientation != null);
switch (orientation) { switch (orientation) {
case Orientation.portrait: case Orientation.portrait:
return new SizedBox( return new SizedBox(
width: _kTimePickerWidthPortrait, width: _kTimePickerWidthPortrait,
height: timePickerHeightPortrait, height: _kTimePickerHeightPortrait,
child: new Column( child: new Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
...@@ -1613,7 +1595,7 @@ class _TimePickerDialogState extends State<_TimePickerDialog> { ...@@ -1613,7 +1595,7 @@ class _TimePickerDialogState extends State<_TimePickerDialog> {
case Orientation.landscape: case Orientation.landscape:
return new SizedBox( return new SizedBox(
width: _kTimePickerWidthLandscape, width: _kTimePickerWidthLandscape,
height: timePickerHeightLandscape, height: _kTimePickerHeightLandscape,
child: new Row( child: new Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
......
...@@ -26,10 +26,10 @@ abstract class RenderToggleable extends RenderConstrainedBox { ...@@ -26,10 +26,10 @@ abstract class RenderToggleable extends RenderConstrainedBox {
RenderToggleable({ RenderToggleable({
@required bool value, @required bool value,
bool tristate = false, bool tristate = false,
Size size,
@required Color activeColor, @required Color activeColor,
@required Color inactiveColor, @required Color inactiveColor,
ValueChanged<bool> onChanged, ValueChanged<bool> onChanged,
BoxConstraints additionalConstraints,
@required TickerProvider vsync, @required TickerProvider vsync,
}) : assert(tristate != null), }) : assert(tristate != null),
assert(tristate || value != null), assert(tristate || value != null),
...@@ -42,7 +42,7 @@ abstract class RenderToggleable extends RenderConstrainedBox { ...@@ -42,7 +42,7 @@ abstract class RenderToggleable extends RenderConstrainedBox {
_inactiveColor = inactiveColor, _inactiveColor = inactiveColor,
_onChanged = onChanged, _onChanged = onChanged,
_vsync = vsync, _vsync = vsync,
super(additionalConstraints: additionalConstraints) { super(additionalConstraints: new BoxConstraints.tight(size)) {
_tap = new TapGestureRecognizer() _tap = new TapGestureRecognizer()
..onTapDown = _handleTapDown ..onTapDown = _handleTapDown
..onTap = _handleTap ..onTap = _handleTap
......
...@@ -39,8 +39,8 @@ void main() { ...@@ -39,8 +39,8 @@ void main() {
SemanticsAction.tap, SemanticsAction.tap,
], ],
label: 'ABC', label: 'ABC',
rect: new Rect.fromLTRB(0.0, 0.0, 88.0, 48.0), rect: new Rect.fromLTRB(0.0, 0.0, 88.0, 36.0),
transform: new Matrix4.translationValues(356.0, 276.0, 0.0), transform: new Matrix4.translationValues(356.0, 282.0, 0.0),
flags: <SemanticsFlag>[ flags: <SemanticsFlag>[
SemanticsFlag.isButton, SemanticsFlag.isButton,
SemanticsFlag.hasEnabledState, SemanticsFlag.hasEnabledState,
...@@ -79,8 +79,8 @@ void main() { ...@@ -79,8 +79,8 @@ void main() {
SemanticsAction.tap, SemanticsAction.tap,
], ],
label: 'ABC', label: 'ABC',
rect: new Rect.fromLTRB(0.0, 0.0, 88.0, 48.0), rect: new Rect.fromLTRB(0.0, 0.0, 88.0, 36.0),
transform: new Matrix4.translationValues(356.0, 276.0, 0.0), transform: new Matrix4.translationValues(356.0, 282.0, 0.0),
flags: <SemanticsFlag>[ flags: <SemanticsFlag>[
SemanticsFlag.isButton, SemanticsFlag.isButton,
SemanticsFlag.hasEnabledState, SemanticsFlag.hasEnabledState,
...@@ -113,7 +113,7 @@ void main() { ...@@ -113,7 +113,7 @@ void main() {
), ),
); );
expect(tester.getSize(find.byType(FlatButton)), equals(const Size(88.0, 48.0))); expect(tester.getSize(find.byType(FlatButton)), equals(const Size(88.0, 36.0)));
expect(tester.getSize(find.byType(Text)), equals(const Size(42.0, 14.0))); expect(tester.getSize(find.byType(Text)), equals(const Size(42.0, 14.0)));
// textScaleFactor expands text, but not button. // textScaleFactor expands text, but not button.
...@@ -134,7 +134,7 @@ void main() { ...@@ -134,7 +134,7 @@ void main() {
), ),
); );
expect(tester.getSize(find.byType(FlatButton)), equals(const Size(88.0, 48.0))); expect(tester.getSize(find.byType(FlatButton)), equals(const Size(88.0, 36.0)));
// Scaled text rendering is different on Linux and Mac by one pixel. // Scaled text rendering is different on Linux and Mac by one pixel.
// TODO(#12357): Update this test when text rendering is fixed. // TODO(#12357): Update this test when text rendering is fixed.
expect(tester.getSize(find.byType(Text)).width, isIn(<double>[54.0, 55.0])); expect(tester.getSize(find.byType(Text)).width, isIn(<double>[54.0, 55.0]));
...@@ -162,7 +162,7 @@ void main() { ...@@ -162,7 +162,7 @@ void main() {
// Scaled text rendering is different on Linux and Mac by one pixel. // Scaled text rendering is different on Linux and Mac by one pixel.
// TODO(#12357): Update this test when text rendering is fixed. // TODO(#12357): Update this test when text rendering is fixed.
expect(tester.getSize(find.byType(FlatButton)).width, isIn(<double>[158.0, 159.0])); expect(tester.getSize(find.byType(FlatButton)).width, isIn(<double>[158.0, 159.0]));
expect(tester.getSize(find.byType(FlatButton)).height, equals(48.0)); expect(tester.getSize(find.byType(FlatButton)).height, equals(42.0));
expect(tester.getSize(find.byType(Text)).width, isIn(<double>[126.0, 127.0])); expect(tester.getSize(find.byType(Text)).width, isIn(<double>[126.0, 127.0]));
expect(tester.getSize(find.byType(Text)).height, equals(42.0)); expect(tester.getSize(find.byType(Text)).height, equals(42.0));
}); });
...@@ -187,9 +187,7 @@ void main() { ...@@ -187,9 +187,7 @@ void main() {
new Directionality( new Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: new Theme( child: new Theme(
data: new ThemeData( data: new ThemeData(),
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
child: buttonWidget, child: buttonWidget,
), ),
), ),
...@@ -235,7 +233,6 @@ void main() { ...@@ -235,7 +233,6 @@ void main() {
data: new ThemeData( data: new ThemeData(
highlightColor: themeHighlightColor1, highlightColor: themeHighlightColor1,
splashColor: themeSplashColor1, splashColor: themeSplashColor1,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
), ),
child: buttonWidget, child: buttonWidget,
), ),
...@@ -263,7 +260,6 @@ void main() { ...@@ -263,7 +260,6 @@ void main() {
data: new ThemeData( data: new ThemeData(
highlightColor: themeHighlightColor2, highlightColor: themeHighlightColor2,
splashColor: themeSplashColor2, splashColor: themeSplashColor2,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
), ),
child: buttonWidget, // same widget, so does not get updated because of us child: buttonWidget, // same widget, so does not get updated because of us
), ),
...@@ -283,7 +279,7 @@ void main() { ...@@ -283,7 +279,7 @@ void main() {
testWidgets('Disabled MaterialButton has same semantic size as enabled and exposes disabled semantics', (WidgetTester tester) async { testWidgets('Disabled MaterialButton has same semantic size as enabled and exposes disabled semantics', (WidgetTester tester) async {
final SemanticsTester semantics = new SemanticsTester(tester); final SemanticsTester semantics = new SemanticsTester(tester);
final Rect expectedButtonSize = new Rect.fromLTRB(0.0, 0.0, 116.0, 48.0); final Rect expectedButtonSize = new Rect.fromLTRB(0.0, 0.0, 116.0, 36.0);
// Button is in center of screen // Button is in center of screen
final Matrix4 expectedButtonTransform = new Matrix4.identity() final Matrix4 expectedButtonTransform = new Matrix4.identity()
..translate( ..translate(
...@@ -358,136 +354,4 @@ void main() { ...@@ -358,136 +354,4 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgets('MaterialButton size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async {
final Key key1 = new UniqueKey();
await tester.pumpWidget(
new Theme(
data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.padded),
child: new Directionality(
textDirection: TextDirection.ltr,
child: new Material(
child: new Center(
child: new MaterialButton(
key: key1,
child: const SizedBox(width: 50.0, height: 8.0),
onPressed: () {},
),
),
),
),
),
);
expect(tester.getSize(find.byKey(key1)), const Size(88.0, 48.0));
final Key key2 = new UniqueKey();
await tester.pumpWidget(
new Theme(
data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap),
child: new Directionality(
textDirection: TextDirection.ltr,
child: new Material(
child: new Center(
child: new MaterialButton(
key: key2,
child: const SizedBox(width: 50.0, height: 8.0),
onPressed: () {},
),
),
),
),
),
);
expect(tester.getSize(find.byKey(key2)), const Size(88.0, 36.0));
});
testWidgets('FlatButton size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async {
final Key key1 = new UniqueKey();
await tester.pumpWidget(
new Theme(
data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.padded),
child: new Directionality(
textDirection: TextDirection.ltr,
child: new Material(
child: new Center(
child: new FlatButton(
key: key1,
child: const SizedBox(width: 50.0, height: 8.0),
onPressed: () {},
),
),
),
),
),
);
expect(tester.getSize(find.byKey(key1)), const Size(88.0, 48.0));
final Key key2 = new UniqueKey();
await tester.pumpWidget(
new Theme(
data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap),
child: new Directionality(
textDirection: TextDirection.ltr,
child: new Material(
child: new Center(
child: new FlatButton(
key: key2,
child: const SizedBox(width: 50.0, height: 8.0),
onPressed: () {},
),
),
),
),
),
);
expect(tester.getSize(find.byKey(key2)), const Size(88.0, 36.0));
});
testWidgets('RaisedButton size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async {
final Key key1 = new UniqueKey();
await tester.pumpWidget(
new Theme(
data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.padded),
child: new Directionality(
textDirection: TextDirection.ltr,
child: new Material(
child: new Center(
child: new RaisedButton(
key: key1,
child: const SizedBox(width: 50.0, height: 8.0),
onPressed: () {},
),
),
),
),
),
);
expect(tester.getSize(find.byKey(key1)), const Size(88.0, 48.0));
final Key key2 = new UniqueKey();
await tester.pumpWidget(
new Theme(
data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap),
child: new Directionality(
textDirection: TextDirection.ltr,
child: new Material(
child: new Center(
child: new RaisedButton(
key: key2,
child: const SizedBox(width: 50.0, height: 8.0),
onPressed: () {},
),
),
),
),
),
);
expect(tester.getSize(find.byKey(key2)), const Size(88.0, 36.0));
});
} }
...@@ -16,38 +16,13 @@ void main() { ...@@ -16,38 +16,13 @@ void main() {
debugResetSemanticsIdCounter(); debugResetSemanticsIdCounter();
}); });
testWidgets('Checkbox size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async { testWidgets('Checkbox size is 40x40', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new Theme( new Material(
data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.padded), child: new Center(
child: new Directionality( child: new Checkbox(
textDirection: TextDirection.ltr, value: false,
child: new Material( onChanged: (bool newValue) { },
child: new Center(
child: new Checkbox(
value: true,
onChanged: (bool newValue) {},
),
),
),
),
),
);
expect(tester.getSize(find.byType(Checkbox)), const Size(48.0, 48.0));
await tester.pumpWidget(
new Theme(
data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap),
child: new Directionality(
textDirection: TextDirection.ltr,
child: new Material(
child: new Center(
child: new Checkbox(
value: true,
onChanged: (bool newValue) {},
),
),
), ),
), ),
), ),
......
...@@ -4,13 +4,11 @@ ...@@ -4,13 +4,11 @@
import 'dart:ui' show window; import 'dart:ui' show window;
import 'package:flutter/semantics.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
import '../rendering/mock_canvas.dart'; import '../rendering/mock_canvas.dart';
import '../widgets/semantics_tester.dart';
import 'feedback_tester.dart'; import 'feedback_tester.dart';
Finder findRenderChipElement() { Finder findRenderChipElement() {
...@@ -251,7 +249,7 @@ void main() { ...@@ -251,7 +249,7 @@ void main() {
), ),
); );
expect(tester.getSize(find.byType(Text)), const Size(40.0, 10.0)); expect(tester.getSize(find.byType(Text)), const Size(40.0, 10.0));
expect(tester.getSize(find.byType(Chip)), const Size(64.0,48.0)); expect(tester.getSize(find.byType(Chip)), const Size(64.0, 32.0));
await tester.pumpWidget( await tester.pumpWidget(
_wrapForChip( _wrapForChip(
child: new Row( child: new Row(
...@@ -262,7 +260,7 @@ void main() { ...@@ -262,7 +260,7 @@ void main() {
), ),
); );
expect(tester.getSize(find.byType(Text)), const Size(40.0, 10.0)); expect(tester.getSize(find.byType(Text)), const Size(40.0, 10.0));
expect(tester.getSize(find.byType(Chip)), const Size(64.0, 48.0)); expect(tester.getSize(find.byType(Chip)), const Size(64.0, 32.0));
await tester.pumpWidget( await tester.pumpWidget(
_wrapForChip( _wrapForChip(
child: new Row( child: new Row(
...@@ -273,7 +271,7 @@ void main() { ...@@ -273,7 +271,7 @@ void main() {
), ),
); );
expect(tester.getSize(find.byType(Text)), const Size(40.0, 10.0)); expect(tester.getSize(find.byType(Text)), const Size(40.0, 10.0));
expect(tester.getSize(find.byType(Chip)), const Size(800.0, 48.0)); expect(tester.getSize(find.byType(Chip)), const Size(800.0, 32.0));
}); });
testWidgets('Chip elements are ordered horizontally for locale', (WidgetTester tester) async { testWidgets('Chip elements are ordered horizontally for locale', (WidgetTester tester) async {
...@@ -340,8 +338,8 @@ void main() { ...@@ -340,8 +338,8 @@ void main() {
tester.getSize(find.text('Chip B')), tester.getSize(find.text('Chip B')),
anyOf(const Size(84.0, 14.0), const Size(83.0, 14.0)), anyOf(const Size(84.0, 14.0), const Size(83.0, 14.0)),
); );
expect(tester.getSize(find.byType(Chip).first), anyOf(const Size(132.0, 48.0), const Size(131.0, 48.0))); expect(tester.getSize(find.byType(Chip).first), anyOf(const Size(132.0, 32.0), const Size(131.0, 32.0)));
expect(tester.getSize(find.byType(Chip).last), anyOf(const Size(132.0, 48.0), const Size(131.0, 48.0))); expect(tester.getSize(find.byType(Chip).last), anyOf(const Size(132.0, 32.0), const Size(131.0, 32.0)));
await tester.pumpWidget( await tester.pumpWidget(
_wrapForChip( _wrapForChip(
...@@ -394,7 +392,7 @@ void main() { ...@@ -394,7 +392,7 @@ void main() {
expect(tester.getSize(find.text('Chip B')), anyOf(const Size(84.0, 14.0), const Size(83.0, 14.0))); expect(tester.getSize(find.text('Chip B')), anyOf(const Size(84.0, 14.0), const Size(83.0, 14.0)));
expect(tester.getSize(find.byType(Chip).first).width, anyOf(318.0, 319.0)); expect(tester.getSize(find.byType(Chip).first).width, anyOf(318.0, 319.0));
expect(tester.getSize(find.byType(Chip).first).height, equals(50.0)); expect(tester.getSize(find.byType(Chip).first).height, equals(50.0));
expect(tester.getSize(find.byType(Chip).last), anyOf(const Size(132.0, 48.0), const Size(131.0, 48.0))); expect(tester.getSize(find.byType(Chip).last), anyOf(const Size(132.0, 32.0), const Size(131.0, 32.0)));
}); });
testWidgets('Labels can be non-text widgets', (WidgetTester tester) async { testWidgets('Labels can be non-text widgets', (WidgetTester tester) async {
...@@ -426,9 +424,9 @@ void main() { ...@@ -426,9 +424,9 @@ void main() {
expect(tester.getSize(find.byKey(keyB)), const Size(10.0, 10.0)); expect(tester.getSize(find.byKey(keyB)), const Size(10.0, 10.0));
expect( expect(
tester.getSize(find.byType(Chip).first), tester.getSize(find.byType(Chip).first),
anyOf(const Size(132.0, 48.0), const Size(131.0, 48.0)), anyOf(const Size(132.0, 32.0), const Size(131.0, 32.0)),
); );
expect(tester.getSize(find.byType(Chip).last), const Size(58.0, 48.0)); expect(tester.getSize(find.byType(Chip).last), const Size(58.0, 32.0));
}); });
testWidgets('Avatars can be non-circle avatar widgets', (WidgetTester tester) async { testWidgets('Avatars can be non-circle avatar widgets', (WidgetTester tester) async {
...@@ -563,7 +561,7 @@ void main() { ...@@ -563,7 +561,7 @@ void main() {
// No avatar // No avatar
await pushChip(); await pushChip();
expect(tester.getSize(find.byType(RawChip)), equals(const Size(80.0, 48.0))); expect(tester.getSize(find.byType(RawChip)), equals(const Size(80.0, 32.0)));
final GlobalKey avatarKey = new GlobalKey(); final GlobalKey avatarKey = new GlobalKey();
// Add an avatar // Add an avatar
...@@ -576,10 +574,10 @@ void main() { ...@@ -576,10 +574,10 @@ void main() {
), ),
); );
// Avatar drawer should start out closed. // Avatar drawer should start out closed.
expect(tester.getSize(find.byType(RawChip)), equals(const Size(80.0, 48.0))); expect(tester.getSize(find.byType(RawChip)), equals(const Size(80.0, 32.0)));
expect(tester.getSize(find.byKey(avatarKey)), equals(const Size(24.0, 24.0))); expect(tester.getSize(find.byKey(avatarKey)), equals(const Size(24.0, 24.0)));
expect(tester.getTopLeft(find.byKey(avatarKey)), equals(const Offset(-20.0, 12.0))); expect(tester.getTopLeft(find.byKey(avatarKey)), equals(const Offset(-20.0, 4.0)));
expect(tester.getTopLeft(find.byKey(labelKey)), equals(const Offset(12.0, 17.0))); expect(tester.getTopLeft(find.byKey(labelKey)), equals(const Offset(12.0, 9.0)));
await tester.pump(const Duration(milliseconds: 20)); await tester.pump(const Duration(milliseconds: 20));
// Avatar drawer should start expanding. // Avatar drawer should start expanding.
...@@ -609,18 +607,18 @@ void main() { ...@@ -609,18 +607,18 @@ void main() {
// Wait for being done with animation, and make sure it didn't change // Wait for being done with animation, and make sure it didn't change
// height. // height.
await tester.pumpAndSettle(const Duration(milliseconds: 200)); await tester.pumpAndSettle(const Duration(milliseconds: 200));
expect(tester.getSize(find.byType(RawChip)), equals(const Size(104.0, 48.0))); expect(tester.getSize(find.byType(RawChip)), equals(const Size(104.0, 32.0)));
expect(tester.getSize(find.byKey(avatarKey)), equals(const Size(24.0, 24.0))); expect(tester.getSize(find.byKey(avatarKey)), equals(const Size(24.0, 24.0)));
expect(tester.getTopLeft(find.byKey(avatarKey)), equals(const Offset(4.0, 12.0))); expect(tester.getTopLeft(find.byKey(avatarKey)), equals(const Offset(4.0, 4.0)));
expect(tester.getTopLeft(find.byKey(labelKey)), equals(const Offset(36.0, 17.0))); expect(tester.getTopLeft(find.byKey(labelKey)), equals(const Offset(36.0, 9.0)));
// Remove the avatar again // Remove the avatar again
await pushChip(); await pushChip();
// Avatar drawer should start out open. // Avatar drawer should start out open.
expect(tester.getSize(find.byType(RawChip)), equals(const Size(104.0, 48.0))); expect(tester.getSize(find.byType(RawChip)), equals(const Size(104.0, 32.0)));
expect(tester.getSize(find.byKey(avatarKey)), equals(const Size(24.0, 24.0))); expect(tester.getSize(find.byKey(avatarKey)), equals(const Size(24.0, 24.0)));
expect(tester.getTopLeft(find.byKey(avatarKey)), equals(const Offset(4.0, 12.0))); expect(tester.getTopLeft(find.byKey(avatarKey)), equals(const Offset(4.0, 4.0)));
expect(tester.getTopLeft(find.byKey(labelKey)), equals(const Offset(36.0, 17.0))); expect(tester.getTopLeft(find.byKey(labelKey)), equals(const Offset(36.0, 9.0)));
await tester.pump(const Duration(milliseconds: 20)); await tester.pump(const Duration(milliseconds: 20));
// Avatar drawer should start contracting. // Avatar drawer should start contracting.
...@@ -650,8 +648,8 @@ void main() { ...@@ -650,8 +648,8 @@ void main() {
// Wait for being done with animation, make sure it didn't change // Wait for being done with animation, make sure it didn't change
// height, and make sure that the avatar is no longer drawn. // height, and make sure that the avatar is no longer drawn.
await tester.pumpAndSettle(const Duration(milliseconds: 200)); await tester.pumpAndSettle(const Duration(milliseconds: 200));
expect(tester.getSize(find.byType(RawChip)), equals(const Size(80.0, 48.0))); expect(tester.getSize(find.byType(RawChip)), equals(const Size(80.0, 32.0)));
expect(tester.getTopLeft(find.byKey(labelKey)), equals(const Offset(12.0, 17.0))); expect(tester.getTopLeft(find.byKey(labelKey)), equals(const Offset(12.0, 9.0)));
expect(find.byKey(avatarKey), findsNothing); expect(find.byKey(avatarKey), findsNothing);
}); });
...@@ -686,22 +684,22 @@ void main() { ...@@ -686,22 +684,22 @@ void main() {
// No delete button // No delete button
await pushChip(); await pushChip();
expect(tester.getSize(find.byType(RawChip)), equals(const Size(80.0, 48.0))); expect(tester.getSize(find.byType(RawChip)), equals(const Size(80.0, 32.0)));
// Add a delete button // Add a delete button
await pushChip(deletable: true); await pushChip(deletable: true);
// Delete button drawer should start out closed. // Delete button drawer should start out closed.
expect(tester.getSize(find.byType(RawChip)), equals(const Size(80.0, 48.0))); expect(tester.getSize(find.byType(RawChip)), equals(const Size(80.0, 32.0)));
expect(tester.getSize(find.byKey(deleteButtonKey)), equals(const Size(24.0, 24.0))); expect(tester.getSize(find.byKey(deleteButtonKey)), equals(const Size(24.0, 24.0)));
expect(tester.getTopLeft(find.byKey(deleteButtonKey)), equals(const Offset(52.0, 12.0))); expect(tester.getTopLeft(find.byKey(deleteButtonKey)), equals(const Offset(52.0, 4.0)));
expect(tester.getTopLeft(find.byKey(labelKey)), equals(const Offset(12.0, 17.0))); expect(tester.getTopLeft(find.byKey(labelKey)), equals(const Offset(12.0, 9.0)));
await tester.pump(const Duration(milliseconds: 20)); await tester.pump(const Duration(milliseconds: 20));
// Delete button drawer should start expanding. // Delete button drawer should start expanding.
expect(tester.getSize(find.byType(RawChip)).width, closeTo(81.2, 0.1)); expect(tester.getSize(find.byType(RawChip)).width, closeTo(81.2, 0.1));
expect(tester.getSize(find.byKey(deleteButtonKey)), equals(const Size(24.0, 24.0))); expect(tester.getSize(find.byKey(deleteButtonKey)), equals(const Size(24.0, 24.0)));
expect(tester.getTopLeft(find.byKey(deleteButtonKey)).dx, closeTo(53.2, 0.1)); expect(tester.getTopLeft(find.byKey(deleteButtonKey)).dx, closeTo(53.2, 0.1));
expect(tester.getTopLeft(find.byKey(labelKey)), equals(const Offset(12.0, 17.0))); expect(tester.getTopLeft(find.byKey(labelKey)), equals(const Offset(12.0, 9.0)));
await tester.pump(const Duration(milliseconds: 20)); await tester.pump(const Duration(milliseconds: 20));
expect(tester.getSize(find.byType(RawChip)).width, closeTo(86.7, 0.1)); expect(tester.getSize(find.byType(RawChip)).width, closeTo(86.7, 0.1));
...@@ -721,10 +719,10 @@ void main() { ...@@ -721,10 +719,10 @@ void main() {
// Wait for being done with animation, and make sure it didn't change // Wait for being done with animation, and make sure it didn't change
// height. // height.
await tester.pumpAndSettle(const Duration(milliseconds: 200)); await tester.pumpAndSettle(const Duration(milliseconds: 200));
expect(tester.getSize(find.byType(RawChip)), equals(const Size(104.0, 48.0))); expect(tester.getSize(find.byType(RawChip)), equals(const Size(104.0, 32.0)));
expect(tester.getSize(find.byKey(deleteButtonKey)), equals(const Size(24.0, 24.0))); expect(tester.getSize(find.byKey(deleteButtonKey)), equals(const Size(24.0, 24.0)));
expect(tester.getTopLeft(find.byKey(deleteButtonKey)), equals(const Offset(76.0, 12.0))); expect(tester.getTopLeft(find.byKey(deleteButtonKey)), equals(const Offset(76.0, 4.0)));
expect(tester.getTopLeft(find.byKey(labelKey)), equals(const Offset(12.0, 17.0))); expect(tester.getTopLeft(find.byKey(labelKey)), equals(const Offset(12.0, 9.0)));
// Test the tap work for the delete button, but not the rest of the chip. // Test the tap work for the delete button, but not the rest of the chip.
expect(wasDeleted, isFalse); expect(wasDeleted, isFalse);
...@@ -736,17 +734,17 @@ void main() { ...@@ -736,17 +734,17 @@ void main() {
// Remove the delete button again // Remove the delete button again
await pushChip(); await pushChip();
// Delete button drawer should start out open. // Delete button drawer should start out open.
expect(tester.getSize(find.byType(RawChip)), equals(const Size(104.0, 48.0))); expect(tester.getSize(find.byType(RawChip)), equals(const Size(104.0, 32.0)));
expect(tester.getSize(find.byKey(deleteButtonKey)), equals(const Size(24.0, 24.0))); expect(tester.getSize(find.byKey(deleteButtonKey)), equals(const Size(24.0, 24.0)));
expect(tester.getTopLeft(find.byKey(deleteButtonKey)), equals(const Offset(76.0, 12.0))); expect(tester.getTopLeft(find.byKey(deleteButtonKey)), equals(const Offset(76.0, 4.0)));
expect(tester.getTopLeft(find.byKey(labelKey)), equals(const Offset(12.0, 17.0))); expect(tester.getTopLeft(find.byKey(labelKey)), equals(const Offset(12.0, 9.0)));
await tester.pump(const Duration(milliseconds: 20)); await tester.pump(const Duration(milliseconds: 20));
// Delete button drawer should start contracting. // Delete button drawer should start contracting.
expect(tester.getSize(find.byType(RawChip)).width, closeTo(103.8, 0.1)); expect(tester.getSize(find.byType(RawChip)).width, closeTo(103.8, 0.1));
expect(tester.getSize(find.byKey(deleteButtonKey)), equals(const Size(24.0, 24.0))); expect(tester.getSize(find.byKey(deleteButtonKey)), equals(const Size(24.0, 24.0)));
expect(tester.getTopLeft(find.byKey(deleteButtonKey)).dx, closeTo(75.8, 0.1)); expect(tester.getTopLeft(find.byKey(deleteButtonKey)).dx, closeTo(75.8, 0.1));
expect(tester.getTopLeft(find.byKey(labelKey)), equals(const Offset(12.0, 17.0))); expect(tester.getTopLeft(find.byKey(labelKey)), equals(const Offset(12.0, 9.0)));
await tester.pump(const Duration(milliseconds: 20)); await tester.pump(const Duration(milliseconds: 20));
expect(tester.getSize(find.byType(RawChip)).width, closeTo(102.9, 0.1)); expect(tester.getSize(find.byType(RawChip)).width, closeTo(102.9, 0.1));
...@@ -766,8 +764,8 @@ void main() { ...@@ -766,8 +764,8 @@ void main() {
// Wait for being done with animation, make sure it didn't change // Wait for being done with animation, make sure it didn't change
// height, and make sure that the delete button is no longer drawn. // height, and make sure that the delete button is no longer drawn.
await tester.pumpAndSettle(const Duration(milliseconds: 200)); await tester.pumpAndSettle(const Duration(milliseconds: 200));
expect(tester.getSize(find.byType(RawChip)), equals(const Size(80.0, 48.0))); expect(tester.getSize(find.byType(RawChip)), equals(const Size(80.0, 32.0)));
expect(tester.getTopLeft(find.byKey(labelKey)), equals(const Offset(12.0, 17.0))); expect(tester.getTopLeft(find.byKey(labelKey)), equals(const Offset(12.0, 9.0)));
expect(find.byKey(deleteButtonKey), findsNothing); expect(find.byKey(deleteButtonKey), findsNothing);
}); });
...@@ -808,7 +806,7 @@ void main() { ...@@ -808,7 +806,7 @@ void main() {
await pushChip( await pushChip(
avatar: new Container(width: 40.0, height: 40.0, key: avatarKey), avatar: new Container(width: 40.0, height: 40.0, key: avatarKey),
); );
expect(tester.getSize(find.byType(RawChip)), equals(const Size(104.0, 48.0))); expect(tester.getSize(find.byType(RawChip)), equals(const Size(104.0, 32.0)));
// Turn on selection. // Turn on selection.
await pushChip( await pushChip(
...@@ -887,7 +885,7 @@ void main() { ...@@ -887,7 +885,7 @@ void main() {
// Without avatar, but not selectable. // Without avatar, but not selectable.
await pushChip(); await pushChip();
expect(tester.getSize(find.byType(RawChip)), equals(const Size(80.0, 48.0))); expect(tester.getSize(find.byType(RawChip)), equals(const Size(80.0, 32.0)));
// Turn on selection. // Turn on selection.
await pushChip(selectable: true); await pushChip(selectable: true);
...@@ -1019,42 +1017,6 @@ void main() { ...@@ -1019,42 +1017,6 @@ void main() {
expect(materialBox, paints..path(color: chipTheme.disabledColor)); expect(materialBox, paints..path(color: chipTheme.disabledColor));
}); });
testWidgets('Chip size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async {
final Key key1 = new UniqueKey();
await tester.pumpWidget(
_wrapForChip(
child: new Theme(
data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.padded),
child: new Center(
child: new RawChip(
key: key1,
label: const Text('test'),
),
),
),
),
);
expect(tester.getSize(find.byKey(key1)), const Size(80.0, 48.0));
final Key key2 = new UniqueKey();
await tester.pumpWidget(
_wrapForChip(
child: new Theme(
data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap),
child: new Center(
child: new RawChip(
key: key2,
label: const Text('test'),
),
),
),
),
);
expect(tester.getSize(find.byKey(key2)), const Size(80.0, 32.0));
});
testWidgets('Chip uses the right theme colors for the right components', (WidgetTester tester) async { testWidgets('Chip uses the right theme colors for the right components', (WidgetTester tester) async {
final ThemeData themeData = new ThemeData( final ThemeData themeData = new ThemeData(
platform: TargetPlatform.android, platform: TargetPlatform.android,
...@@ -1176,255 +1138,4 @@ void main() { ...@@ -1176,255 +1138,4 @@ void main() {
expect(materialBox, paints..path(color: customTheme.disabledColor)); expect(materialBox, paints..path(color: customTheme.disabledColor));
expect(labelStyle.style.color, equals(Colors.black.withAlpha(0xde))); expect(labelStyle.style.color, equals(Colors.black.withAlpha(0xde)));
}); });
group('Chip semantics', () {
testWidgets('label only', (WidgetTester tester) async {
final SemanticsTester semanticsTester = new SemanticsTester(tester);
await tester.pumpWidget(new MaterialApp(
home: const Material(
child: const RawChip(
label: const Text('test'),
),
),
));
expect(semanticsTester, hasSemantics(
new TestSemantics.root(
children: <TestSemantics>[
new TestSemantics(
textDirection: TextDirection.ltr,
children: <TestSemantics>[
new TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
new TestSemantics(
label: 'test',
textDirection: TextDirection.ltr,
),
],
),
],
),
],
), ignoreTransform: true, ignoreId: true, ignoreRect: true));
semanticsTester.dispose();
});
testWidgets('with onPressed', (WidgetTester tester) async {
final SemanticsTester semanticsTester = new SemanticsTester(tester);
await tester.pumpWidget(new MaterialApp(
home: new Material(
child: new RawChip(
label: const Text('test'),
onPressed: () {},
),
),
));
expect(semanticsTester, hasSemantics(
new TestSemantics.root(
children: <TestSemantics>[
new TestSemantics(
textDirection: TextDirection.ltr,
children: <TestSemantics>[
new TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
new TestSemantics(
label: 'test',
textDirection: TextDirection.ltr,
flags: <SemanticsFlag>[
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
],
actions: <SemanticsAction>[SemanticsAction.tap],
),
],
),
],
),
],
), ignoreTransform: true, ignoreId: true, ignoreRect: true));
semanticsTester.dispose();
});
testWidgets('with onSelected', (WidgetTester tester) async {
final SemanticsTester semanticsTester = new SemanticsTester(tester);
bool selected = false;
await tester.pumpWidget(new MaterialApp(
home: new Material(
child: new RawChip(
isEnabled: true,
label: const Text('test'),
selected: selected,
onSelected: (bool value) {
selected = value;
},
),
),
));
expect(semanticsTester, hasSemantics(
new TestSemantics.root(
children: <TestSemantics>[
new TestSemantics(
textDirection: TextDirection.ltr,
children: <TestSemantics>[
new TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
new TestSemantics(
label: 'test',
textDirection: TextDirection.ltr,
flags: <SemanticsFlag>[
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
],
actions: <SemanticsAction>[SemanticsAction.tap],
),
],
),
],
),
],
), ignoreTransform: true, ignoreId: true, ignoreRect: true));
await tester.tap(find.byType(RawChip));
await tester.pumpWidget(new MaterialApp(
home: new Material(
child: new RawChip(
isEnabled: true,
label: const Text('test'),
selected: selected,
onSelected: (bool value) {
selected = value;
},
),
),
));
expect(selected, true);
expect(semanticsTester, hasSemantics(
new TestSemantics.root(
children: <TestSemantics>[
new TestSemantics(
textDirection: TextDirection.ltr,
children: <TestSemantics>[
new TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
new TestSemantics(
label: 'test',
textDirection: TextDirection.ltr,
flags: <SemanticsFlag>[
SemanticsFlag.isSelected,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
],
actions: <SemanticsAction>[SemanticsAction.tap],
),
],
),
],
),
],
), ignoreTransform: true, ignoreId: true, ignoreRect: true));
semanticsTester.dispose();
});
testWidgets('disabled', (WidgetTester tester) async {
final SemanticsTester semanticsTester = new SemanticsTester(tester);
await tester.pumpWidget(new MaterialApp(
home: new Material(
child: new RawChip(
isEnabled: false,
onPressed: () {},
label: const Text('test'),
),
),
));
expect(semanticsTester, hasSemantics(
new TestSemantics.root(
children: <TestSemantics>[
new TestSemantics(
textDirection: TextDirection.ltr,
children: <TestSemantics>[
new TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
new TestSemantics(
label: 'test',
textDirection: TextDirection.ltr,
flags: <SemanticsFlag>[],
actions: <SemanticsAction>[],
),
],
),
],
),
],
), ignoreTransform: true, ignoreId: true, ignoreRect: true));
semanticsTester.dispose();
});
});
testWidgets('can be tapped outside of chip delete icon', (WidgetTester tester) async {
bool deleted = false;
await tester.pumpWidget(
_wrapForChip(
child: new Row(
children: <Widget>[
new Chip(
materialTapTargetSize: MaterialTapTargetSize.padded,
shape: const RoundedRectangleBorder(borderRadius: const BorderRadius.all(const Radius.circular(0.0))),
avatar: const CircleAvatar(child: const Text('A')),
label: const Text('Chip A'),
onDeleted: () {
deleted = true;
},
deleteIcon: const Icon(Icons.delete),
),
],
),
),
);
await tester.tapAt(tester.getTopRight(find.byType(Chip)) - const Offset(2.0, -2.0));
await tester.pumpAndSettle();
expect(deleted, true);
});
testWidgets('can be tapped outside of chip body', (WidgetTester tester) async {
bool pressed = false;
await tester.pumpWidget(
_wrapForChip(
child: new Row(
children: <Widget>[
new InputChip(
materialTapTargetSize: MaterialTapTargetSize.padded,
shape: const RoundedRectangleBorder(borderRadius: const BorderRadius.all(const Radius.circular(0.0))),
avatar: const CircleAvatar(child: const Text('A')),
label: const Text('Chip A'),
onPressed: () {
pressed = true;
},
),
],
),
),
);
await tester.tapAt(tester.getRect(find.byType(InputChip)).topCenter);
await tester.pumpAndSettle();
expect(pressed, true);
});
} }
...@@ -67,44 +67,6 @@ void main() { ...@@ -67,44 +67,6 @@ void main() {
expect(find.byType(Text), findsOneWidget); expect(find.byType(Text), findsOneWidget);
}); });
testWidgets('FlatActionButton mini size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async {
final Key key1 = new UniqueKey();
await tester.pumpWidget(
new MaterialApp(
home: new Theme(
data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.padded),
child: new Scaffold(
floatingActionButton: new FloatingActionButton(
key: key1,
mini: true,
onPressed: null,
),
),
),
),
);
expect(tester.getSize(find.byKey(key1)), const Size(48.0, 48.0));
final Key key2 = new UniqueKey();
await tester.pumpWidget(
new MaterialApp(
home: new Theme(
data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap),
child: new Scaffold(
floatingActionButton: new FloatingActionButton(
key: key2,
mini: true,
onPressed: null,
),
),
),
),
);
expect(tester.getSize(find.byKey(key2)), const Size(40.0, 40.0));
});
testWidgets('FloatingActionButton.isExtended', (WidgetTester tester) async { testWidgets('FloatingActionButton.isExtended', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new MaterialApp( new MaterialApp(
......
...@@ -55,7 +55,7 @@ void main() { ...@@ -55,7 +55,7 @@ void main() {
new Directionality( new Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: new Theme( child: new Theme(
data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap), data: new ThemeData(),
child: new Container( child: new Container(
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
child: new OutlineButton( child: new OutlineButton(
...@@ -140,8 +140,8 @@ void main() { ...@@ -140,8 +140,8 @@ void main() {
SemanticsAction.tap, SemanticsAction.tap,
], ],
label: 'ABC', label: 'ABC',
rect: new Rect.fromLTRB(0.0, 0.0, 88.0, 48.0), rect: new Rect.fromLTRB(0.0, 0.0, 88.0, 36.0),
transform: new Matrix4.translationValues(356.0, 276.0, 0.0), transform: new Matrix4.translationValues(356.0, 282.0, 0.0),
flags: <SemanticsFlag>[ flags: <SemanticsFlag>[
SemanticsFlag.isButton, SemanticsFlag.isButton,
SemanticsFlag.hasEnabledState, SemanticsFlag.hasEnabledState,
...@@ -175,7 +175,7 @@ void main() { ...@@ -175,7 +175,7 @@ void main() {
), ),
); );
expect(tester.getSize(find.byType(OutlineButton)), equals(const Size(88.0, 48.0))); expect(tester.getSize(find.byType(OutlineButton)), equals(const Size(88.0, 36.0)));
expect(tester.getSize(find.byType(Text)), equals(const Size(42.0, 14.0))); expect(tester.getSize(find.byType(Text)), equals(const Size(42.0, 14.0)));
// textScaleFactor expands text, but not button. // textScaleFactor expands text, but not button.
...@@ -196,7 +196,7 @@ void main() { ...@@ -196,7 +196,7 @@ void main() {
), ),
); );
expect(tester.getSize(find.byType(FlatButton)), equals(const Size(88.0, 48.0))); expect(tester.getSize(find.byType(FlatButton)), equals(const Size(88.0, 36.0)));
// Scaled text rendering is different on Linux and Mac by one pixel. // Scaled text rendering is different on Linux and Mac by one pixel.
// TODO(#12357): Update this test when text rendering is fixed. // TODO(#12357): Update this test when text rendering is fixed.
expect(tester.getSize(find.byType(Text)).width, isIn(<double>[54.0, 55.0])); expect(tester.getSize(find.byType(Text)).width, isIn(<double>[54.0, 55.0]));
...@@ -224,7 +224,7 @@ void main() { ...@@ -224,7 +224,7 @@ void main() {
// Scaled text rendering is different on Linux and Mac by one pixel. // Scaled text rendering is different on Linux and Mac by one pixel.
// TODO(#12357): Update this test when text rendering is fixed. // TODO(#12357): Update this test when text rendering is fixed.
expect(tester.getSize(find.byType(FlatButton)).width, isIn(<double>[158.0, 159.0])); expect(tester.getSize(find.byType(FlatButton)).width, isIn(<double>[158.0, 159.0]));
expect(tester.getSize(find.byType(FlatButton)).height, equals(48.0)); expect(tester.getSize(find.byType(FlatButton)).height, equals(42.0));
expect(tester.getSize(find.byType(Text)).width, isIn(<double>[126.0, 127.0])); expect(tester.getSize(find.byType(Text)).width, isIn(<double>[126.0, 127.0]));
expect(tester.getSize(find.byType(Text)).height, equals(42.0)); expect(tester.getSize(find.byType(Text)).height, equals(42.0));
}); });
......
...@@ -64,50 +64,23 @@ void main() { ...@@ -64,50 +64,23 @@ void main() {
expect(log, isEmpty); expect(log, isEmpty);
}); });
testWidgets('Radio size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async { testWidgets('Radio size is 40x40', (WidgetTester tester) async {
final Key key1 = new UniqueKey(); final Key key = new UniqueKey();
await tester.pumpWidget(
new Theme(
data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.padded),
child: new Directionality(
textDirection: TextDirection.ltr,
child: new Material(
child: new Center(
child: new Radio<bool>(
key: key1,
groupValue: true,
value: true,
onChanged: (bool newValue) {},
),
),
),
),
),
);
expect(tester.getSize(find.byKey(key1)), const Size(48.0, 48.0));
final Key key2 = new UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
new Theme( new Material(
data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap), child: new Center(
child: new Directionality( child: new Radio<int>(
textDirection: TextDirection.ltr, key: key,
child: new Material( value: 1,
child: new Center( groupValue: 2,
child: new Radio<bool>( onChanged: (int newValue) { },
key: key2,
groupValue: true,
value: true,
onChanged: (bool newValue) {},
),
),
), ),
), ),
), ),
); );
expect(tester.getSize(find.byKey(key2)), const Size(40.0, 40.0)); expect(tester.getSize(find.byKey(key)), const Size(40.0, 40.0));
}); });
......
...@@ -2,11 +2,10 @@ import 'package:flutter/material.dart'; ...@@ -2,11 +2,10 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import '../rendering/mock_canvas.dart';
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.dart';
void main() { void main() {
testWidgets('materialTapTargetSize.padded expands hit test area', (WidgetTester tester) async { testWidgets('outerPadding expands hit test area', (WidgetTester tester) async {
int pressed = 0; int pressed = 0;
await tester.pumpWidget(new RawMaterialButton( await tester.pumpWidget(new RawMaterialButton(
...@@ -14,23 +13,23 @@ void main() { ...@@ -14,23 +13,23 @@ void main() {
pressed++; pressed++;
}, },
constraints: new BoxConstraints.tight(const Size(10.0, 10.0)), constraints: new BoxConstraints.tight(const Size(10.0, 10.0)),
materialTapTargetSize: MaterialTapTargetSize.padded, outerPadding: const EdgeInsets.all(50.0),
child: const Text('+', textDirection: TextDirection.ltr), child: const Text('+', textDirection: TextDirection.ltr),
)); ));
await tester.tapAt(const Offset(40.0, 400.0)); await tester.tapAt(const Offset(100.0, 100.0));
expect(pressed, 1); expect(pressed, 1);
}); });
testWidgets('materialTapTargetSize.padded expands semantics area', (WidgetTester tester) async { testWidgets('outerPadding expands semantics area', (WidgetTester tester) async {
final SemanticsTester semantics = new SemanticsTester(tester); final SemanticsTester semantics = new SemanticsTester(tester);
await tester.pumpWidget( await tester.pumpWidget(
new Center( new Center(
child: new RawMaterialButton( child: new RawMaterialButton(
onPressed: () {}, onPressed: () {},
constraints: new BoxConstraints.tight(const Size(10.0, 10.0)), constraints: new BoxConstraints.tight(const Size(10.0, 10.0)),
materialTapTargetSize: MaterialTapTargetSize.padded, outerPadding: const EdgeInsets.all(50.0),
child: const Text('+', textDirection: TextDirection.ltr), child: const Text('+', textDirection: TextDirection.ltr),
), ),
), ),
...@@ -51,7 +50,7 @@ void main() { ...@@ -51,7 +50,7 @@ void main() {
], ],
label: '+', label: '+',
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
rect: Rect.fromLTRB(0.0, 0.0, 48.0, 48.0), rect: Rect.fromLTRB(0.0, 0.0, 110.0, 110.0),
children: <TestSemantics>[], children: <TestSemantics>[],
), ),
] ]
...@@ -59,57 +58,4 @@ void main() { ...@@ -59,57 +58,4 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgets('Ink splash from center tap originates in correct location', (WidgetTester tester) async {
const Color highlightColor = const Color(0xAAFF0000);
const Color splashColor = const Color(0xAA0000FF);
const Color fillColor = const Color(0xFFEF5350);
await tester.pumpWidget(
new RawMaterialButton(
materialTapTargetSize: MaterialTapTargetSize.padded,
onPressed: () {},
fillColor: fillColor,
highlightColor: highlightColor,
splashColor: splashColor,
child: const SizedBox(),
)
);
final Offset center = tester.getCenter(find.byType(InkWell));
final TestGesture gesture = await tester.startGesture(center);
await tester.pump(); // start gesture
await tester.pump(const Duration(milliseconds: 200)); // wait for splash to be well under way
final RenderBox box = Material.of(tester.element(find.byType(InkWell))) as dynamic;
// centered in material button.
expect(box, paints..circle(x: 44.0, y: 18.0, color: splashColor));
await gesture.up();
});
testWidgets('Ink splash from tap above material originates in correct location', (WidgetTester tester) async {
const Color highlightColor = const Color(0xAAFF0000);
const Color splashColor = const Color(0xAA0000FF);
const Color fillColor = const Color(0xFFEF5350);
await tester.pumpWidget(
new RawMaterialButton(
materialTapTargetSize: MaterialTapTargetSize.padded,
onPressed: () {},
fillColor: fillColor,
highlightColor: highlightColor,
splashColor: splashColor,
child: const SizedBox(),
)
);
final Offset top = tester.getRect(find.byType(InkWell)).topCenter;
final TestGesture gesture = await tester.startGesture(top);
await tester.pump(); // start gesture
await tester.pump(const Duration(milliseconds: 200)); // wait for splash to be well under way
final RenderBox box = Material.of(tester.element(find.byType(InkWell))) as dynamic;
// paints above above material
expect(box, paints..circle(x: 44.0, y: 0.0, color: splashColor));
await gesture.up();
});
} }
\ No newline at end of file
...@@ -542,7 +542,7 @@ void main() { ...@@ -542,7 +542,7 @@ void main() {
), ),
), ),
)); ));
expect(tester.element(find.byKey(testKey)).size, const Size(88.0, 48.0)); expect(tester.element(find.byKey(testKey)).size, const Size(88.0, 36.0));
expect(tester.renderObject<RenderBox>(find.byKey(testKey)).localToGlobal(Offset.zero), const Offset(0.0, 0.0)); expect(tester.renderObject<RenderBox>(find.byKey(testKey)).localToGlobal(Offset.zero), const Offset(0.0, 0.0));
}); });
}); });
......
...@@ -341,10 +341,10 @@ void main() { ...@@ -341,10 +341,10 @@ void main() {
final Offset snackBarBottomRight = snackBarBox.localToGlobal(snackBarBox.size.bottomRight(Offset.zero)); final Offset snackBarBottomRight = snackBarBox.localToGlobal(snackBarBox.size.bottomRight(Offset.zero));
expect(textBottomLeft.dx - snackBarBottomLeft.dx, 24.0 + 10.0); // margin + left padding expect(textBottomLeft.dx - snackBarBottomLeft.dx, 24.0 + 10.0); // margin + left padding
expect(snackBarBottomLeft.dy - textBottomLeft.dy, 17.0 + 40.0); // margin + bottom padding expect(snackBarBottomLeft.dy - textBottomLeft.dy, 14.0 + 40.0); // margin + bottom padding
expect(actionTextBottomLeft.dx - textBottomRight.dx, 24.0); expect(actionTextBottomLeft.dx - textBottomRight.dx, 24.0);
expect(snackBarBottomRight.dx - actionTextBottomRight.dx, 24.0 + 30.0); // margin + right padding expect(snackBarBottomRight.dx - actionTextBottomRight.dx, 24.0 + 30.0); // margin + right padding
expect(snackBarBottomRight.dy - actionTextBottomRight.dy, 17.0 + 40.0); // margin + bottom padding expect(snackBarBottomRight.dy - actionTextBottomRight.dy, 14.0 + 40.0); // margin + bottom padding
}); });
testWidgets('SnackBar is positioned above BottomNavigationBar', (WidgetTester tester) async { testWidgets('SnackBar is positioned above BottomNavigationBar', (WidgetTester tester) async {
...@@ -398,10 +398,10 @@ void main() { ...@@ -398,10 +398,10 @@ void main() {
final Offset snackBarBottomRight = snackBarBox.localToGlobal(snackBarBox.size.bottomRight(Offset.zero)); final Offset snackBarBottomRight = snackBarBox.localToGlobal(snackBarBox.size.bottomRight(Offset.zero));
expect(textBottomLeft.dx - snackBarBottomLeft.dx, 24.0 + 10.0); // margin + left padding expect(textBottomLeft.dx - snackBarBottomLeft.dx, 24.0 + 10.0); // margin + left padding
expect(snackBarBottomLeft.dy - textBottomLeft.dy, 17.0); // margin (with no bottom padding) expect(snackBarBottomLeft.dy - textBottomLeft.dy, 14.0); // margin (with no bottom padding)
expect(actionTextBottomLeft.dx - textBottomRight.dx, 24.0); expect(actionTextBottomLeft.dx - textBottomRight.dx, 24.0);
expect(snackBarBottomRight.dx - actionTextBottomRight.dx, 24.0 + 30.0); // margin + right padding expect(snackBarBottomRight.dx - actionTextBottomRight.dx, 24.0 + 30.0); // margin + right padding
expect(snackBarBottomRight.dy - actionTextBottomRight.dy, 17.0); // margin (with no bottom padding) expect(snackBarBottomRight.dy - actionTextBottomRight.dy, 14.0); // margin (with no bottom padding)
}); });
testWidgets('SnackBarClosedReason', (WidgetTester tester) async { testWidgets('SnackBarClosedReason', (WidgetTester tester) async {
......
...@@ -43,46 +43,6 @@ void main() { ...@@ -43,46 +43,6 @@ void main() {
expect(value, isTrue); expect(value, isTrue);
}); });
testWidgets('Switch size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async {
await tester.pumpWidget(
new Theme(
data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.padded),
child: new Directionality(
textDirection: TextDirection.ltr,
child: new Material(
child: new Center(
child: new Switch(
value: true,
onChanged: (bool newValue) {},
),
),
),
),
),
);
expect(tester.getSize(find.byType(Switch)), const Size(59.0, 48.0));
await tester.pumpWidget(
new Theme(
data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap),
child: new Directionality(
textDirection: TextDirection.ltr,
child: new Material(
child: new Center(
child: new Switch(
value: true,
onChanged: (bool newValue) {},
),
),
),
),
),
);
expect(tester.getSize(find.byType(Switch)), const Size(59.0, 40.0));
});
testWidgets('Switch can drag (LTR)', (WidgetTester tester) async { testWidgets('Switch can drag (LTR)', (WidgetTester tester) async {
bool value = false; bool value = false;
......
...@@ -103,12 +103,6 @@ void main() { ...@@ -103,12 +103,6 @@ void main() {
expect(darkTheme.accentTextTheme.title.color, typography.white.title.color); expect(darkTheme.accentTextTheme.title.color, typography.white.title.color);
}); });
test('Defaults to MaterialTapTargetBehavior.expanded', () {
final ThemeData themeData = new ThemeData();
expect(themeData.materialTapTargetSize, MaterialTapTargetSize.padded);
});
test('Can control fontFamily', () { test('Can control fontFamily', () {
final ThemeData themeData = new ThemeData(fontFamily: 'Ahem'); final ThemeData themeData = new ThemeData(fontFamily: 'Ahem');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment