Skip to content

Search View doesn't update size on navigator resize #186154

Closed
flutter/packages
#12466

Description

@Zekfad

Steps to reproduce

  1. Use full screen search view (SearchAnchor).
  2. Rotate phone/expand window.
  3. Search view has outdated forced constraints.

Alternatively if navigator is resized to not be covered by keyboard:

  1. Open keyboard (for example long press to search bar inside of search anchor).
  2. Open search view.
  3. Close keyboard.
  4. View is clipped at the bottom because navigator was initially small.

Expected results

View should update viewMaxWidth to match new constraints.
_SearchViewRoute should call updateTweens when Navigator.size changes.

It seems that _viewRect is provided from evaluated tween (animation) and also updated in _ViewContentState.didChangeDependencies using media query (which is incorrect and should actually use Navigator.size, because navigator can be resized in response to opened/closed keyboard)

Actual results

View is stuck with old size constraints.

Code sample

Code sample
import 'package:flutter/material.dart';

/// Flutter code sample for [SearchAnchor].

void main() => runApp(const SearchBarApp());

class SearchBarApp extends StatefulWidget {
  const SearchBarApp({super.key});

  @override
  State<SearchBarApp> createState() => _SearchBarAppState();
}

class _SearchBarAppState extends State<SearchBarApp> {
  final SearchController controller = SearchController();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Search Anchor Sample')),
        body: Column(
          children: <Widget>[
            SearchAnchor(
              searchController: controller,
              isFullScreen: true,
              builder: (BuildContext context, SearchController controller) {
                return IconButton(
                  icon: const Icon(Icons.search),
                  onPressed: () {
                    controller.openView();
                  },
                );
              },
              suggestionsBuilder:
                  (BuildContext context, SearchController controller) {
                    return List<ListTile>.generate(5, (int index) {
                      final String item = 'item $index';
                      return ListTile(
                        title: Text(item),
                        onTap: () {
                          setState(() {
                            controller.closeView(item);
                          });
                        },
                      );
                    });
                  },
            ),
            Center(
              child: controller.text.isEmpty
                  ? const Text('No item selected')
                  : Text('Selected item: ${controller.value.text}'),
            ),
          ],
        ),
      ),
    );
  }
}

Screenshots or Video

No response

Logs

No response

Flutter Doctor output

Doctor output
[√] Flutter (Channel stable, 3.41.9, on Microsoft Windows [Version 10.0.19044.4529], locale en-US) [599ms]
    • Flutter version 3.41.9 on channel stable at D:\Android\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 00b0c91f06 (7 days ago), 2026-04-29 10:03:19 -0700
    • Engine revision 42d3d75a56
    • Dart version 3.11.5
    • DevTools version 2.54.2
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android,
      enable-ios, cli-animations, enable-native-assets, enable-swift-package-manager, omit-legacy-version-file,
      enable-lldb-debugging, enable-uiscene-migration

[√] Windows Version (10 Enterprise 64-bit, 21H2, 2009) [4.5s]

[√] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [6.1s]
    • Android SDK at D:\Android\sdk
    • Emulator version 36.5.10.0 (build_id 15081367) (CL:N/A)
    • Platform android-36, build-tools 36.0.0
    • ANDROID_HOME = D:\Android\sdk
    • Java binary at: d:\Program Files\Android Studio Beta\jbr\bin\java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.10+-14961533-b1163.108)
    • All Android licenses accepted.

[√] Chrome - develop for the web [137ms]
    • CHROME_EXECUTABLE = C:\Program Files\Google\Chrome Beta\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.14.31 (April 2026)) [134ms]
    • Visual Studio at D:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.14.37216.2
    • Windows 10 SDK version 10.0.26100.0

[√] Connected device (3 available) [334ms]
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.19044.4529]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 147.0.7727.138
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 147.0.3912.98

[√] Network resources [446ms]
    • All expected network resources are available.

• No issues found!

Activity

  1. saurabh-mirajkar commented on May 7, 2026

    @saurabh-mirajkar
    Contributor

    @Zekfad Thanks for the detailed report. I’m able to reproduce the issue on multiple platforms using the provided code sample.

    Platform Device Environment
    Android Pixel 10 Pro (emulator) Android 17
    iOS iPhone 17 Pro (simulator) iOS 26.4
    Web Chrome Browser Version 148.0.7778.97 (Official Build) (arm64)
    macOS Mac desktop macOS 26.4.1

    After opening the fullscreen SearchAnchor, resizing the window or rotating the device causes the search view to retain stale size constraints instead of adapting to the updated navigator dimensions.

    Routing this to team-design for further investigation.

  2. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    team-designOwned by Design Languages team
    platform-androidAndroid applications specifically
    platform-iosiOS applications specifically
    platform-macosBuilding on or for macOS specifically
    platform-webWeb applications specifically
    and removed
    in triagePresently being triaged by the triage team
    on May 7, 2026
  3. self-assigned this
    on May 11, 2026
  4. added
    P2Important issues not at the top of the work list
    triaged-designTriaged by Design Languages team
    on May 13, 2026
  5. added
    packageflutter/packages repository. See also p: labels.
    and removed
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Aug 17, 2026
  6. github-actions commented on Sep 3, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  7. locked as resolved and limited conversation to collaborators on Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listp: material_uimaterial_ui package in flutter/packagespackageflutter/packages repository. See also p: labels.platform-androidAndroid applications specificallyplatform-iosiOS applications specificallyplatform-macosBuilding on or for macOS specificallyplatform-webWeb applications specificallyteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions