From f805419816720c5d3830e78d5030a64d2f71a27f Mon Sep 17 00:00:00 2001 From: Gordon Hayes Date: Mon, 18 Oct 2021 11:42:39 +0200 Subject: [PATCH] chore: linting --- .../lib/src/message_widget.dart | 10 ++- .../src/element_registry.dart | 8 +- .../src/item_positions_listener.dart | 11 +-- .../src/positioned_list.dart | 81 ++++++++++--------- .../src/scrollable_positioned_list.dart | 66 +++++++-------- .../src/viewport.dart | 77 ++++++++++-------- ...ontal_scrollable_positioned_list_test.dart | 16 ++-- .../positioned_list_test.dart | 6 +- .../reversed_positioned_list_test.dart | 8 +- ...ersed_scrollable_positioned_list_test.dart | 8 +- .../scrollable_positioned_list_test.dart | 16 ++-- .../separated_positioned_list_test.dart | 2 +- ...rated_scrollable_positioned_list_test.dart | 6 +- ...ontal_scrollable_positioned_list_test.dart | 4 +- 14 files changed, 170 insertions(+), 149 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/message_widget.dart b/packages/stream_chat_flutter/lib/src/message_widget.dart index b0155545..f6ae52c6 100644 --- a/packages/stream_chat_flutter/lib/src/message_widget.dart +++ b/packages/stream_chat_flutter/lib/src/message_widget.dart @@ -678,14 +678,16 @@ class _MessageWidgetState extends State ? Container( transform: Matrix4.translationValues( - widget.reverse ? 12 : -12, - 0, - 0), + widget.reverse ? 12 : -12, + 0, + 0, + ), constraints: const BoxConstraints( maxWidth: 22 * 6.0, ), child: _buildReactionIndicator( - context), + context, + ), ) : null, portalAnchor: diff --git a/packages/stream_chat_flutter/lib/src/scrollable_positioned_list/src/element_registry.dart b/packages/stream_chat_flutter/lib/src/scrollable_positioned_list/src/element_registry.dart index f4327246..218e2ca0 100644 --- a/packages/stream_chat_flutter/lib/src/scrollable_positioned_list/src/element_registry.dart +++ b/packages/stream_chat_flutter/lib/src/scrollable_positioned_list/src/element_registry.dart @@ -46,9 +46,11 @@ class _RegistryWidgetState extends State { } class _InheritedRegistryWidget extends InheritedWidget { - const _InheritedRegistryWidget( - {Key? key, required this.state, required Widget child}) - : super(key: key, child: child); + const _InheritedRegistryWidget({ + Key? key, + required this.state, + required Widget child, + }) : super(key: key, child: child); final _RegistryWidgetState state; diff --git a/packages/stream_chat_flutter/lib/src/scrollable_positioned_list/src/item_positions_listener.dart b/packages/stream_chat_flutter/lib/src/scrollable_positioned_list/src/item_positions_listener.dart index 886cabe7..fbfd9c56 100644 --- a/packages/stream_chat_flutter/lib/src/scrollable_positioned_list/src/item_positions_listener.dart +++ b/packages/stream_chat_flutter/lib/src/scrollable_positioned_list/src/item_positions_listener.dart @@ -21,10 +21,11 @@ abstract class ItemPositionsListener { /// Position information for an item in the list. class ItemPosition { /// Create an [ItemPosition]. - const ItemPosition( - {required this.index, - required this.itemLeadingEdge, - required this.itemTrailingEdge}); + const ItemPosition({ + required this.index, + required this.itemLeadingEdge, + required this.itemTrailingEdge, + }); /// Index of the item. final int index; @@ -52,7 +53,7 @@ class ItemPosition { @override int get hashCode => - 31 * (31 * (7 + index.hashCode) + itemLeadingEdge.hashCode) + + 31 * (31 * (index.hashCode + 7) + itemLeadingEdge.hashCode) + itemTrailingEdge.hashCode; @override diff --git a/packages/stream_chat_flutter/lib/src/scrollable_positioned_list/src/positioned_list.dart b/packages/stream_chat_flutter/lib/src/scrollable_positioned_list/src/positioned_list.dart index 43f3d9ab..03376fb3 100644 --- a/packages/stream_chat_flutter/lib/src/scrollable_positioned_list/src/positioned_list.dart +++ b/packages/stream_chat_flutter/lib/src/scrollable_positioned_list/src/positioned_list.dart @@ -187,10 +187,11 @@ class _PositionedListState extends State { (context, index) => widget.separatorBuilder == null ? _buildItem(widget.positionedIndex - (index + 1)) : _buildSeparatedListElement( - 2 * widget.positionedIndex - (index + 1)), + widget.positionedIndex * 2 - (index + 1), + ), childCount: widget.separatorBuilder == null ? widget.positionedIndex - : 2 * widget.positionedIndex, + : widget.positionedIndex * 2, addSemanticIndexes: false, findChildIndexCallback: widget.findChildIndexCallback, addRepaintBoundaries: widget.addRepaintBoundaries, @@ -206,7 +207,8 @@ class _PositionedListState extends State { (context, index) => widget.separatorBuilder == null ? _buildItem(index + widget.positionedIndex) : _buildSeparatedListElement( - index + 2 * widget.positionedIndex), + index + widget.positionedIndex * 2, + ), childCount: widget.itemCount != 0 ? 1 : 0, findChildIndexCallback: widget.findChildIndexCallback, addSemanticIndexes: false, @@ -224,7 +226,8 @@ class _PositionedListState extends State { (context, index) => widget.separatorBuilder == null ? _buildItem(index + widget.positionedIndex + 1) : _buildSeparatedListElement( - index + 2 * widget.positionedIndex + 1), + index + widget.positionedIndex * 2 + 1, + ), childCount: widget.separatorBuilder == null ? widget.itemCount - widget.positionedIndex - 1 : 2 * (widget.itemCount - widget.positionedIndex - 1), @@ -270,27 +273,27 @@ class _PositionedListState extends State { EdgeInsets get _centerSliverPadding => widget.scrollDirection == Axis.vertical ? widget.reverse ? widget.padding?.copyWith( - top: widget.positionedIndex == widget.itemCount - 1 - ? widget.padding!.top - : 0, - bottom: widget.positionedIndex == 0 - ? widget.padding!.bottom - : 0) ?? + top: widget.positionedIndex == widget.itemCount - 1 + ? widget.padding!.top + : 0, + bottom: + widget.positionedIndex == 0 ? widget.padding!.bottom : 0, + ) ?? const EdgeInsets.all(0) : widget.padding?.copyWith( - top: widget.positionedIndex == 0 ? widget.padding!.top : 0, - bottom: widget.positionedIndex == widget.itemCount - 1 - ? widget.padding!.bottom - : 0) ?? + top: widget.positionedIndex == 0 ? widget.padding!.top : 0, + bottom: widget.positionedIndex == widget.itemCount - 1 + ? widget.padding!.bottom + : 0, + ) ?? const EdgeInsets.all(0) : widget.reverse ? widget.padding?.copyWith( - left: widget.positionedIndex == widget.itemCount - 1 - ? widget.padding!.left - : 0, - right: widget.positionedIndex == 0 - ? widget.padding!.right - : 0) ?? + left: widget.positionedIndex == widget.itemCount - 1 + ? widget.padding!.left + : 0, + right: widget.positionedIndex == 0 ? widget.padding!.right : 0, + ) ?? const EdgeInsets.all(0) : widget.padding?.copyWith( left: widget.positionedIndex == 0 ? widget.padding!.left : 0, @@ -329,28 +332,30 @@ class _PositionedListState extends State { viewport.offset.pixels + viewport.anchor * viewport.size.height; positions.add(ItemPosition( - index: key.index, - itemLeadingEdge: itemOffset.round() / - scrollController.position.viewportDimension, - itemTrailingEdge: (itemOffset + box.size.height).round() / - scrollController.position.viewportDimension)); + index: key.index, + itemLeadingEdge: itemOffset.round() / + scrollController.position.viewportDimension, + itemTrailingEdge: (itemOffset + box.size.height).round() / + scrollController.position.viewportDimension, + )); } else { final itemOffset = box.localToGlobal(Offset.zero, ancestor: viewport).dx; positions.add(ItemPosition( - index: key.index, - itemLeadingEdge: (widget.reverse - ? scrollController.position.viewportDimension - - (itemOffset + box.size.width) - : itemOffset) - .round() / - scrollController.position.viewportDimension, - itemTrailingEdge: (widget.reverse - ? scrollController.position.viewportDimension - - itemOffset - : (itemOffset + box.size.width)) - .round() / - scrollController.position.viewportDimension)); + index: key.index, + itemLeadingEdge: (widget.reverse + ? scrollController.position.viewportDimension - + (itemOffset + box.size.width) + : itemOffset) + .round() / + scrollController.position.viewportDimension, + itemTrailingEdge: (widget.reverse + ? scrollController.position.viewportDimension - + itemOffset + : (itemOffset + box.size.width)) + .round() / + scrollController.position.viewportDimension, + )); } } widget.itemPositionsNotifier?.itemPositions.value = positions; diff --git a/packages/stream_chat_flutter/lib/src/scrollable_positioned_list/src/scrollable_positioned_list.dart b/packages/stream_chat_flutter/lib/src/scrollable_positioned_list/src/scrollable_positioned_list.dart index 704ed221..98ce0dbf 100644 --- a/packages/stream_chat_flutter/lib/src/scrollable_positioned_list/src/scrollable_positioned_list.dart +++ b/packages/stream_chat_flutter/lib/src/scrollable_positioned_list/src/scrollable_positioned_list.dart @@ -315,20 +315,14 @@ class _ScrollablePositionedListState extends State } if (widget.itemCount == 0) { - setState(() { - primary.target = 0; - secondary.target = 0; - }); + primary.target = 0; + secondary.target = 0; } else { if (primary.target > widget.itemCount - 1) { - setState(() { - primary.target = widget.itemCount - 1; - }); + primary.target = widget.itemCount - 1; } if (secondary.target > widget.itemCount - 1) { - setState(() { - secondary.target = widget.itemCount - 1; - }); + secondary.target = widget.itemCount - 1; } } } @@ -465,19 +459,21 @@ class _ScrollablePositionedListState extends State required List opacityAnimationWeights, }) async { final direction = index > primary.target ? 1 : -1; - final itemPosition = primary.itemPositionsNotifier.itemPositions.value - .firstWhereOrNull( - (ItemPosition itemPosition) => itemPosition.index == index); + final itemPosition = + primary.itemPositionsNotifier.itemPositions.value.firstWhereOrNull( + (ItemPosition itemPosition) => itemPosition.index == index, + ); if (itemPosition != null) { // Scroll directly. final localScrollAmount = itemPosition.itemLeadingEdge * primary.scrollController.position.viewportDimension; await primary.scrollController.animateTo( - primary.scrollController.offset + - localScrollAmount - - alignment * primary.scrollController.position.viewportDimension, - duration: duration, - curve: curve); + primary.scrollController.offset + + localScrollAmount - + alignment * primary.scrollController.position.viewportDimension, + duration: duration, + curve: curve, + ); } else { final scrollAmount = _screenScrollCount * primary.scrollController.position.viewportDimension; @@ -488,7 +484,8 @@ class _ScrollablePositionedListState extends State startAnimationCallback = () {}; opacity.parent = _opacityAnimation(opacityAnimationWeights).animate( - AnimationController(vsync: this, duration: duration)..forward()); + AnimationController(vsync: this, duration: duration)..forward(), + ); secondary.scrollController.jumpTo(-direction * (_screenScrollCount * primary.scrollController.position.viewportDimension - @@ -496,9 +493,10 @@ class _ScrollablePositionedListState extends State secondary.scrollController.position.viewportDimension)); startCompleter.complete(primary.scrollController.animateTo( - primary.scrollController.offset + direction * scrollAmount, - duration: duration, - curve: curve)); + primary.scrollController.offset + direction * scrollAmount, + duration: duration, + curve: curve, + )); endCompleter.complete(secondary.scrollController .animateTo(0, duration: duration, curve: curve)); }); @@ -548,14 +546,17 @@ class _ScrollablePositionedListState extends State const endOpacity = 1.0; return TweenSequence(>[ TweenSequenceItem( - tween: ConstantTween(startOpacity), - weight: opacityAnimationWeights[0]), + tween: ConstantTween(startOpacity), + weight: opacityAnimationWeights[0], + ), TweenSequenceItem( - tween: Tween(begin: startOpacity, end: endOpacity), - weight: opacityAnimationWeights[1]), + tween: Tween(begin: startOpacity, end: endOpacity), + weight: opacityAnimationWeights[1], + ), TweenSequenceItem( - tween: ConstantTween(endOpacity), - weight: opacityAnimationWeights[2]), + tween: ConstantTween(endOpacity), + weight: opacityAnimationWeights[2], + ), ]); } @@ -565,11 +566,10 @@ class _ScrollablePositionedListState extends State position.itemLeadingEdge < 1 && position.itemTrailingEdge > 0); if (itemPositions.isNotEmpty) { PageStorage.of(context)!.writeState( - context, - itemPositions.reduce((value, element) => - value.itemLeadingEdge < element.itemLeadingEdge - ? value - : element)); + context, + itemPositions.reduce((value, element) => + value.itemLeadingEdge < element.itemLeadingEdge ? value : element), + ); } widget.itemPositionsNotifier?.itemPositions.value = itemPositions; } diff --git a/packages/stream_chat_flutter/lib/src/scrollable_positioned_list/src/viewport.dart b/packages/stream_chat_flutter/lib/src/scrollable_positioned_list/src/viewport.dart index 7e307040..01dce022 100644 --- a/packages/stream_chat_flutter/lib/src/scrollable_positioned_list/src/viewport.dart +++ b/packages/stream_chat_flutter/lib/src/scrollable_positioned_list/src/viewport.dart @@ -29,13 +29,14 @@ class UnboundedViewport extends Viewport { List slivers = const [], }) : _anchor = anchor, super( - key: key, - axisDirection: axisDirection, - crossAxisDirection: crossAxisDirection, - offset: offset, - center: center, - cacheExtent: cacheExtent, - slivers: slivers); + key: key, + axisDirection: axisDirection, + crossAxisDirection: crossAxisDirection, + offset: offset, + center: center, + cacheExtent: cacheExtent, + slivers: slivers, + ); // [Viewport] enforces constraints on [Viewport.anchor], so we need our own // version. @@ -76,12 +77,13 @@ class UnboundedRenderViewport extends RenderViewport { double? cacheExtent, }) : _anchor = anchor, super( - axisDirection: axisDirection, - crossAxisDirection: crossAxisDirection, - offset: offset, - center: center, - cacheExtent: cacheExtent, - children: children); + axisDirection: axisDirection, + crossAxisDirection: crossAxisDirection, + offset: offset, + center: center, + cacheExtent: cacheExtent, + children: children, + ); static const int _maxLayoutCycles = 10; @@ -179,8 +181,11 @@ class UnboundedRenderViewport extends RenderViewport { double correction; var count = 0; do { - correction = _attemptLayout(mainAxisExtent, crossAxisExtent, - offset.pixels + centerOffsetAdjustment); + correction = _attemptLayout( + mainAxisExtent, + crossAxisExtent, + offset.pixels + centerOffsetAdjustment, + ); if (correction != 0.0) { offset.correctBy(correction); } else { @@ -200,29 +205,33 @@ class UnboundedRenderViewport extends RenderViewport { if (count >= _maxLayoutCycles) { assert(count != 1, 'count not equal to 1'); throw FlutterError( - 'A RenderViewport exceeded its maximum number of layout cycles.\n' - 'RenderViewport render objects, during layout, can retry if either their ' - 'slivers or their ViewportOffset decide that the offset should be corrected ' - 'to take into account information collected during that layout.\n' - 'In the case of this RenderViewport object, however, this happened $count ' - 'times and still there was no consensus on the scroll offset. This usually ' - 'indicates a bug. Specifically, it means that one of the following three ' - 'problems is being experienced by the RenderViewport object:\n' - ' * One of the RenderSliver children or the ViewportOffset have a bug such' - ' that they always think that they need to correct the offset regardless.\n' - ' * Some combination of the RenderSliver children and the ViewportOffset' - ' have a bad interaction such that one applies a correction then another' - ' applies a reverse correction, leading to an infinite loop of corrections.\n' - ' * There is a pathological case that would eventually resolve, but it is' - ' so complicated that it cannot be resolved in any reasonable number of' - ' layout passes.'); + 'A RenderViewport exceeded its maximum number of layout cycles.\n' + 'RenderViewport render objects, during layout, can retry if either their ' + 'slivers or their ViewportOffset decide that the offset should be corrected ' + 'to take into account information collected during that layout.\n' + 'In the case of this RenderViewport object, however, this happened $count ' + 'times and still there was no consensus on the scroll offset. This usually ' + 'indicates a bug. Specifically, it means that one of the following three ' + 'problems is being experienced by the RenderViewport object:\n' + ' * One of the RenderSliver children or the ViewportOffset have a bug such' + ' that they always think that they need to correct the offset regardless.\n' + ' * Some combination of the RenderSliver children and the ViewportOffset' + ' have a bad interaction such that one applies a correction then another' + ' applies a reverse correction, leading to an infinite loop of corrections.\n' + ' * There is a pathological case that would eventually resolve, but it is' + ' so complicated that it cannot be resolved in any reasonable number of' + ' layout passes.', + ); } return true; }(), 'count needs to be bigger than _maxLayoutCycles'); } double _attemptLayout( - double mainAxisExtent, double crossAxisExtent, double correctedOffset) { + double mainAxisExtent, + double crossAxisExtent, + double correctedOffset, + ) { assert(!mainAxisExtent.isNaN, 'assert mainAxisExtent.isNaN'); assert(mainAxisExtent >= 0.0, 'assert mainAxisExtent >= 0.0'); assert(crossAxisExtent.isFinite, 'assert crossAxisExtent.isFinite'); @@ -301,7 +310,9 @@ class UnboundedRenderViewport extends RenderViewport { @override void updateOutOfBandData( - GrowthDirection growthDirection, SliverGeometry childLayoutGeometry) { + GrowthDirection growthDirection, + SliverGeometry childLayoutGeometry, + ) { switch (growthDirection) { case GrowthDirection.forward: _maxScrollExtent += childLayoutGeometry.scrollExtent; diff --git a/packages/stream_chat_flutter/test/src/scrollable_positioned_list/horizontal_scrollable_positioned_list_test.dart b/packages/stream_chat_flutter/test/src/scrollable_positioned_list/horizontal_scrollable_positioned_list_test.dart index 61b22aa2..5f34fc15 100644 --- a/packages/stream_chat_flutter/test/src/scrollable_positioned_list/horizontal_scrollable_positioned_list_test.dart +++ b/packages/stream_chat_flutter/test/src/scrollable_positioned_list/horizontal_scrollable_positioned_list_test.dart @@ -208,9 +208,9 @@ void main() { expect(tester.getTopLeft(find.text('Item 0')), const Offset(10, 10)); expect(tester.getTopLeft(find.text('Item 1')), - const Offset(10 + itemWidth, 10)); + const Offset(itemWidth + 10, 10)); expect(tester.getBottomRight(find.text('Item 1')), - const Offset(10 + 2 * itemWidth, screenHeight - 10)); + const Offset(10 + itemWidth * 2, screenHeight - 10)); unawaited( itemScrollController.scrollTo(index: 490, duration: scrollDuration)); @@ -240,9 +240,9 @@ void main() { expect(tester.getTopLeft(find.text('Item 0')), const Offset(10, 10)); expect(tester.getTopLeft(find.text('Item 2')), - const Offset(10 + 2 * itemWidth, 10)); + const Offset(10 + itemWidth * 2, 10)); expect(tester.getTopLeft(find.text('Item 3')), - const Offset(10 + 3 * itemWidth, 10)); + const Offset(10 + itemWidth * 3, 10)); }); testWidgets('padding test - reversed - centered sliver at right', @@ -258,9 +258,9 @@ void main() { expect(tester.getTopRight(find.text('Item 0')), const Offset(screenWidth - 10, 10)); expect(tester.getTopRight(find.text('Item 1')), - const Offset(screenWidth - (10 + itemWidth), 10)); + const Offset(screenWidth - (itemWidth + 10), 10)); expect(tester.getBottomLeft(find.text('Item 1')), - const Offset(screenWidth - (10 + 2 * itemWidth), screenHeight - 10)); + const Offset(screenWidth - (10 + itemWidth * 2), screenHeight - 10)); unawaited( itemScrollController.scrollTo(index: 490, duration: scrollDuration)); @@ -291,8 +291,8 @@ void main() { expect(tester.getTopRight(find.text('Item 0')), const Offset(screenWidth - 10, 10)); expect(tester.getTopRight(find.text('Item 2')), - const Offset(screenWidth - (10 + 2 * itemWidth), 10)); + const Offset(screenWidth - (10 + itemWidth * 2), 10)); expect(tester.getTopRight(find.text('Item 3')), - const Offset(screenWidth - (10 + 3 * itemWidth), 10)); + const Offset(screenWidth - (10 + itemWidth * 3), 10)); }); } diff --git a/packages/stream_chat_flutter/test/src/scrollable_positioned_list/positioned_list_test.dart b/packages/stream_chat_flutter/test/src/scrollable_positioned_list/positioned_list_test.dart index 983f249f..b3522391 100644 --- a/packages/stream_chat_flutter/test/src/scrollable_positioned_list/positioned_list_test.dart +++ b/packages/stream_chat_flutter/test/src/scrollable_positioned_list/positioned_list_test.dart @@ -197,7 +197,7 @@ void main() { await setUpWidgetTest(tester, topItem: 5); await tester.drag( - find.byType(PositionedList), const Offset(0, 2 * itemHeight)); + find.byType(PositionedList), const Offset(0, itemHeight * 2)); await tester.pump(); expect(find.text('Item 2'), findsNothing); @@ -248,7 +248,7 @@ void main() { await setUpWidgetTest(tester, scrollController: scrollController); await tester.pump(); - scrollController.jumpTo(5 * itemHeight); + scrollController.jumpTo(itemHeight * 5); await tester.pump(); await tester.pumpAndSettle(); @@ -307,7 +307,7 @@ void main() { await setUpWidgetTest(tester, topItem: 5, scrollController: scrollController); - scrollController.jumpTo(20 * itemHeight); + scrollController.jumpTo(itemHeight * 20); await tester.pump(); expect( diff --git a/packages/stream_chat_flutter/test/src/scrollable_positioned_list/reversed_positioned_list_test.dart b/packages/stream_chat_flutter/test/src/scrollable_positioned_list/reversed_positioned_list_test.dart index 8b3a1ab5..54aa4c02 100644 --- a/packages/stream_chat_flutter/test/src/scrollable_positioned_list/reversed_positioned_list_test.dart +++ b/packages/stream_chat_flutter/test/src/scrollable_positioned_list/reversed_positioned_list_test.dart @@ -162,7 +162,7 @@ void main() { await setUpWidgetTest(tester, topItem: 5); await tester.drag( - find.byType(PositionedList), const Offset(0, 2 * itemHeight)); + find.byType(PositionedList), const Offset(0, itemHeight * 2)); await tester.pump(); expect(find.text('Item 6'), findsNothing); @@ -186,7 +186,7 @@ void main() { await setUpWidgetTest(tester, scrollController: scrollController); await tester.pump(); - scrollController.jumpTo(5 * itemHeight); + scrollController.jumpTo(itemHeight * 5); await tester.pump(); await tester.pumpAndSettle(); @@ -214,7 +214,7 @@ void main() { await setUpWidgetTest(tester, topItem: 5, scrollController: scrollController); - scrollController.jumpTo(2 * itemHeight); + scrollController.jumpTo(itemHeight * 2); await tester.pump(); expect(find.text('Item 6'), findsNothing); @@ -242,7 +242,7 @@ void main() { testWidgets('List positioned with 5 at bottom and initial scroll offset', (WidgetTester tester) async { final scrollController = - ScrollController(initialScrollOffset: 2 * itemHeight); + ScrollController(initialScrollOffset: itemHeight * 2); await setUpWidgetTest(tester, topItem: 5, scrollController: scrollController); diff --git a/packages/stream_chat_flutter/test/src/scrollable_positioned_list/reversed_scrollable_positioned_list_test.dart b/packages/stream_chat_flutter/test/src/scrollable_positioned_list/reversed_scrollable_positioned_list_test.dart index f93bcf71..9e453259 100644 --- a/packages/stream_chat_flutter/test/src/scrollable_positioned_list/reversed_scrollable_positioned_list_test.dart +++ b/packages/stream_chat_flutter/test/src/scrollable_positioned_list/reversed_scrollable_positioned_list_test.dart @@ -200,9 +200,9 @@ void main() { expect(tester.getBottomLeft(find.text('Item 0')), const Offset(10, screenHeight - 10)); expect(tester.getBottomLeft(find.text('Item 1')), - const Offset(10, screenHeight - (10 + itemHeight))); + const Offset(10, screenHeight - (itemHeight + 10))); expect(tester.getTopRight(find.text('Item 1')), - const Offset(screenWidth - 10, screenHeight - (10 + 2 * itemHeight))); + const Offset(screenWidth - 10, screenHeight - (10 + itemHeight * 2))); unawaited( itemScrollController.scrollTo(index: 490, duration: scrollDuration)); @@ -232,8 +232,8 @@ void main() { expect(tester.getBottomLeft(find.text('Item 0')), const Offset(10, screenHeight - 10)); expect(tester.getBottomLeft(find.text('Item 2')), - const Offset(10, screenHeight - (10 + 2 * itemHeight))); + const Offset(10, screenHeight - (10 + itemHeight * 2))); expect(tester.getBottomLeft(find.text('Item 3')), - const Offset(10, screenHeight - (10 + 3 * itemHeight))); + const Offset(10, screenHeight - (10 + itemHeight * 3))); }); } diff --git a/packages/stream_chat_flutter/test/src/scrollable_positioned_list/scrollable_positioned_list_test.dart b/packages/stream_chat_flutter/test/src/scrollable_positioned_list/scrollable_positioned_list_test.dart index 243aeeb1..4f0dcc1d 100644 --- a/packages/stream_chat_flutter/test/src/scrollable_positioned_list/scrollable_positioned_list_test.dart +++ b/packages/stream_chat_flutter/test/src/scrollable_positioned_list/scrollable_positioned_list_test.dart @@ -1211,7 +1211,7 @@ void main() { itemScrollController: itemScrollController, initialIndex: 5); await tester.drag( - find.byType(ScrollablePositionedList), const Offset(0, 2 * itemHeight)); + find.byType(ScrollablePositionedList), const Offset(0, itemHeight * 2)); await tester.pumpAndSettle(); final indexSemantics3 = tester.widget(find.ancestor( @@ -1234,7 +1234,7 @@ void main() { await tester.pumpAndSettle(); await tester.drag( - find.byType(ScrollablePositionedList), const Offset(0, 2 * itemHeight)); + find.byType(ScrollablePositionedList), const Offset(0, itemHeight * 2)); await tester.pumpAndSettle(); final indexSemantics3b = tester.widget(find.ancestor( @@ -1339,9 +1339,9 @@ void main() { expect(tester.getTopLeft(find.text('Item 0')), const Offset(10, 10)); expect(tester.getTopLeft(find.text('Item 1')), - const Offset(10, 10 + itemHeight)); + const Offset(10, itemHeight + 10)); expect(tester.getTopRight(find.text('Item 1')), - const Offset(screenWidth - 10, 10 + itemHeight)); + const Offset(screenWidth - 10, itemHeight + 10)); unawaited( itemScrollController.scrollTo(index: 490, duration: scrollDuration)); @@ -1371,9 +1371,9 @@ void main() { expect(tester.getTopLeft(find.text('Item 0')), const Offset(10, 10)); expect(tester.getTopLeft(find.text('Item 2')), - const Offset(10, 10 + 2 * itemHeight)); + const Offset(10, 10 + itemHeight * 2)); expect(tester.getTopLeft(find.text('Item 3')), - const Offset(10, 10 + 3 * itemHeight)); + const Offset(10, 10 + itemHeight * 3)); }); testWidgets('padding - first element centered - scroll up', @@ -1862,7 +1862,7 @@ void main() { }); testWidgets('Large minCacheExtent', (WidgetTester tester) async { - await setUpWidgetTest(tester, minCacheExtent: 200 * itemHeight); + await setUpWidgetTest(tester, minCacheExtent: itemHeight * 200); expect(find.text('Item 100', skipOffstage: false), findsOneWidget); }); @@ -1911,7 +1911,7 @@ void main() { await setUpWidgetTest( tester, itemScrollController: itemScrollController, - minCacheExtent: 200 * itemHeight, + minCacheExtent: itemHeight * 200, ); var fadeTransition = tester.widget(find diff --git a/packages/stream_chat_flutter/test/src/scrollable_positioned_list/separated_positioned_list_test.dart b/packages/stream_chat_flutter/test/src/scrollable_positioned_list/separated_positioned_list_test.dart index 5afdb438..a4252a23 100644 --- a/packages/stream_chat_flutter/test/src/scrollable_positioned_list/separated_positioned_list_test.dart +++ b/packages/stream_chat_flutter/test/src/scrollable_positioned_list/separated_positioned_list_test.dart @@ -86,7 +86,7 @@ void main() { await setUpWidgetTest(tester, itemCount: 3, topItem: 1); await tester.drag( - find.byType(PositionedList), const Offset(0, 2 * itemHeight)); + find.byType(PositionedList), const Offset(0, itemHeight * 2)); await tester.pumpAndSettle(); expect(find.text('Item 0'), findsOneWidget); diff --git a/packages/stream_chat_flutter/test/src/scrollable_positioned_list/separated_scrollable_positioned_list_test.dart b/packages/stream_chat_flutter/test/src/scrollable_positioned_list/separated_scrollable_positioned_list_test.dart index b0dac065..44164d6b 100644 --- a/packages/stream_chat_flutter/test/src/scrollable_positioned_list/separated_scrollable_positioned_list_test.dart +++ b/packages/stream_chat_flutter/test/src/scrollable_positioned_list/separated_scrollable_positioned_list_test.dart @@ -320,7 +320,7 @@ void main() { await setUpWidgetTest(tester, initialIndex: 5); await tester.drag( - find.byType(ScrollablePositionedList), const Offset(0, 4 * itemHeight)); + find.byType(ScrollablePositionedList), const Offset(0, itemHeight * 4)); await tester.pumpAndSettle(); final indexSemantics3 = tester.widget(find.ancestor( @@ -401,9 +401,9 @@ void main() { expect(tester.getTopLeft(find.text('Item 0')), const Offset(10, 10)); expect(tester.getTopLeft(find.text('Item 1')), - const Offset(10, 10 + itemHeight + separatorHeight)); + const Offset(10, itemHeight + 10 + separatorHeight)); expect(tester.getTopRight(find.text('Item 1')), - const Offset(screenWidth - 10, 10 + itemHeight + separatorHeight)); + const Offset(screenWidth - 10, itemHeight + 10 + separatorHeight)); unawaited( itemScrollController.scrollTo(index: 494, duration: scrollDuration)); diff --git a/packages/stream_chat_flutter/test/src/scrollable_positioned_list/seperated_horizontal_scrollable_positioned_list_test.dart b/packages/stream_chat_flutter/test/src/scrollable_positioned_list/seperated_horizontal_scrollable_positioned_list_test.dart index 2c8dbacb..55935638 100644 --- a/packages/stream_chat_flutter/test/src/scrollable_positioned_list/seperated_horizontal_scrollable_positioned_list_test.dart +++ b/packages/stream_chat_flutter/test/src/scrollable_positioned_list/seperated_horizontal_scrollable_positioned_list_test.dart @@ -166,9 +166,9 @@ void main() { expect(tester.getTopLeft(find.text('Item 0')), const Offset(10, 10)); expect(tester.getTopLeft(find.text('Item 1')), - const Offset(10 + itemWidth + separatorWidth, 10)); + const Offset(itemWidth + 10 + separatorWidth, 10)); expect(tester.getBottomRight(find.text('Item 1')), - const Offset(10 + 2 * itemWidth + separatorWidth, screenHeight - 10)); + const Offset(10 + itemWidth * 2 + separatorWidth, screenHeight - 10)); unawaited( itemScrollController.scrollTo(index: 494, duration: scrollDuration));