feat(scrollbar): support retrieving the current position of state (#1552)

As of now it is possible to change the position of the Scrollbar but not
possible to retrieve the position for further use. e.g.

```rust
let mut state = ScrollbarState::default();
state.next();
```

This commit adds a new method "`current_position`" (since `position` is
already taken by the fluent setter) for that purpose:

```rust
let index = state.get_position(); // yay
```

See #1545 for the concrete usage of this.
This commit is contained in:
Orhun Parmaksız
2024-12-07 18:23:22 +03:00
committed by GitHub
parent 6ddde0e8a8
commit ff729b7607

View File

@@ -494,6 +494,12 @@ impl ScrollbarState {
}
}
}
/// Returns the current position within the scrollable content.
#[must_use = "returns the current position within the scrollable content"]
pub const fn get_position(&self) -> usize {
self.position
}
}
impl StatefulWidget for Scrollbar<'_> {