chore: linting

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