Skip to content

Commit

Permalink
Fix type error when dragging rows.
Browse files Browse the repository at this point in the history
  • Loading branch information
bosskmk committed May 5, 2021
1 parent 4b17275 commit 531c39f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/src/manager/state/row_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ mixin RowState implements IPlutoGridState {
refRows!.remove(row);
});

refRows!.insertAll(indexToMove, rows);
refRows!.insertAll(indexToMove, rows.cast<PlutoRow>());

int sortIdx = 0;

Expand Down Expand Up @@ -480,6 +480,6 @@ mixin RowState implements IPlutoGridState {
}
}

refRows!.insertAll(index, rows);
refRows!.insertAll(index, rows.cast<PlutoRow>());
}
}
38 changes: 38 additions & 0 deletions test/src/manager/state/row_state_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1793,6 +1793,44 @@ void main() {
verify(listener.onChangeVoidNoParamListener()).called(1);
},
);

testWidgets(
'행 2개가 있는 상태에서 0번 컬럼을 1번으로 이동 할 경우 타입에러가 발생되지 않고 이동 되어야 한다.',
(WidgetTester tester) async {
// given
List<PlutoColumn> columns = [
...ColumnHelper.textColumn('text', count: 3, width: 150),
];

List<PlutoRow> rows = RowHelper.count(2, columns);

final scroll = MockPlutoScrollController();

PlutoGridStateManager stateManager = PlutoGridStateManager(
columns: columns,
rows: rows,
gridFocusNode: null,
scroll: scroll,
);

final listener = MockOnChangeListener();

stateManager.addListener(listener.onChangeVoidNoParamListener);

// when
final rowKey = rows[0].key;

stateManager.moveRowsByIndex(
[rows[0]],
1,
);

// then
expect(stateManager.rows.length, 2);
expect(stateManager.rows[1]!.key, rowKey);
verify(listener.onChangeVoidNoParamListener()).called(1);
},
);
});

group('toggleAllRowChecked', () {
Expand Down

0 comments on commit 531c39f

Please sign in to comment.