1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- import 'package:flutter/widgets.dart';
- /// 表格列配置
- class TableColumn<T> {
- TableColumn({
- this.headerText,
- this.headerRender,
- this.textFormatter,
- this.render,
- this.textAlign = TextAlign.center,
- this.flex = 1,
- this.width,
- this.minWidth,
- this.maxWidth,
- this.textFontSize = 15,
- }) : assert(() {
- if (headerText == null && headerRender == null) {
- throw FlutterError(
- "`titleText` and `headerRender` cannot both be null.");
- }
- return true;
- }()),
- assert(() {
- if (textFormatter == null && render == null) {
- throw FlutterError(
- "`textFormatter` and `render` cannot both be null.");
- }
- return true;
- }());
- /// 列头文本
- final String? headerText;
- /// 列头自定义渲染
- final Widget Function()? headerRender;
- /// 内容文本格式器
- final String Function(T rowData, int rowIndex)? textFormatter;
- /// 内容自定义渲染
- final Widget Function(T rowData, int rowIndex)? render;
- /// 内容文本对齐方式
- final TextAlign textAlign;
- /// 列宽自适应权重
- final int flex;
- /// 固定栏宽 -尚未启用
- final double? width;
- /// 最小列宽 -尚未启用
- final double? minWidth;
- /// 最大列宽 -尚未启用
- final double? maxWidth;
- /// 在内容文本格式器的时候改变文字大小
- final double? textFontSize;
- int get actualFlex => width != null || maxWidth != null ? 0 : flex;
- bool get hasWidthLimit =>
- width != null || maxWidth != null || minWidth != null;
- }
|