cleanup code

This commit is contained in:
tzw
2024-01-23 16:28:08 +06:30
parent a1e87cdbf6
commit f3f75a80c6
96 changed files with 232 additions and 439 deletions

View File

@@ -1,9 +1,9 @@
// ignore_for_file: unnecessary_null_comparison, dead_code
import 'dart:math' as math;
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
/// Signature for [MyDataColumn.onSort] callback.
typedef MyDataColumnSortCallback = void Function(
@@ -13,7 +13,7 @@ typedef MyDataColumnSortCallback = void Function(
///
/// One column configuration must be provided for each column to
/// display in the table. The list of [MyDataColumn] objects is passed
/// as the `columns` argument to the [new MyDataTable] constructor.
/// as the `columns` argument to the [MyDataTable.new] constructor.
@immutable
class MyDataColumn {
/// Creates the configuration for a column of a [MyDataTable].
@@ -62,7 +62,7 @@ class MyDataColumn {
///
/// One row configuration must be provided for each row to
/// display in the table. The list of [MyDataRow] objects is passed
/// as the `rows` argument to the [new MyDataTable] constructor.
/// as the `rows` argument to the [MyDataTable.new] constructor.
///
/// The data for this row of the table is provided in the [cells]
/// property of the [MyDataRow] object.
@@ -137,7 +137,7 @@ class MyDataRow {
/// The data for a cell of a [MyDataTable].
///
/// One list of [MyDataCell] objects must be provided for each [MyDataRow]
/// in the [MyDataTable], in the [new MyDataRow] constructor's `cells`
/// in the [MyDataTable], in the [MyDataRow.new] constructor's `cells`
/// argument.
@immutable
class MyDataCell {
@@ -314,19 +314,18 @@ class MyDataTable extends StatelessWidget {
this.sortColumnIndex,
this.sortAscending = true,
this.onSelectAll,
this.MyDataRowHeight = kMinInteractiveDimension,
this.myDataRowHeight = kMinInteractiveDimension,
this.headingRowHeight = 56.0,
this.horizontalMargin = 24.0,
this.columnSpacing = 56.0,
this.oddLine,
this.evenLine,
required this.rows,
}) : assert(columns != null),
assert(columns.isNotEmpty),
}) : assert(columns.isNotEmpty),
assert(sortColumnIndex == null ||
(sortColumnIndex >= 0 && sortColumnIndex < columns.length)),
assert(sortAscending != null),
assert(MyDataRowHeight != null),
assert(myDataRowHeight != null),
assert(headingRowHeight != null),
assert(horizontalMargin != null),
assert(columnSpacing != null),
@@ -382,7 +381,7 @@ class MyDataTable extends StatelessWidget {
///
/// This value defaults to kMinInteractiveDimension to adhere to the Material
/// Design specifications.
final double MyDataRowHeight;
final double myDataRowHeight;
/// The height of the heading row.
///
@@ -567,7 +566,7 @@ class MyDataTable extends StatelessWidget {
}
label = Container(
padding: padding,
height: MyDataRowHeight,
height: myDataRowHeight,
alignment: (numeric ?? false)
? Alignment.centerRight
: AlignmentDirectional.centerStart,
@@ -605,7 +604,6 @@ class MyDataTable extends StatelessWidget {
Widget build(BuildContext context) {
assert(!_debugInteractive || debugCheckHasMaterial(context));
final ThemeData theme = Theme.of(context);
final BoxDecoration _kSelectedDecoration = BoxDecoration(
border: Border(bottom: Divider.createBorderSide(context, width: 1.0)),
// The backgroundColor has to be transparent so you can see the ink on the material
@@ -618,7 +616,6 @@ class MyDataTable extends StatelessWidget {
);
final bool showCheckboxColumn = false;
final bool allChecked = false;
final List<TableColumnWidth> tableColumns = (columns.length +
(showCheckboxColumn ? 1 : 0)) as List<TableColumnWidth>;
@@ -641,7 +638,7 @@ class MyDataTable extends StatelessWidget {
int rowIndex;
int displayColumnIndex = 0;
int displayColumnIndex = 0;
// if (showCheckboxColumn) {
// tableColumns[0] = FixedColumnWidth(
// horizontalMargin + Checkbox.width + horizontalMargin / 2.0);
@@ -696,7 +693,7 @@ class MyDataTable extends StatelessWidget {
} else {
tableColumns[displayColumnIndex] = const IntrinsicColumnWidth();
}
tableRows[0].children![displayColumnIndex] = _buildHeadingCell(
tableRows[0].children[displayColumnIndex] = _buildHeadingCell(
context: context,
padding: padding,
label: column.label,
@@ -712,7 +709,7 @@ class MyDataTable extends StatelessWidget {
rowIndex = 1;
for (MyDataRow row in rows) {
final MyDataCell cell = row.cells[MyDataColumnIndex];
tableRows[rowIndex].children?[displayColumnIndex] = _buildMyDataCell(
tableRows[rowIndex].children[displayColumnIndex] = _buildMyDataCell(
context: context,
padding: padding,
label: cell.child,
@@ -780,13 +777,13 @@ class TableRowInkWell extends InkResponse {
parentBox.applyPaintTransform(cell, transform);
assert(table == cell.parent);
cell = parentBox;
table = table?.parent;
table = table.parent;
}
if (table is RenderTable) {
final TableCellParentData cellParentData =
cell.parentData as TableCellParentData;
assert(cellParentData.y != null);
final Rect rect = table .getRowBox(cellParentData.y!);
final Rect rect = table.getRowBox(cellParentData.y!);
// The rect is in the table's coordinate space. We need to change it to the
// TableRowInkWell's coordinate space.
table.applyPaintTransform(cell, transform);