1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use crate::foundation::Key;
use super::{BuildContext, Widget};
pub trait SliverChildDelegate {
// Returns an estimate of the number of children this delegate will build. [...]
// estimatedChildCount → int?
// Returns the child with the given index. [...]
fn build(&self, context: Option<BuildContext>, index: usize) -> Option<Box<dyn Widget>> {
todo!()
}
// Called at the end of layout to indicate that layout is now complete. [...]
fn did_finish_layout(&self, first_index: usize, last_index: usize) {}
// Returns an estimate of the max scroll extent for all the children. [...]
fn estimate_max_scroll_offset(
&self,
first_index: usize,
last_index: usize,
leading_scroll_offset: f32,
trailing_scroll_offset: f32,
) -> Option<f32> {
None
}
// Find index of child element with associated key. [...]
fn find_index_by_key(&self, key: Key) -> Option<usize> {
None
}
// Called whenever a new instance of the child delegate class is provided to the sliver. [...]
fn should_rebuild(&self, old_delegate: Box<dyn SliverChildDelegate>) -> bool {
false
}
}
pub struct NoneSliverChildDelegate;
impl SliverChildDelegate for NoneSliverChildDelegate {}