From 6ac74321abb2b2176b46f5126142f8f0647abc66 Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Wed, 17 Jan 2024 16:33:36 -0600 Subject: [PATCH 1/3] Fix TableSpanDecoration rects when axes are reversed --- .../lib/src/table_view/table.dart | 30 +- .../test/table_view/table_span_test.dart | 665 ++++++++++++++++++ 2 files changed, 689 insertions(+), 6 deletions(-) diff --git a/packages/two_dimensional_scrollables/lib/src/table_view/table.dart b/packages/two_dimensional_scrollables/lib/src/table_view/table.dart index a2452c71ab1..4e43ff065f2 100644 --- a/packages/two_dimensional_scrollables/lib/src/table_view/table.dart +++ b/packages/two_dimensional_scrollables/lib/src/table_view/table.dart @@ -861,31 +861,41 @@ class RenderTableViewport extends RenderTwoDimensionalViewport { )!; Rect getColumnRect(bool consumePadding) { + final double leadingOffsetCorrection = + axisDirectionIsReversed(verticalAxisDirection) + ? leadingCell.size.height + : 0.0; + final double trailingOffsetCorrection = + axisDirectionIsReversed(verticalAxisDirection) + ? trailingCell.size.height + : 0.0; return Rect.fromPoints( parentDataOf(leadingCell).paintOffset! + offset - Offset( consumePadding ? columnSpan.padding.leading : 0.0, - rowSpan.padding.leading, + rowSpan.padding.leading - leadingOffsetCorrection, ), parentDataOf(trailingCell).paintOffset! + offset + Offset(trailingCell.size.width, trailingCell.size.height) + Offset( consumePadding ? columnSpan.padding.trailing : 0.0, - rowSpan.padding.trailing, + rowSpan.padding.trailing - trailingOffsetCorrection, ), ); } if (columnSpan.backgroundDecoration != null) { final Rect rect = getColumnRect( - columnSpan.backgroundDecoration!.consumeSpanPadding); + columnSpan.backgroundDecoration!.consumeSpanPadding, + ); backgroundColumns[rect] = columnSpan.backgroundDecoration!; } if (columnSpan.foregroundDecoration != null) { final Rect rect = getColumnRect( - columnSpan.foregroundDecoration!.consumeSpanPadding); + columnSpan.foregroundDecoration!.consumeSpanPadding, + ); foregroundColumns[rect] = columnSpan.foregroundDecoration!; } } @@ -910,18 +920,26 @@ class RenderTableViewport extends RenderTwoDimensionalViewport { )!; Rect getRowRect(bool consumePadding) { + final double leadingOffsetCorrection = + axisDirectionIsReversed(horizontalAxisDirection) + ? leadingCell.size.height + : 0.0; + final double trailingOffsetCorrection = + axisDirectionIsReversed(horizontalAxisDirection) + ? trailingCell.size.height + : 0.0; return Rect.fromPoints( parentDataOf(leadingCell).paintOffset! + offset - Offset( - columnSpan.padding.leading, + columnSpan.padding.leading - leadingOffsetCorrection, consumePadding ? rowSpan.padding.leading : 0.0, ), parentDataOf(trailingCell).paintOffset! + offset + Offset(trailingCell.size.width, trailingCell.size.height) + Offset( - columnSpan.padding.leading, + columnSpan.padding.leading - trailingOffsetCorrection, consumePadding ? rowSpan.padding.trailing : 0.0, ), ); diff --git a/packages/two_dimensional_scrollables/test/table_view/table_span_test.dart b/packages/two_dimensional_scrollables/test/table_view/table_span_test.dart index fea0d26e9a1..cc13c7f3b58 100644 --- a/packages/two_dimensional_scrollables/test/table_view/table_span_test.dart +++ b/packages/two_dimensional_scrollables/test/table_view/table_span_test.dart @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:two_dimensional_scrollables/two_dimensional_scrollables.dart'; @@ -177,6 +178,670 @@ void main() { expect(border.details, details); expect(border.radius, radius); }); + + group('Decoration rects account for reversed axes', () { + late ScrollController verticalController; + late ScrollController horizontalController; + + setUp(() { + verticalController = ScrollController(); + horizontalController = ScrollController(); + }); + + tearDown(() { + verticalController.dispose(); + horizontalController.dispose(); + }); + + Widget buildCell(BuildContext context, TableVicinity vicinity) { + return const SizedBox.shrink(); + } + + TableSpan buildSpan(bool isColumn) { + return TableSpan( + extent: const FixedTableSpanExtent(100), + // Do with background as well + foregroundDecoration: TableSpanDecoration( + color: isColumn ? const Color(0xFFE1BEE7) : const Color(0xFFBBDEFB), + ), + ); + } + + testWidgets('Vertical main axis, vertical reversed', + (WidgetTester tester) async { + final TableView table = TableView.builder( + verticalDetails: ScrollableDetails.vertical( + controller: verticalController, + reverse: true, + ), + horizontalDetails: ScrollableDetails.horizontal( + controller: horizontalController, + ), + rowCount: 10, + columnCount: 10, + rowBuilder: (_) => buildSpan(false), + columnBuilder: (_) => buildSpan(true), + cellBuilder: buildCell, + ); + await tester.pumpWidget(Directionality( + textDirection: TextDirection.ltr, + child: table, + )); + await tester.pumpAndSettle(); + + expect( + find.byType(TableViewport), + paints + // Rows first, bottom to top for reversed axis + ..rect( + rect: const Rect.fromLTRB(0.0, 500.0, 1000.0, 600.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, 400.0, 1000.0, 500.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, 300.0, 1000.0, 400.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, 200.0, 1000.0, 300.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, 100.0, 1000.0, 200.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, 0.0, 1000.0, 100.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, -100.0, 1000.0, 0.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, -200.0, 1000.0, -100.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, -300.0, 1000.0, -200.0), + color: const Color(0xffbbdefb), + ) + // Columns next + ..rect( + rect: const Rect.fromLTRB(0.0, -300.0, 100.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(100.0, -300.0, 200.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(200.0, -300.0, 300.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(300.0, -300.0, 400.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(400.0, -300.0, 500.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(500.0, -300.0, 600.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(600.0, -300.0, 700.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(700.0, -300.0, 800.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(800.0, -300.0, 900.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(900.0, -300.0, 1000.0, 600.0), + color: const Color(0xffe1bee7), + )); + }); + + testWidgets('Vertical main axis, horizontal reversed', + (WidgetTester tester) async { + final TableView table = TableView.builder( + verticalDetails: ScrollableDetails.vertical( + controller: verticalController, + ), + horizontalDetails: ScrollableDetails.horizontal( + controller: horizontalController, + reverse: true, + ), + rowCount: 10, + columnCount: 10, + rowBuilder: (_) => buildSpan(false), + columnBuilder: (_) => buildSpan(true), + cellBuilder: buildCell, + ); + await tester.pumpWidget(Directionality( + textDirection: TextDirection.ltr, + child: table, + )); + await tester.pumpAndSettle(); + + expect( + find.byType(TableViewport), + paints + // Rows first + ..rect( + rect: const Rect.fromLTRB(-200.0, 0.0, 800.0, 100.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 100.0, 800.0, 200.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 200.0, 800.0, 300.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 300.0, 800.0, 400.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 400.0, 800.0, 500.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 500.0, 800.0, 600.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 600.0, 800.0, 700.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 700.0, 800.0, 800.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 800.0, 800.0, 900.0), + color: const Color(0xffbbdefb), + ) + // Columns next, right to left for reversed axis + ..rect( + rect: const Rect.fromLTRB(700.0, 0.0, 800.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(600.0, 0.0, 700.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(500.0, 0.0, 600.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(400.0, 0.0, 500.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(300.0, 0.0, 400.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(200.0, 0.0, 300.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(100.0, 0.0, 200.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, 0.0, 100.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(-100.0, 0.0, 0.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 0.0, -100.0, 900.0), + color: const Color(0xffe1bee7), + )); + }); + + testWidgets('Vertical main axis, both reversed', + (WidgetTester tester) async { + final TableView table = TableView.builder( + verticalDetails: ScrollableDetails.vertical( + controller: verticalController, + reverse: true, + ), + horizontalDetails: ScrollableDetails.horizontal( + controller: horizontalController, + reverse: true, + ), + rowCount: 10, + columnCount: 10, + rowBuilder: (_) => buildSpan(false), + columnBuilder: (_) => buildSpan(true), + cellBuilder: buildCell, + ); + await tester.pumpWidget(Directionality( + textDirection: TextDirection.ltr, + child: table, + )); + await tester.pumpAndSettle(); + + expect( + find.byType(TableViewport), + paints + // Rows first, bottom to top for reversed axis + ..rect( + rect: const Rect.fromLTRB(-200.0, 500.0, 800.0, 600.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 400.0, 800.0, 500.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 300.0, 800.0, 400.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 200.0, 800.0, 300.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 100.0, 800.0, 200.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 0.0, 800.0, 100.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, -100.0, 800.0, 0.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, -200.0, 800.0, -100.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, -300.0, 800.0, -200.0), + color: const Color(0xffbbdefb), + ) + // Columns next, right to left for reversed axis + ..rect( + rect: const Rect.fromLTRB(700.0, -300.0, 800.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(600.0, -300.0, 700.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(500.0, -300.0, 600.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(400.0, -300.0, 500.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(300.0, -300.0, 400.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(200.0, -300.0, 300.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(100.0, -300.0, 200.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, -300.0, 100.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(-100.0, -300.0, 0.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, -300.0, -100.0, 600.0), + color: const Color(0xffe1bee7), + )); + }); + + testWidgets('Horizontal main axis, vertical reversed', + (WidgetTester tester) async { + final TableView table = TableView.builder( + mainAxis: Axis.horizontal, + verticalDetails: ScrollableDetails.vertical( + controller: verticalController, + reverse: true, + ), + horizontalDetails: ScrollableDetails.horizontal( + controller: horizontalController, + ), + rowCount: 10, + columnCount: 10, + rowBuilder: (_) => buildSpan(false), + columnBuilder: (_) => buildSpan(true), + cellBuilder: buildCell, + ); + await tester.pumpWidget(Directionality( + textDirection: TextDirection.ltr, + child: table, + )); + await tester.pumpAndSettle(); + + expect( + find.byType(TableViewport), + paints + // Columns first + ..rect( + rect: const Rect.fromLTRB(0.0, -300.0, 100.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(100.0, -300.0, 200.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(200.0, -300.0, 300.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(300.0, -300.0, 400.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(400.0, -300.0, 500.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(500.0, -300.0, 600.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(600.0, -300.0, 700.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(700.0, -300.0, 800.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(800.0, -300.0, 900.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(900.0, -300.0, 1000.0, 600.0), + color: const Color(0xffe1bee7), + ) + // Rows next, bottom to top for reversed axis + ..rect( + rect: const Rect.fromLTRB(0.0, 500.0, 1000.0, 600.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, 400.0, 1000.0, 500.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, 300.0, 1000.0, 400.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, 200.0, 1000.0, 300.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, 100.0, 1000.0, 200.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, 0.0, 1000.0, 100.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, -100.0, 1000.0, 0.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, -200.0, 1000.0, -100.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, -300.0, 1000.0, -200.0), + color: const Color(0xffbbdefb), + )); + }); + + testWidgets('Horizontal main axis, horizontal reversed', + (WidgetTester tester) async { + final TableView table = TableView.builder( + mainAxis: Axis.horizontal, + verticalDetails: ScrollableDetails.vertical( + controller: verticalController, + ), + horizontalDetails: ScrollableDetails.horizontal( + controller: horizontalController, + reverse: true, + ), + rowCount: 10, + columnCount: 10, + rowBuilder: (_) => buildSpan(false), + columnBuilder: (_) => buildSpan(true), + cellBuilder: buildCell, + ); + await tester.pumpWidget(Directionality( + textDirection: TextDirection.ltr, + child: table, + )); + await tester.pumpAndSettle(); + + expect( + find.byType(TableViewport), + paints + // Columns first, right to left for reversed axis + ..rect( + rect: const Rect.fromLTRB(700.0, 0.0, 800.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(600.0, 0.0, 700.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(500.0, 0.0, 600.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(400.0, 0.0, 500.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(300.0, 0.0, 400.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(200.0, 0.0, 300.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(100.0, 0.0, 200.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, 0.0, 100.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(-100.0, 0.0, 0.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 0.0, -100.0, 900.0), + color: const Color(0xffe1bee7), + ) + // Rows next + ..rect( + rect: const Rect.fromLTRB(-200.0, 0.0, 800.0, 100.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 100.0, 800.0, 200.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 200.0, 800.0, 300.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 300.0, 800.0, 400.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 400.0, 800.0, 500.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 500.0, 800.0, 600.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 600.0, 800.0, 700.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 700.0, 800.0, 800.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 800.0, 800.0, 900.0), + color: const Color(0xffbbdefb), + )); + }); + + testWidgets('Horizontal main axis, both reversed', + (WidgetTester tester) async { + final TableView table = TableView.builder( + mainAxis: Axis.horizontal, + verticalDetails: ScrollableDetails.vertical( + controller: verticalController, + reverse: true, + ), + horizontalDetails: ScrollableDetails.horizontal( + controller: horizontalController, + reverse: true, + ), + rowCount: 10, + columnCount: 10, + rowBuilder: (_) => buildSpan(false), + columnBuilder: (_) => buildSpan(true), + cellBuilder: buildCell, + ); + await tester.pumpWidget(Directionality( + textDirection: TextDirection.ltr, + child: table, + )); + await tester.pumpAndSettle(); + + expect( + find.byType(TableViewport), + paints + // Columns first, right to left for reversed axis + ..rect( + rect: const Rect.fromLTRB(700.0, -300.0, 800.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(600.0, -300.0, 700.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(500.0, -300.0, 600.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(400.0, -300.0, 500.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(300.0, -300.0, 400.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(200.0, -300.0, 300.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(100.0, -300.0, 200.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, -300.0, 100.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(-100.0, -300.0, 0.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, -300.0, -100.0, 600.0), + color: const Color(0xffe1bee7), + ) + // Rows next, bottom to top for reversed axis + ..rect( + rect: const Rect.fromLTRB(-200.0, 500.0, 800.0, 600.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 400.0, 800.0, 500.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 300.0, 800.0, 400.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 200.0, 800.0, 300.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 100.0, 800.0, 200.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 0.0, 800.0, 100.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, -100.0, 800.0, 0.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, -200.0, 800.0, -100.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, -300.0, 800.0, -200.0), + color: const Color(0xffbbdefb), + )); + }); + }); } class TestCanvas implements Canvas { From f4c7799819c16ab3ef7bebe494755aef9a3c20f7 Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Wed, 17 Jan 2024 16:38:11 -0600 Subject: [PATCH 2/3] Self review --- packages/two_dimensional_scrollables/CHANGELOG.md | 4 ++++ packages/two_dimensional_scrollables/pubspec.yaml | 2 +- .../test/table_view/table_span_test.dart | 2 -- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/two_dimensional_scrollables/CHANGELOG.md b/packages/two_dimensional_scrollables/CHANGELOG.md index e2a6474c31e..6b04d1bf63c 100644 --- a/packages/two_dimensional_scrollables/CHANGELOG.md +++ b/packages/two_dimensional_scrollables/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.0.6 + +* Fixes an error in TableSpanDecoration when one or both axes are reversed. + ## 0.0.5+2 * Fixes must_call_super lint warning from pending framework change. diff --git a/packages/two_dimensional_scrollables/pubspec.yaml b/packages/two_dimensional_scrollables/pubspec.yaml index d8a9f961528..5d1ede3d73f 100644 --- a/packages/two_dimensional_scrollables/pubspec.yaml +++ b/packages/two_dimensional_scrollables/pubspec.yaml @@ -1,6 +1,6 @@ name: two_dimensional_scrollables description: Widgets that scroll using the two dimensional scrolling foundation. -version: 0.0.5+2 +version: 0.0.6 repository: https://github.com/flutter/packages/tree/main/packages/two_dimensional_scrollables issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+two_dimensional_scrollables%22+ diff --git a/packages/two_dimensional_scrollables/test/table_view/table_span_test.dart b/packages/two_dimensional_scrollables/test/table_view/table_span_test.dart index cc13c7f3b58..0980ea2bd84 100644 --- a/packages/two_dimensional_scrollables/test/table_view/table_span_test.dart +++ b/packages/two_dimensional_scrollables/test/table_view/table_span_test.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:two_dimensional_scrollables/two_dimensional_scrollables.dart'; @@ -200,7 +199,6 @@ void main() { TableSpan buildSpan(bool isColumn) { return TableSpan( extent: const FixedTableSpanExtent(100), - // Do with background as well foregroundDecoration: TableSpanDecoration( color: isColumn ? const Color(0xFFE1BEE7) : const Color(0xFFBBDEFB), ), From 243dcd8077bb10ea63957e69cd36ada5d42eef09 Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Mon, 22 Jan 2024 16:55:14 -0600 Subject: [PATCH 3/3] Review feedback --- .../lib/src/table_view/table.dart | 35 +- .../test/table_view/table_span_test.dart | 966 +++++++++--------- 2 files changed, 503 insertions(+), 498 deletions(-) diff --git a/packages/two_dimensional_scrollables/lib/src/table_view/table.dart b/packages/two_dimensional_scrollables/lib/src/table_view/table.dart index 4e43ff065f2..a8d9a0cc99d 100644 --- a/packages/two_dimensional_scrollables/lib/src/table_view/table.dart +++ b/packages/two_dimensional_scrollables/lib/src/table_view/table.dart @@ -861,27 +861,27 @@ class RenderTableViewport extends RenderTwoDimensionalViewport { )!; Rect getColumnRect(bool consumePadding) { - final double leadingOffsetCorrection = + final ({double leading, double trailing}) offsetCorrection = axisDirectionIsReversed(verticalAxisDirection) - ? leadingCell.size.height - : 0.0; - final double trailingOffsetCorrection = - axisDirectionIsReversed(verticalAxisDirection) - ? trailingCell.size.height - : 0.0; + ? ( + leading: leadingCell.size.height, + trailing: trailingCell.size.height, + ) + : (leading: 0.0, trailing: 0.0); + return Rect.fromPoints( parentDataOf(leadingCell).paintOffset! + offset - Offset( consumePadding ? columnSpan.padding.leading : 0.0, - rowSpan.padding.leading - leadingOffsetCorrection, + rowSpan.padding.leading - offsetCorrection.leading, ), parentDataOf(trailingCell).paintOffset! + offset + Offset(trailingCell.size.width, trailingCell.size.height) + Offset( consumePadding ? columnSpan.padding.trailing : 0.0, - rowSpan.padding.trailing - trailingOffsetCorrection, + rowSpan.padding.trailing - offsetCorrection.trailing, ), ); } @@ -920,26 +920,25 @@ class RenderTableViewport extends RenderTwoDimensionalViewport { )!; Rect getRowRect(bool consumePadding) { - final double leadingOffsetCorrection = - axisDirectionIsReversed(horizontalAxisDirection) - ? leadingCell.size.height - : 0.0; - final double trailingOffsetCorrection = + final ({double leading, double trailing}) offsetCorrection = axisDirectionIsReversed(horizontalAxisDirection) - ? trailingCell.size.height - : 0.0; + ? ( + leading: leadingCell.size.width, + trailing: trailingCell.size.width, + ) + : (leading: 0.0, trailing: 0.0); return Rect.fromPoints( parentDataOf(leadingCell).paintOffset! + offset - Offset( - columnSpan.padding.leading - leadingOffsetCorrection, + columnSpan.padding.leading - offsetCorrection.leading, consumePadding ? rowSpan.padding.leading : 0.0, ), parentDataOf(trailingCell).paintOffset! + offset + Offset(trailingCell.size.width, trailingCell.size.height) + Offset( - columnSpan.padding.leading - trailingOffsetCorrection, + columnSpan.padding.leading - offsetCorrection.trailing, consumePadding ? rowSpan.padding.trailing : 0.0, ), ); diff --git a/packages/two_dimensional_scrollables/test/table_view/table_span_test.dart b/packages/two_dimensional_scrollables/test/table_view/table_span_test.dart index 0980ea2bd84..b6b0db398e2 100644 --- a/packages/two_dimensional_scrollables/test/table_view/table_span_test.dart +++ b/packages/two_dimensional_scrollables/test/table_view/table_span_test.dart @@ -228,86 +228,87 @@ void main() { await tester.pumpAndSettle(); expect( - find.byType(TableViewport), - paints - // Rows first, bottom to top for reversed axis - ..rect( - rect: const Rect.fromLTRB(0.0, 500.0, 1000.0, 600.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(0.0, 400.0, 1000.0, 500.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(0.0, 300.0, 1000.0, 400.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(0.0, 200.0, 1000.0, 300.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(0.0, 100.0, 1000.0, 200.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(0.0, 0.0, 1000.0, 100.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(0.0, -100.0, 1000.0, 0.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(0.0, -200.0, 1000.0, -100.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(0.0, -300.0, 1000.0, -200.0), - color: const Color(0xffbbdefb), - ) - // Columns next - ..rect( - rect: const Rect.fromLTRB(0.0, -300.0, 100.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(100.0, -300.0, 200.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(200.0, -300.0, 300.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(300.0, -300.0, 400.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(400.0, -300.0, 500.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(500.0, -300.0, 600.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(600.0, -300.0, 700.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(700.0, -300.0, 800.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(800.0, -300.0, 900.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(900.0, -300.0, 1000.0, 600.0), - color: const Color(0xffe1bee7), - )); + find.byType(TableViewport), + paints + // Rows first, bottom to top for reversed axis + ..rect( + rect: const Rect.fromLTRB(0.0, 500.0, 1000.0, 600.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, 400.0, 1000.0, 500.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, 300.0, 1000.0, 400.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, 200.0, 1000.0, 300.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, 100.0, 1000.0, 200.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, 0.0, 1000.0, 100.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, -100.0, 1000.0, 0.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, -200.0, 1000.0, -100.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, -300.0, 1000.0, -200.0), + color: const Color(0xffbbdefb), + ) + // Columns next + ..rect( + rect: const Rect.fromLTRB(0.0, -300.0, 100.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(100.0, -300.0, 200.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(200.0, -300.0, 300.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(300.0, -300.0, 400.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(400.0, -300.0, 500.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(500.0, -300.0, 600.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(600.0, -300.0, 700.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(700.0, -300.0, 800.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(800.0, -300.0, 900.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(900.0, -300.0, 1000.0, 600.0), + color: const Color(0xffe1bee7), + ), + ); }); testWidgets('Vertical main axis, horizontal reversed', @@ -333,86 +334,87 @@ void main() { await tester.pumpAndSettle(); expect( - find.byType(TableViewport), - paints - // Rows first - ..rect( - rect: const Rect.fromLTRB(-200.0, 0.0, 800.0, 100.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, 100.0, 800.0, 200.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, 200.0, 800.0, 300.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, 300.0, 800.0, 400.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, 400.0, 800.0, 500.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, 500.0, 800.0, 600.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, 600.0, 800.0, 700.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, 700.0, 800.0, 800.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, 800.0, 800.0, 900.0), - color: const Color(0xffbbdefb), - ) - // Columns next, right to left for reversed axis - ..rect( - rect: const Rect.fromLTRB(700.0, 0.0, 800.0, 900.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(600.0, 0.0, 700.0, 900.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(500.0, 0.0, 600.0, 900.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(400.0, 0.0, 500.0, 900.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(300.0, 0.0, 400.0, 900.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(200.0, 0.0, 300.0, 900.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(100.0, 0.0, 200.0, 900.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(0.0, 0.0, 100.0, 900.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(-100.0, 0.0, 0.0, 900.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, 0.0, -100.0, 900.0), - color: const Color(0xffe1bee7), - )); + find.byType(TableViewport), + paints + // Rows first + ..rect( + rect: const Rect.fromLTRB(-200.0, 0.0, 800.0, 100.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 100.0, 800.0, 200.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 200.0, 800.0, 300.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 300.0, 800.0, 400.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 400.0, 800.0, 500.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 500.0, 800.0, 600.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 600.0, 800.0, 700.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 700.0, 800.0, 800.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 800.0, 800.0, 900.0), + color: const Color(0xffbbdefb), + ) + // Columns next, right to left for reversed axis + ..rect( + rect: const Rect.fromLTRB(700.0, 0.0, 800.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(600.0, 0.0, 700.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(500.0, 0.0, 600.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(400.0, 0.0, 500.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(300.0, 0.0, 400.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(200.0, 0.0, 300.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(100.0, 0.0, 200.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, 0.0, 100.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(-100.0, 0.0, 0.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 0.0, -100.0, 900.0), + color: const Color(0xffe1bee7), + ), + ); }); testWidgets('Vertical main axis, both reversed', @@ -439,86 +441,87 @@ void main() { await tester.pumpAndSettle(); expect( - find.byType(TableViewport), - paints - // Rows first, bottom to top for reversed axis - ..rect( - rect: const Rect.fromLTRB(-200.0, 500.0, 800.0, 600.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, 400.0, 800.0, 500.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, 300.0, 800.0, 400.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, 200.0, 800.0, 300.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, 100.0, 800.0, 200.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, 0.0, 800.0, 100.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, -100.0, 800.0, 0.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, -200.0, 800.0, -100.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, -300.0, 800.0, -200.0), - color: const Color(0xffbbdefb), - ) - // Columns next, right to left for reversed axis - ..rect( - rect: const Rect.fromLTRB(700.0, -300.0, 800.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(600.0, -300.0, 700.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(500.0, -300.0, 600.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(400.0, -300.0, 500.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(300.0, -300.0, 400.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(200.0, -300.0, 300.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(100.0, -300.0, 200.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(0.0, -300.0, 100.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(-100.0, -300.0, 0.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, -300.0, -100.0, 600.0), - color: const Color(0xffe1bee7), - )); + find.byType(TableViewport), + paints + // Rows first, bottom to top for reversed axis + ..rect( + rect: const Rect.fromLTRB(-200.0, 500.0, 800.0, 600.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 400.0, 800.0, 500.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 300.0, 800.0, 400.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 200.0, 800.0, 300.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 100.0, 800.0, 200.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 0.0, 800.0, 100.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, -100.0, 800.0, 0.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, -200.0, 800.0, -100.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, -300.0, 800.0, -200.0), + color: const Color(0xffbbdefb), + ) + // Columns next, right to left for reversed axis + ..rect( + rect: const Rect.fromLTRB(700.0, -300.0, 800.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(600.0, -300.0, 700.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(500.0, -300.0, 600.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(400.0, -300.0, 500.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(300.0, -300.0, 400.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(200.0, -300.0, 300.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(100.0, -300.0, 200.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, -300.0, 100.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(-100.0, -300.0, 0.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, -300.0, -100.0, 600.0), + color: const Color(0xffe1bee7), + ), + ); }); testWidgets('Horizontal main axis, vertical reversed', @@ -545,86 +548,87 @@ void main() { await tester.pumpAndSettle(); expect( - find.byType(TableViewport), - paints - // Columns first - ..rect( - rect: const Rect.fromLTRB(0.0, -300.0, 100.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(100.0, -300.0, 200.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(200.0, -300.0, 300.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(300.0, -300.0, 400.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(400.0, -300.0, 500.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(500.0, -300.0, 600.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(600.0, -300.0, 700.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(700.0, -300.0, 800.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(800.0, -300.0, 900.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(900.0, -300.0, 1000.0, 600.0), - color: const Color(0xffe1bee7), - ) - // Rows next, bottom to top for reversed axis - ..rect( - rect: const Rect.fromLTRB(0.0, 500.0, 1000.0, 600.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(0.0, 400.0, 1000.0, 500.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(0.0, 300.0, 1000.0, 400.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(0.0, 200.0, 1000.0, 300.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(0.0, 100.0, 1000.0, 200.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(0.0, 0.0, 1000.0, 100.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(0.0, -100.0, 1000.0, 0.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(0.0, -200.0, 1000.0, -100.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(0.0, -300.0, 1000.0, -200.0), - color: const Color(0xffbbdefb), - )); + find.byType(TableViewport), + paints + // Columns first + ..rect( + rect: const Rect.fromLTRB(0.0, -300.0, 100.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(100.0, -300.0, 200.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(200.0, -300.0, 300.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(300.0, -300.0, 400.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(400.0, -300.0, 500.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(500.0, -300.0, 600.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(600.0, -300.0, 700.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(700.0, -300.0, 800.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(800.0, -300.0, 900.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(900.0, -300.0, 1000.0, 600.0), + color: const Color(0xffe1bee7), + ) + // Rows next, bottom to top for reversed axis + ..rect( + rect: const Rect.fromLTRB(0.0, 500.0, 1000.0, 600.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, 400.0, 1000.0, 500.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, 300.0, 1000.0, 400.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, 200.0, 1000.0, 300.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, 100.0, 1000.0, 200.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, 0.0, 1000.0, 100.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, -100.0, 1000.0, 0.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, -200.0, 1000.0, -100.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, -300.0, 1000.0, -200.0), + color: const Color(0xffbbdefb), + ), + ); }); testWidgets('Horizontal main axis, horizontal reversed', @@ -651,86 +655,87 @@ void main() { await tester.pumpAndSettle(); expect( - find.byType(TableViewport), - paints - // Columns first, right to left for reversed axis - ..rect( - rect: const Rect.fromLTRB(700.0, 0.0, 800.0, 900.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(600.0, 0.0, 700.0, 900.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(500.0, 0.0, 600.0, 900.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(400.0, 0.0, 500.0, 900.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(300.0, 0.0, 400.0, 900.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(200.0, 0.0, 300.0, 900.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(100.0, 0.0, 200.0, 900.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(0.0, 0.0, 100.0, 900.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(-100.0, 0.0, 0.0, 900.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, 0.0, -100.0, 900.0), - color: const Color(0xffe1bee7), - ) - // Rows next - ..rect( - rect: const Rect.fromLTRB(-200.0, 0.0, 800.0, 100.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, 100.0, 800.0, 200.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, 200.0, 800.0, 300.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, 300.0, 800.0, 400.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, 400.0, 800.0, 500.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, 500.0, 800.0, 600.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, 600.0, 800.0, 700.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, 700.0, 800.0, 800.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, 800.0, 800.0, 900.0), - color: const Color(0xffbbdefb), - )); + find.byType(TableViewport), + paints + // Columns first, right to left for reversed axis + ..rect( + rect: const Rect.fromLTRB(700.0, 0.0, 800.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(600.0, 0.0, 700.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(500.0, 0.0, 600.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(400.0, 0.0, 500.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(300.0, 0.0, 400.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(200.0, 0.0, 300.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(100.0, 0.0, 200.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, 0.0, 100.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(-100.0, 0.0, 0.0, 900.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 0.0, -100.0, 900.0), + color: const Color(0xffe1bee7), + ) + // Rows next + ..rect( + rect: const Rect.fromLTRB(-200.0, 0.0, 800.0, 100.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 100.0, 800.0, 200.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 200.0, 800.0, 300.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 300.0, 800.0, 400.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 400.0, 800.0, 500.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 500.0, 800.0, 600.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 600.0, 800.0, 700.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 700.0, 800.0, 800.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 800.0, 800.0, 900.0), + color: const Color(0xffbbdefb), + ), + ); }); testWidgets('Horizontal main axis, both reversed', @@ -758,86 +763,87 @@ void main() { await tester.pumpAndSettle(); expect( - find.byType(TableViewport), - paints - // Columns first, right to left for reversed axis - ..rect( - rect: const Rect.fromLTRB(700.0, -300.0, 800.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(600.0, -300.0, 700.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(500.0, -300.0, 600.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(400.0, -300.0, 500.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(300.0, -300.0, 400.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(200.0, -300.0, 300.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(100.0, -300.0, 200.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(0.0, -300.0, 100.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(-100.0, -300.0, 0.0, 600.0), - color: const Color(0xffe1bee7), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, -300.0, -100.0, 600.0), - color: const Color(0xffe1bee7), - ) - // Rows next, bottom to top for reversed axis - ..rect( - rect: const Rect.fromLTRB(-200.0, 500.0, 800.0, 600.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, 400.0, 800.0, 500.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, 300.0, 800.0, 400.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, 200.0, 800.0, 300.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, 100.0, 800.0, 200.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, 0.0, 800.0, 100.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, -100.0, 800.0, 0.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, -200.0, 800.0, -100.0), - color: const Color(0xffbbdefb), - ) - ..rect( - rect: const Rect.fromLTRB(-200.0, -300.0, 800.0, -200.0), - color: const Color(0xffbbdefb), - )); + find.byType(TableViewport), + paints + // Columns first, right to left for reversed axis + ..rect( + rect: const Rect.fromLTRB(700.0, -300.0, 800.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(600.0, -300.0, 700.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(500.0, -300.0, 600.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(400.0, -300.0, 500.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(300.0, -300.0, 400.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(200.0, -300.0, 300.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(100.0, -300.0, 200.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(0.0, -300.0, 100.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(-100.0, -300.0, 0.0, 600.0), + color: const Color(0xffe1bee7), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, -300.0, -100.0, 600.0), + color: const Color(0xffe1bee7), + ) + // Rows next, bottom to top for reversed axis + ..rect( + rect: const Rect.fromLTRB(-200.0, 500.0, 800.0, 600.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 400.0, 800.0, 500.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 300.0, 800.0, 400.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 200.0, 800.0, 300.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 100.0, 800.0, 200.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, 0.0, 800.0, 100.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, -100.0, 800.0, 0.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, -200.0, 800.0, -100.0), + color: const Color(0xffbbdefb), + ) + ..rect( + rect: const Rect.fromLTRB(-200.0, -300.0, 800.0, -200.0), + color: const Color(0xffbbdefb), + ), + ); }); }); }