微信交流群

老孟公众号

# MaterialTapTargetSize

MaterialTapTargetSize并不是一个组件,是配置组件点击区域大小的属性,很多组件都有materialTapTargetSize属性,比如:

[FloatingActionButton], only the mini tap target size is increased.
* [MaterialButton]
* [OutlineButton]
* [FlatButton]
* [RaisedButton]
* [TimePicker]
* [SnackBar]
* [Chip]
* [RawChip]
* [InputChip]
* [ChoiceChip]
* [FilterChip]
* [ActionChip]
* [Radio]
* [Switch]
* [Checkbox]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

MaterialTapTargetSize有2个值,分别为:

  • padded:最小点击区域为48*48。
  • shrinkWrap:子组件的实际大小。

源码如下:

BoxConstraints constraints;
switch (widget.materialTapTargetSize ?? theme.materialTapTargetSize) {
  case MaterialTapTargetSize.padded:
    constraints = const BoxConstraints(minHeight: kMinInteractiveDimension);
    break;
  case MaterialTapTargetSize.shrinkWrap:
    constraints = const BoxConstraints();
    break;
}
1
2
3
4
5
6
7
8
9

kMinInteractiveDimension值为48。