Create SearchAnchor and SearchViewTheme Widget#123256
Create SearchAnchor and SearchViewTheme Widget#123256QuncCccccc merged 37 commits intoflutter:masterfrom
SearchAnchor and SearchViewTheme Widget#123256Conversation
SearchAnchor and SearchViewTheme WidgetSearchAnchor and SearchViewTheme Widget
HansMuller
left a comment
There was a problem hiding this comment.
This looks great! Only real bit of feedback here is a suggestion about the "anchorBuilder" name.
There was a problem hiding this comment.
Does this mean that if nothing was selected the caller will see a stale value?
There was a problem hiding this comment.
Yes. When _closeView is called without providing any text, only the search view route is popped and the controller's value will not change. Or another way I can think of is, when selectedText is null, we just clear the value that the controller originally hold. Do you think if this makes sense?
There was a problem hiding this comment.
I think the way you have it now is OK; it is pretty clear what's going to happen when closeView(null) is called.
There was a problem hiding this comment.
https://api.flutter.dev/flutter/animation/CurvedAnimation/reverseCurve.html
If you use a non-null reverseCurve you might want to hold this object in a State object rather than recreating it each time your widget builds in order to take advantage of the state in this object that avoids visual discontinuities.
If bringing the page up and down (before the animation completes) looks janky, making the CurvedAnimation part of this Route's state might be a good idea. Could be handled in a separate PR.
QuncCccccc
left a comment
There was a problem hiding this comment.
Thanks a lot for the feedback! Fixing it now.
There was a problem hiding this comment.
Yes. When _closeView is called without providing any text, only the search view route is popped and the controller's value will not change. Or another way I can think of is, when selectedText is null, we just clear the value that the controller originally hold. Do you think if this makes sense?
HansMuller
left a comment
There was a problem hiding this comment.
Assuming that anchorBuilder is renamed to builder, LGTM!
a867b97 to
555bb69
Compare
555bb69 to
c11e3bc
Compare
This PR is to create a
SearchAnchorwidget in which we can use an anchor to trigger a search view. Typically an anchor is aSearchBar, orIconButton.In order to use the
SearchAnchorwith the new Material 3 colors, turn on theuseMaterial3flag in theThemeData:Fixes #117483.
This is an example to show how we can use the SearchAnchor.bar() constructor. The sample code is in examples/api/lib/material/search_anchor/search_anchor.0.dart
Screen.Recording.2023-03-22.at.11.15.25.AM.mov
Same example running on mobile devices shows full screen.
Screen.Recording.2023-03-22.at.11.06.16.AM.mov
Another example in examples/api/lib/material/search_anchor/search_anchor.1.dart is to show how we can use SliverAppBar and SearchAnchor to get a pinned/floating effect. To achieve this, we need to add an additional api
clipBehaviorto AppBar, otherwise the shadow might be clipped.See the commit.
Screen.Recording.2023-03-22.at.11.09.16.AM.mov
Pre-launch Checklist
///).