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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
build(BuildContext context, int index) -> Widget?
Returns the child with the given index.
override
debugFillDescription(List<String> description) -> void
Add additional information to the given description for use by toString.
@mustCallSuper, @protected, inherited
didFinishLayout(int firstIndex, int lastIndex) -> void
Called at the end of layout to indicate that layout is now complete.
inherited
estimateMaxScrollOffset(int firstIndex, int lastIndex, double leadingScrollOffset, double trailingScrollOffset) -> double?
Returns an estimate of the max scroll extent for all the children.
inherited
findIndexByKey(Key key) -> int?
Find index of child element with associated key.
override
noSuchMethod(Invocation invocation) -> dynamic
Invoked when a non-existent method or property is accessed.
inherited
shouldRebuild(covariant SliverChildBuilderDelegate oldDelegate) -> bool
Called whenever a new instance of the child delegate class is provided to the sliver.
override
toString() -> String
A string representation of this object.
inherited
*/
use crate::foundation::Key;
use super::{BuildContext, Widget};
// Widget widget, int localIndex
pub type SemanticIndexCallback = Box<dyn Fn(&dyn Widget, usize) -> Option<usize>>;
pub type ChildIndexGetter = Box<dyn Fn(Key) -> Option<usize>>;
// BuildContext context, int index
pub type NullableIndexedWidgetBuilder = Box<dyn Fn(BuildContext, usize) -> Option<Box<dyn Widget>>>;
pub struct SliverChildBuilderDelegate {
// Whether to wrap each child in an AutomaticKeepAlive.
pub add_automatic_keep_alives: bool,
// Whether to wrap each child in a RepaintBoundary.
pub add_repaint_boundaries: bool,
// Whether to wrap each child in an IndexedSemantics.
pub add_semantic_indexes: bool,
// Called to build children for the sliver.
pub builder: NullableIndexedWidgetBuilder,
// The total number of children this delegate can provide.
pub child_count: usize,
// Returns an estimate of the number of children this delegate will build.
pub estimated_child_count: i32,
// Called to find the new index of a child based on its key in case of reordering.
pub find_child_index_callback: ChildIndexGetter,
// A SemanticIndexCallback which is used when addSemanticIndexes is true.
pub semantic_index_callback: SemanticIndexCallback,
// An initial offset to add to the semantic indexes generated by this widget.
pub semantic_index_offset: i32,
}
impl Default for SliverChildBuilderDelegate {
fn default() -> Self {
Self {
add_automatic_keep_alives: Default::default(),
add_repaint_boundaries: Default::default(),
add_semantic_indexes: Default::default(),
builder: box |_,_| None,
child_count: Default::default(),
estimated_child_count: Default::default(),
find_child_index_callback: box |_| None,
semantic_index_callback: box |_,_| None,
semantic_index_offset: Default::default(),
}
}
}