diff --git a/lib/pages/widgets/my_data_table.dart b/lib/pages/widgets/my_data_table.dart index 3015c50..8e66eef 100644 --- a/lib/pages/widgets/my_data_table.dart +++ b/lib/pages/widgets/my_data_table.dart @@ -75,7 +75,7 @@ class MyDataRow { this.key, this.selected = false, this.onSelectChanged, - @required this.cells, + required this.cells, }) : assert(cells != null); /// Creates the configuration for a row of a [MyDataTable], deriving @@ -83,10 +83,10 @@ class MyDataRow { /// /// The [cells] argument must not be null. MyDataRow.byIndex({ - int index, + int index = 0, this.selected = false, this.onSelectChanged, - @required this.cells, + required this.cells, }) : assert(cells != null), key = ValueKey(index); @@ -96,7 +96,7 @@ class MyDataRow { /// remain on the right row visually. /// /// If the table never changes once created, no key is necessary. - final LocalKey key; + final LocalKey? key; /// Called when the user selects or unselects a selectable row. /// @@ -111,7 +111,7 @@ class MyDataRow { /// A row whose [onSelectChanged] callback is null is ignored for /// the purposes of determining the state of the "all" checkbox, /// and its checkbox is disabled. - final ValueChanged onSelectChanged; + final ValueChanged? onSelectChanged; /// Whether the row is selected. /// @@ -193,7 +193,7 @@ class MyDataCell { /// If non-null, tapping the cell will call this callback. If /// null, tapping the cell will attempt to select the row (if /// [MyDataRow.onSelectChanged] is provided). - final VoidCallback onTap; + final VoidCallback? onTap; bool get _debugInteractive => onTap != null; } @@ -309,8 +309,8 @@ class MyDataTable extends StatelessWidget { /// the sort order is ascending, this should be true (the default), /// otherwise it should be false. MyDataTable({ - Key key, - @required this.columns, + Key? key, + required this.columns, this.sortColumnIndex, this.sortAscending = true, this.onSelectAll, @@ -339,8 +339,8 @@ class MyDataTable extends StatelessWidget { /// The configuration and labels for the columns in the table. final List columns; - final Decoration oddLine; - final Decoration evenLine; + final Decoration? oddLine; + final Decoration? evenLine; /// The current primary sort key's column. /// @@ -353,7 +353,7 @@ class MyDataTable extends StatelessWidget { /// /// When this is null, it implies that the table's sort order does /// not correspond to any of the columns. - final int sortColumnIndex; + final int? sortColumnIndex; /// Whether the column mentioned in [sortColumnIndex], if any, is sorted /// in ascending order. @@ -376,7 +376,7 @@ class MyDataTable extends StatelessWidget { /// To control whether a particular row is selectable or not, see /// [MyDataRow.onSelectChanged]. This callback is only relevant if any /// row is selectable. - final ValueSetter onSelectAll; + final ValueSetter? onSelectAll; /// The height of each row (excluding the row that contains column headings). /// @@ -413,11 +413,10 @@ class MyDataTable extends StatelessWidget { // non-numeric, if there is exactly one, otherwise null. final int _onlyTextColumn; static int _initOnlyTextColumn(List columns) { - int result; + int result = 0; for (int index = 0; index < columns.length; index += 1) { final MyDataColumn column = columns[index]; if (!column.numeric) { - if (result != null) return null; result = index; } } @@ -433,11 +432,11 @@ class MyDataTable extends StatelessWidget { void _handleSelectAll(bool checked) { if (onSelectAll != null) { - onSelectAll(checked); + onSelectAll!(checked); } else { for (MyDataRow row in rows) { if ((row.onSelectChanged != null) && (row.selected != checked)) - row.onSelectChanged(checked); + row.onSelectChanged!(checked); } } } @@ -613,8 +612,8 @@ class MyDataTable extends StatelessWidget { final bool showCheckboxColumn = false; final bool allChecked = false; - final List tableColumns = - List(columns.length + (showCheckboxColumn ? 1 : 0)); + final List tableColumns = (columns.length + + (showCheckboxColumn ? 1 : 0)) as List; final List tableRows = List.generate( rows.length + 1, // the +1 is for the header row (int index) { @@ -745,7 +744,7 @@ class MyDataTable extends StatelessWidget { class TableRowInkWell extends InkResponse { /// Creates an ink well for a table row. const TableRowInkWell({ - Key key, + Key? key, Widget child, GestureTapCallback onTap, GestureTapCallback onDoubleTap, @@ -799,7 +798,7 @@ class TableRowInkWell extends InkResponse { class _SortArrow extends StatefulWidget { const _SortArrow({ - Key key, + Key? key, this.visible, this.down, this.duration, @@ -816,14 +815,14 @@ class _SortArrow extends StatefulWidget { } class _SortArrowState extends State<_SortArrow> with TickerProviderStateMixin { - AnimationController _opacityController; - Animation _opacityAnimation; + late AnimationController _opacityController; + late Animation _opacityAnimation; - AnimationController _orientationController; - Animation _orientationAnimation; + late AnimationController _orientationController; + late Animation _orientationAnimation; double _orientationOffset = 0.0; - bool _down; + late bool _down; static final Animatable _turnTween = Tween(begin: 0.0, end: math.pi) @@ -869,7 +868,7 @@ class _SortArrowState extends State<_SortArrow> with TickerProviderStateMixin { void didUpdateWidget(_SortArrow oldWidget) { super.didUpdateWidget(oldWidget); bool skipArrow = false; - final bool newDown = widget.down ?? _down; + final bool newDown = widget.down; if (oldWidget.visible != widget.visible) { if (widget.visible && (_opacityController.status == AnimationStatus.dismissed)) {