Commit 3f70271d authored by Hans Muller's avatar Hans Muller

manage listener with on,didMount

parent b0e0e65c
......@@ -28,11 +28,20 @@ class VariableHeightScrollable extends Scrollable {
void initState() {
assert(layoutState != null);
layoutState.removeListener(_handleLayoutChanged);
layoutState.addListener(_handleLayoutChanged);
super.initState();
}
void didMount() {
layoutState.addListener(_handleLayoutChanged);
super.didMount();
}
void didUnmount() {
layoutState.removeListener(_handleLayoutChanged);
super.didUnmount();
}
void syncFields(VariableHeightScrollable source) {
builder = source.builder;
if (token != source.token)
......@@ -55,11 +64,6 @@ class VariableHeightScrollable extends Scrollable {
scrollBehavior.containerSize = newSize.height;
}
void didUnmount() {
layoutState.removeListener(_handleLayoutChanged);
super.didUnmount();
}
void _handleLayoutChanged() {
if (layoutState.didReachLastChild) {
scrollBehavior.contentsSize = layoutState.contentsSize;
......
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