只能用于Table的水波纹,接收点击、双击、长按、高亮变化事件,水波纹会作用于表格的一行。

相关组件

Table

TableRowInkWell基本事件

【child】 : 子组件 【Widget】
【onTap】 : 点击事件 【Function()】
【onDoubleTap】 : 双击事件 【Function()】
【onLongPress】 : 长按事件 【Function()】
【onHighlightChanged】 : 高亮变化回调 【Function(bool)】
170.gif

  1. import 'package:flutter/material.dart';
  2. class CustomTableRowInkWell extends StatelessWidget {
  3. @override
  4. Widget build(BuildContext context) {
  5. var title = _ItemBean("单位称", "量纲", "单位", "单位名称", "单位符号");
  6. var m = _ItemBean("长度", "L", "1m", "米", "m");
  7. var kg = _ItemBean("质量", "M", "1Kg", "千克", "Kg");
  8. var s = _ItemBean("时间", "T", "1s", "秒", "s");
  9. var a = _ItemBean("安培", "Ι", "1A", "安培", "A");
  10. var k = _ItemBean("热力学温度", "θ", "1K", "开尔文", "K");
  11. var mol = _ItemBean("物质的量", "N", "1mol", "摩尔", "mol");
  12. var cd = _ItemBean("发光强度", "J", "1cd", "坎德拉", "cd");
  13. var data = <_ItemBean>[title, m, kg, s, a, k, mol, cd];
  14. return SingleChildScrollView(
  15. scrollDirection: Axis.horizontal,
  16. child: Table(
  17. columnWidths: const <int, TableColumnWidth>{
  18. 0: FixedColumnWidth(80.0),
  19. 1: FixedColumnWidth(80.0),
  20. 2: FixedColumnWidth(80.0),
  21. 3: FixedColumnWidth(80.0),
  22. 4: FixedColumnWidth(80.0),
  23. },
  24. defaultVerticalAlignment: TableCellVerticalAlignment.middle,
  25. border: TableBorder.all(
  26. color: Colors.orangeAccent, width: 1.0, style: BorderStyle.solid),
  27. children: data
  28. .map((item) => TableRow(children: <Widget>[
  29. TableRowInkWell(
  30. onTap: () => print('onTap'),
  31. onDoubleTap: () => print('onDoubleTap'),
  32. onLongPress: () => print('onLongPress'),
  33. onHighlightChanged: (v) => print('onHighlightChanged:$v'),
  34. child: Center(
  35. child: Text(
  36. item.name,
  37. style: TextStyle(color: Colors.blue),
  38. )),
  39. ),
  40. Padding(
  41. padding: const EdgeInsets.all(8.0),
  42. child: Center(child: Text(item.symbol)),
  43. ),
  44. Padding(
  45. padding: const EdgeInsets.all(8.0),
  46. child: Center(child: Text(item.unitSymbol)),
  47. ),
  48. Padding(
  49. padding: const EdgeInsets.all(8.0),
  50. child: Center(child: Text(item.unitName)),
  51. ),
  52. Padding(
  53. padding: const EdgeInsets.all(8.0),
  54. child: Center(child: Text(item.unit)),
  55. ),
  56. ]))
  57. .toList(),
  58. ),
  59. );
  60. }
  61. }
  62. class _ItemBean {
  63. String name;
  64. String symbol;
  65. String unit;
  66. String unitName;
  67. String unitSymbol;
  68. _ItemBean(this.name, this.symbol, this.unit, this.unitName, this.unitSymbol);
  69. }