fix: SearchAnchor View not resizing when in nested navigator (#128357)
Similar to what was done on https://github.com/flutter/flutter/pull/127198, look for the closest navigator instead of screen size. Fixes: https://github.com/flutter/flutter/issues/128344
This commit is contained in:
parent
d99e5fdd2c
commit
39bf968168
@ -489,7 +489,8 @@ class _SearchViewRoute extends PopupRoute<_SearchViewRoute> {
|
||||
}
|
||||
|
||||
void updateTweens(BuildContext context) {
|
||||
final Size screenSize = MediaQuery.of(context).size;
|
||||
final RenderBox navigator = Navigator.of(context).context.findRenderObject()! as RenderBox;
|
||||
final Size screenSize = navigator.size;
|
||||
final Rect anchorRect = getRect() ?? Rect.zero;
|
||||
|
||||
final BoxConstraints effectiveConstraints = viewConstraints ?? viewTheme.constraints ?? viewDefaults.constraints!;
|
||||
|
@ -1789,6 +1789,50 @@ void main() {
|
||||
expect(searchViewRect.topLeft, equals(const Offset(rootSpacing, rootSpacing)));
|
||||
});
|
||||
|
||||
testWidgets('Docked search view with nested navigator does not go off the screen', (WidgetTester tester) async {
|
||||
addTearDown(tester.view.reset);
|
||||
tester.view.physicalSize = const Size(400.0, 400.0);
|
||||
tester.view.devicePixelRatio = 1.0;
|
||||
|
||||
const double rootSpacing = 100.0;
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
builder: (BuildContext context, Widget? child) {
|
||||
return Scaffold(
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(rootSpacing),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
},
|
||||
home: Material(
|
||||
child: Align(
|
||||
alignment: Alignment.bottomRight,
|
||||
child: SearchAnchor(
|
||||
isFullScreen: false,
|
||||
builder: (BuildContext context, SearchController controller) {
|
||||
return IconButton(
|
||||
icon: const Icon(Icons.search),
|
||||
onPressed: () {
|
||||
controller.openView();
|
||||
},
|
||||
);
|
||||
},
|
||||
suggestionsBuilder: (BuildContext context, SearchController controller) {
|
||||
return <Widget>[];
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
await tester.tap(find.byIcon(Icons.search));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final Rect searchViewRect = tester.getRect(find.descendant(of: findViewContent(), matching: find.byType(SizedBox)).first);
|
||||
expect(searchViewRect.bottomRight, equals(const Offset(300.0, 300.0)));
|
||||
});
|
||||
|
||||
|
||||
// Regression tests for https://github.com/flutter/flutter/issues/126623
|
||||
group('Overall InputDecorationTheme does not impact SearchBar and SearchView', () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user