Skip to content

Commit

Permalink
Enabled analysis.(library_private_types_in_public_api, no_leading_und…
Browse files Browse the repository at this point in the history
…erscores_for_local_identifiers)
  • Loading branch information
bosskmk committed Jun 6, 2022
1 parent a9e6597 commit ea3227d
Show file tree
Hide file tree
Showing 30 changed files with 127 additions and 135 deletions.
5 changes: 0 additions & 5 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,3 @@ include: package:flutter_lints/flutter.yaml
analyzer:
exclude:
- '**.mocks.dart'

linter:
rules:
no_leading_underscores_for_local_identifiers: false
library_private_types_in_public_api: false
7 changes: 4 additions & 3 deletions lib/src/extends/pluto_state_with_change.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:pluto_grid/pluto_grid.dart';

typedef _ResetStateCallback = void Function(_UpdateStateFunction update);
typedef PlutoStateResetStateCallback = void Function(
PlutoStateUpdateStateFunction update);

typedef _UpdateStateFunction = T Function<T>(
typedef PlutoStateUpdateStateFunction = T Function<T>(
T oldValue,
T newValue, {
bool Function(T a, T b)? compare,
Expand Down Expand Up @@ -56,7 +57,7 @@ abstract class PlutoStateWithChange<T extends PlutoStatefulWidget>
_initialized = true;
}

void resetState(_ResetStateCallback callback) {
void resetState(PlutoStateResetStateCallback callback) {
callback(_update);
// it may have not been layout yet.
if (mounted &&
Expand Down
25 changes: 12 additions & 13 deletions lib/src/helper/filter_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,10 @@ class FilterHelper {
return (PlutoRow? row) {
bool? flag;

for (var _row in rows) {
final filterType =
_row!.cells[filterFieldType]!.value as PlutoFilterType?;
for (var e in rows) {
final filterType = e!.cells[filterFieldType]!.value as PlutoFilterType?;

if (_row.cells[filterFieldColumn]!.value == filterFieldAllColumns) {
if (e.cells[filterFieldColumn]!.value == filterFieldAllColumns) {
bool? flagAllColumns;

row!.cells.forEach((key, value) {
Expand All @@ -80,7 +79,7 @@ class FilterHelper {
compareByFilterType(
filterType: filterType!,
base: value.value.toString(),
search: _row.cells[filterFieldValue]!.value.toString(),
search: e.cells[filterFieldValue]!.value.toString(),
column: foundColumn,
),
);
Expand All @@ -90,17 +89,17 @@ class FilterHelper {
flag = compareAnd(flag, flagAllColumns);
} else {
var foundColumn = enabledFilterColumns!.firstWhereOrNull(
(element) => element.field == _row.cells[filterFieldColumn]!.value,
(element) => element.field == e.cells[filterFieldColumn]!.value,
);

if (foundColumn != null) {
flag = compareAnd(
flag,
compareByFilterType(
filterType: filterType!,
base: row!.cells[_row.cells[filterFieldColumn]!.value]!.value
base: row!.cells[e.cells[filterFieldColumn]!.value]!.value
.toString(),
search: _row.cells[filterFieldValue]!.value.toString(),
search: e.cells[filterFieldValue]!.value.toString(),
column: foundColumn,
),
);
Expand Down Expand Up @@ -359,9 +358,9 @@ class FilterPopupState {
handleApplyFilter(_stateManager);
}

_FilterPopupHeader createHeader(PlutoGridStateManager _stateManager) {
return _FilterPopupHeader(
stateManager: _stateManager,
PlutoGridFilterPopupHeader createHeader(PlutoGridStateManager stateManager) {
return PlutoGridFilterPopupHeader(
stateManager: stateManager,
configuration: configuration,
handleAddNewFilter: handleAddNewFilter,
);
Expand Down Expand Up @@ -427,12 +426,12 @@ class FilterPopupState {
}
}

class _FilterPopupHeader extends StatelessWidget {
class PlutoGridFilterPopupHeader extends StatelessWidget {
final PlutoGridStateManager? stateManager;
final PlutoGridConfiguration? configuration;
final SetFilterPopupHandler? handleAddNewFilter;

const _FilterPopupHeader({
const PlutoGridFilterPopupHeader({
Key? key,
this.stateManager,
this.configuration,
Expand Down
12 changes: 6 additions & 6 deletions lib/src/manager/pluto_grid_state_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ abstract class IPlutoGridState
IScrollState,
ISelectingState {}

class PlutoGridState extends PlutoChangeNotifier
class PlutoGridStateChangeNotifier extends PlutoChangeNotifier
with
CellState,
ColumnGroupState,
Expand All @@ -56,7 +56,7 @@ class PlutoGridState extends PlutoChangeNotifier
ScrollState,
SelectingState {}

class PlutoGridStateManager extends PlutoGridState {
class PlutoGridStateManager extends PlutoGridStateChangeNotifier {
PlutoGridStateManager({
required List<PlutoColumn> columns,
required List<PlutoRow> rows,
Expand Down Expand Up @@ -149,7 +149,7 @@ class PlutoGridStateManager extends PlutoGridState {

final Completer<List<PlutoRow>> completer = Completer();

SplayTreeMap<int, List<PlutoRow>> _rows = SplayTreeMap();
SplayTreeMap<int, List<PlutoRow>> splayMapRows = SplayTreeMap();

final Iterable<List<PlutoRow>> chunks = refRows.slices(chunkSize);

Expand Down Expand Up @@ -178,11 +178,11 @@ class PlutoGridStateManager extends PlutoGridState {
start: start + (chunkIndex * chunkSize),
);
}).then((value) {
_rows[chunkIndex] = value;
splayMapRows[chunkIndex] = value;

if (_rows.length == chunksLength) {
if (splayMapRows.length == chunksLength) {
completer.complete(
_rows.values.expand((element) => element).toList(),
splayMapRows.values.expand((element) => element).toList(),
);

timer.cancel();
Expand Down
6 changes: 3 additions & 3 deletions lib/src/manager/state/filtering_row_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ mixin FilteringRowState implements IPlutoGridState {
row.setState(PlutoRowState.none);
}

var _filter = filter;
var savedFilter = filter;

if (filter == null) {
setFilterRows([]);
} else {
_filter = (PlutoRow row) {
savedFilter = (PlutoRow row) {
return !row.state.isNone || filter(row);
};
}

refRows.setFilter(_filter);
refRows.setFilter(savedFilter);

resetCurrentState(notify: false);

Expand Down
4 changes: 2 additions & 2 deletions lib/src/manager/state/layout_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,10 @@ mixin LayoutState implements IPlutoGridState {

@override
void setLayout(BoxConstraints size) {
final _isShowFrozenColumn = shouldShowFrozenColumns(size.maxWidth);
final showFrozenColumn = shouldShowFrozenColumns(size.maxWidth);
_maxWidth = size.maxWidth;
_maxHeight = size.maxHeight;
_showFrozenColumn = _isShowFrozenColumn;
_showFrozenColumn = showFrozenColumn;
_gridGlobalOffset = null;
}

Expand Down
16 changes: 8 additions & 8 deletions lib/src/manager/state/selecting_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -320,19 +320,19 @@ mixin SelectingState implements IPlutoGridState {

final columnIndexes = columnIndexesByShowFrozen;

final _rightBlankOffset = rightBlankOffset;
final _horizontalScrollOffset = scroll!.horizontal!.offset;
final savedRightBlankOffset = rightBlankOffset;
final savedHorizontalScrollOffset = scroll!.horizontal!.offset;

for (var i = 0; i < columnIndexes.length; i += 1) {
final column = refColumns[columnIndexes[i]];

currentWidth += column.width;

final rightFrozenColumnOffset =
column.frozen.isRight && showFrozenColumn ? _rightBlankOffset : 0;
column.frozen.isRight && showFrozenColumn ? savedRightBlankOffset : 0;

if (currentWidth + rightFrozenColumnOffset >
offset.dx + _horizontalScrollOffset) {
offset.dx + savedHorizontalScrollOffset) {
columnIdx = i;
break;
}
Expand All @@ -357,15 +357,15 @@ mixin SelectingState implements IPlutoGridState {
return;
}

final _from = min(from!, to!);
final maxFrom = min(from!, to!);

final _to = max(from, to) + 1;
final maxTo = max(from, to) + 1;

if (_from < 0 || _to > refRows.length) {
if (maxFrom < 0 || maxTo > refRows.length) {
return;
}

_currentSelectingRows = refRows.getRange(_from, _to).toList();
_currentSelectingRows = refRows.getRange(maxFrom, maxTo).toList();

if (notify) {
notifyListeners();
Expand Down
6 changes: 1 addition & 5 deletions lib/src/model/pluto_column_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,7 @@ class PlutoColumnTypeSelect implements PlutoColumnType {
@override
int compare(dynamic a, dynamic b) {
return compareWithNull(a, b, () {
final _a = items.indexOf(a);

final _b = items.indexOf(b);

return _a.compareTo(_b);
return items.indexOf(a).compareTo(items.indexOf(b));
});
}

Expand Down
24 changes: 12 additions & 12 deletions lib/src/plugin/pluto_pagination.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class PlutoPagination extends PlutoStatefulWidget {
final PlutoGridStateManager stateManager;

@override
_PlutoPaginationState createState() => _PlutoPaginationState();
PlutoPaginationState createState() => PlutoPaginationState();
}

abstract class _PlutoPaginationStateWithChange
Expand Down Expand Up @@ -46,7 +46,7 @@ abstract class _PlutoPaginationStateWithChange
}
}

class _PlutoPaginationState extends _PlutoPaginationStateWithChange {
class PlutoPaginationState extends _PlutoPaginationStateWithChange {
late double _maxWidth;

final _iconSplashRadius = PlutoGridSettings.rowHeight / 2;
Expand Down Expand Up @@ -174,8 +174,8 @@ class _PlutoPaginationState extends _PlutoPaginationStateWithChange {
return LayoutBuilder(
builder: (layoutContext, size) {
_maxWidth = size.maxWidth;
final Color _iconColor = widget.stateManager.configuration!.iconColor;
final Color _disabledIconColor =
final Color iconColor = widget.stateManager.configuration!.iconColor;
final Color disabledIconColor =
widget.stateManager.configuration!.disabledIconColor;
// can't center using center, it'll take all max width and max height
return Row(
Expand All @@ -192,8 +192,8 @@ class _PlutoPaginationState extends _PlutoPaginationStateWithChange {
IconButton(
onPressed: _isFirstPage ? null : _firstPage,
icon: const Icon(Icons.first_page),
color: _iconColor,
disabledColor: _disabledIconColor,
color: iconColor,
disabledColor: disabledIconColor,
splashRadius: _iconSplashRadius,
mouseCursor: _isFirstPage
? SystemMouseCursors.basic
Expand All @@ -202,8 +202,8 @@ class _PlutoPaginationState extends _PlutoPaginationStateWithChange {
IconButton(
onPressed: _isFirstPage ? null : _beforePage,
icon: const Icon(Icons.navigate_before),
color: _iconColor,
disabledColor: _disabledIconColor,
color: iconColor,
disabledColor: disabledIconColor,
splashRadius: _iconSplashRadius,
mouseCursor: _isFirstPage
? SystemMouseCursors.basic
Expand All @@ -213,8 +213,8 @@ class _PlutoPaginationState extends _PlutoPaginationStateWithChange {
IconButton(
onPressed: _isLastPage ? null : _nextPage,
icon: const Icon(Icons.navigate_next),
color: _iconColor,
disabledColor: _disabledIconColor,
color: iconColor,
disabledColor: disabledIconColor,
splashRadius: _iconSplashRadius,
mouseCursor: _isLastPage
? SystemMouseCursors.basic
Expand All @@ -223,8 +223,8 @@ class _PlutoPaginationState extends _PlutoPaginationStateWithChange {
IconButton(
onPressed: _isLastPage ? null : _lastPage,
icon: const Icon(Icons.last_page),
color: _iconColor,
disabledColor: _disabledIconColor,
color: iconColor,
disabledColor: disabledIconColor,
splashRadius: _iconSplashRadius,
mouseCursor: _isLastPage
? SystemMouseCursors.basic
Expand Down
4 changes: 2 additions & 2 deletions lib/src/pluto_dual_grid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ class PlutoDualGrid extends StatefulWidget {
}) : super(key: key);

@override
_PlutoDualGridState createState() => _PlutoDualGridState();
PlutoDualGridState createState() => PlutoDualGridState();
}

class _PlutoDualGridState extends State<PlutoDualGrid> {
class PlutoDualGridState extends State<PlutoDualGrid> {
PlutoGridStateManager? _stateManagerA;

PlutoGridStateManager? _stateManagerB;
Expand Down
4 changes: 2 additions & 2 deletions lib/src/pluto_grid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ class PlutoGrid extends StatefulWidget {
}

@override
_PlutoGridState createState() => _PlutoGridState();
PlutoGridState createState() => PlutoGridState();
}

class _PlutoGridState extends State<PlutoGrid> {
class PlutoGridState extends State<PlutoGrid> {
final FocusNode _gridFocusNode = FocusNode();

final LinkedScrollControllerGroup _verticalScroll =
Expand Down
4 changes: 2 additions & 2 deletions lib/src/ui/cells/pluto_date_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ class PlutoDateCell extends StatefulWidget implements PopupCell {
}) : super(key: key);

@override
_PlutoDateCellState createState() => _PlutoDateCellState();
PlutoDateCellState createState() => PlutoDateCellState();
}

class _PlutoDateCellState extends State<PlutoDateCell>
class PlutoDateCellState extends State<PlutoDateCell>
with PopupCellState<PlutoDateCell> {
PlutoGridStateManager? popupStateManager;

Expand Down
4 changes: 2 additions & 2 deletions lib/src/ui/cells/pluto_number_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ class PlutoNumberCell extends StatefulWidget implements TextCell {
}) : super(key: key);

@override
_PlutoNumberCellState createState() => _PlutoNumberCellState();
PlutoNumberCellState createState() => PlutoNumberCellState();
}

class _PlutoNumberCellState extends State<PlutoNumberCell>
class PlutoNumberCellState extends State<PlutoNumberCell>
with TextCellState<PlutoNumberCell> {
int? decimalRange;

Expand Down
4 changes: 2 additions & 2 deletions lib/src/ui/cells/pluto_select_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ class PlutoSelectCell extends StatefulWidget implements PopupCell {
}) : super(key: key);

@override
_PlutoSelectCellState createState() => _PlutoSelectCellState();
PlutoSelectCellState createState() => PlutoSelectCellState();
}

class _PlutoSelectCellState extends State<PlutoSelectCell>
class PlutoSelectCellState extends State<PlutoSelectCell>
with PopupCellState<PlutoSelectCell> {
@override
List<PlutoColumn> popupColumns = [];
Expand Down
4 changes: 2 additions & 2 deletions lib/src/ui/cells/pluto_text_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class PlutoTextCell extends StatefulWidget implements TextCell {
}) : super(key: key);

@override
_PlutoTextCellState createState() => _PlutoTextCellState();
PlutoTextCellState createState() => PlutoTextCellState();
}

class _PlutoTextCellState extends State<PlutoTextCell>
class PlutoTextCellState extends State<PlutoTextCell>
with TextCellState<PlutoTextCell> {}
4 changes: 2 additions & 2 deletions lib/src/ui/cells/pluto_time_cell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ class PlutoTimeCell extends StatefulWidget implements PopupCell {
}) : super(key: key);

@override
_PlutoTimeCellState createState() => _PlutoTimeCellState();
PlutoTimeCellState createState() => PlutoTimeCellState();
}

class _PlutoTimeCellState extends State<PlutoTimeCell>
class PlutoTimeCellState extends State<PlutoTimeCell>
with PopupCellState<PlutoTimeCell> {
PlutoGridStateManager? popupStateManager;

Expand Down
Loading

0 comments on commit ea3227d

Please sign in to comment.