page property

double? get page

The current page displayed in the controlled P2PageView.

There are circumstances that this P2PageController can't know the current page. Reading page will throw an AssertionError in the following cases:

  1. No P2PageView is currently using this P2PageController. Once a P2PageView starts using this P2PageController, the new page position will be derived:
  1. More than one P2PageView using the same P2PageController.

The hasClients property can be used to check if a P2PageView is attached prior to accessing page.

Implementation

double? get page {
    assert(
    positions.isNotEmpty,
    'P2PageController.page cannot be accessed before a P2PageView is built with it.',
    );
    assert(
    positions.length == 1,
    'The page property cannot be read when multiple P2PageViews are attached to '
        'the same P2PageController.',
    );
    final _PagePosition position = this.position as _PagePosition;
    return position.page;
}