Skip to content

Commit

Permalink
fix: try catch controller position
Browse files Browse the repository at this point in the history
  • Loading branch information
lcdsmao committed Oct 14, 2021
1 parent 4d8a658 commit 07d9aa7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions playbook_snapshot/lib/src/snapshot_support.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class SnapshotSupport {
}
if (extendedSize.width >= _maxSnapshotSize || extendedSize.height >= _maxSnapshotSize) {
throw StateError(
'Try resizing too large size. Please try to set your scenario to have a fixed size.');
'Try resizing too large size ${extendedSize}. Please try to set your scenario to have a fixed size.');
}
}
snapshotSize = lastExtendedSize;
Expand Down Expand Up @@ -113,7 +113,11 @@ class SnapshotSupport {
required _CompressedResizingTarget resizingTarget,
}) {
final controller = scrollable.controller;
if (controller == null) {
ScrollPosition? position;
try {
position = controller?.position;
} catch (_) {}
if (position == null) {
return Size(
resizingTarget.needResizingWidth
? max(currentExtendedSize.width, originSize.width)
Expand All @@ -124,8 +128,8 @@ class SnapshotSupport {
);
}

final scrollAxis = controller.position.axis;
final maxScrollExtent = controller.position.maxScrollExtent;
final scrollAxis = position.axis;
final maxScrollExtent = position.maxScrollExtent;

final Size newExtendedSize;
switch (scrollAxis) {
Expand Down

0 comments on commit 07d9aa7

Please sign in to comment.