Skip to content

AutomaticKeepAlive now keeps alive#16445

Merged
goderbauer merged 6 commits intoflutter:masterfrom
goderbauer:fixKeepAlive
Apr 11, 2018
Merged

AutomaticKeepAlive now keeps alive#16445
goderbauer merged 6 commits intoflutter:masterfrom
goderbauer:fixKeepAlive

Conversation

@goderbauer
Copy link
Member

@goderbauer goderbauer commented Apr 10, 2018

Fixes #16346.

See #16346 (comment) for detailed explanation of what was going wrong before this fix.

// If we are called during the first build of this subtree the links to the
// children will not be hooked up yet. In that case this method returns
// null despite the fact that we will have a child after the build
// completes. It's the callers responsibility to deal with this case.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

caller's

// If the child doesn't exist yet, we got called during the very first
// build of this subtree. Wait until the end of the frame to update
// the child when the child is guaranteed to be present.
SchedulerBinding.instance.addPostFrameCallback((_) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should be explicit about argument names and types even if we don't use them, that way people editing or copying the code don't have to look up what it is

}

class _AlwaysKeepAlive extends StatefulWidget{
const _AlwaysKeepAlive({Key key}):super(key:key);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trivial nits: space before { on the class line, spaces around first : and space after second : on the constructor line.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the future, maybe it's a good idea to integrate pre-commit hook of dart prettifier which automatically formats code style to the branch.

expect(find.byKey(const GlobalObjectKey<_AlwaysKeepAliveState>(0)), findsOneWidget);
await tester.drag(find.byType(ListView), const Offset(0.0, -1000.0)); // move to bottom
await tester.pump();
expect(find.byKey(const GlobalObjectKey<_AlwaysKeepAliveState>(0)), findsOneWidget);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe also verify that "keep me alive" is present but "FooBar" is not?

@Hixie
Copy link
Contributor

Hixie commented Apr 11, 2018

LGTM

@goderbauer goderbauer merged commit 49a3adc into flutter:master Apr 11, 2018
@goderbauer goderbauer deleted the fixKeepAlive branch April 11, 2018 17:31
DaveShuckerow pushed a commit to DaveShuckerow/flutter that referenced this pull request May 14, 2018
Fixes flutter#16346.

See flutter#16346 (comment) for detailed explanation of what was going wrong before this fix.
@goderbauer goderbauer added framework flutter/packages/flutter repository. See also f: labels. f: scrolling Viewports, list views, slivers, etc. labels Feb 22, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automatic Keep Alive not work

4 participants