Unverified Commit ddfaec19 authored by Alexandre Daigle's avatar Alexandre Daigle Committed by GitHub

Fix null check for content dimensions in page getter (#87824)

parent 42a6b791
...@@ -385,10 +385,12 @@ class _PagePosition extends ScrollPositionWithSingleContext implements PageMetri ...@@ -385,10 +385,12 @@ class _PagePosition extends ScrollPositionWithSingleContext implements PageMetri
@override @override
double? get page { double? get page {
assert( assert(
!hasPixels || (minScrollExtent != null && maxScrollExtent != null), !hasPixels || hasContentDimensions,
'Page value is only available after content dimensions are established.', 'Page value is only available after content dimensions are established.',
); );
return !hasPixels ? null : getPageFromPixels(pixels.clamp(minScrollExtent, maxScrollExtent), viewportDimension); return !hasPixels || !hasContentDimensions
? null
: getPageFromPixels(pixels.clamp(minScrollExtent, maxScrollExtent), viewportDimension);
} }
@override @override
......
...@@ -14,6 +14,12 @@ import 'states.dart'; ...@@ -14,6 +14,12 @@ import 'states.dart';
const Duration _frameDuration = Duration(milliseconds: 100); const Duration _frameDuration = Duration(milliseconds: 100);
void main() { void main() {
testWidgets('PageController cannot return page while unattached',
(WidgetTester tester) async {
final PageController controller = PageController();
expect(() => controller.page, throwsAssertionError);
});
testWidgets('PageView control test', (WidgetTester tester) async { testWidgets('PageView control test', (WidgetTester tester) async {
final List<String> log = <String>[]; final List<String> log = <String>[];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment