SearchAnchor View pops unexpectedly while using Web version in Desktop mode on Android
- Dominant language
- Dart
- Stars
- 179k
- Forks
- 31.1k
- PR merge metrics
- PR metrics pending
Description
### Steps to reproduce
1. Use the sample SearchAnchor template, modify it to use SearchAnchor.bar, and set isFullScreen to false.
2. Build in release mode, and open the hosted website on Android in Desktop Mode
3. Click on the Search Bar
### Expected results
The Search Anchor View should stay open.
### Actual results
The View appears briefly for a second, then closes automatically. Also, sometimes the text in the SearchBar appears to be selected when the View gets closed this way. Writing further with the Keyboard over-writes the Text. Experiencing the issue on latest Flutter Stable and Master channels. Tested on OnePlus 11R (OxygenOS 15) on Chrome and Firefox.
### Code sample
Code sample
```dart
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 createState() => _SearchBarAppState();
}
class _SearchBarAppState extends State {
final SearchController controller = SearchController();
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Search Anchor Sample')),
body: Column(
children: [
SearchAnchor.bar(
searchController: controller,
isFullScreen: false,
suggestionsBuilder:
(BuildContext context, SearchController controller) {
return List.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
Screenshots / Video demonstration
[
https://github.com/user-attachments/assets/2fc06d84-f0dc-4852-a8ef-b7a326015665
### Logs
_No response_
### Flutter Doctor output
Doctor output
```console
[✓] Flutter (Channel master, 3.40.0-1.0.pre-273, on Kali GNU/Linux Rolling 6.11.2-amd64, locale en_US.UTF-8) [4.2s]
• Flutter version 3.40.0-1.0.pre-273 on channel master at /home/r00n1l/snap/flutter/common/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 96ae88f398 (3 hours ago), 2025-12-19 10:15:01 -0800
• Engine revision 0e9461ea4a
• Dart version 3.11.0 (build 3.11.0-262.0.dev)
• DevTools version 2.53.0
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations,
enable-native-assets, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration
[!] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [3.6s]
• Android SDK at /home/r00n1l/Android/Sdk
• Emulator version 34.2.16.0 (build_id 12038310) (CL:N/A)
• Platform android-36, build-tools 35.0.0
• Java binary at: /opt/android-studio/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 17.0.11+0-17.0.11b1207.24-11852314)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[✓] Chrome - develop for the web [20ms]
• Chrome at google-chrome
[✓] Linux toolchain - develop for Linux desktop [1,384ms]
• clang version 10.0.0-4ubuntu1
• cmake version 3.16.3
• ninja version 1.10.0
• pkg-config version 0.29.1
• OpenGL core renderer: llvmpipe (LLVM 19.1.3, 256 bits)
• OpenGL core version: 4.5 (Core Profile) Mesa 24.2.7-1
• OpenGL core shading language version: 4.50
• OpenGL ES renderer: llvmpipe (LLVM 19.1.3, 256 bits)
• OpenGL ES version: OpenGL ES 3.2 Mesa 24.2.7-1
• OpenGL ES shading language version: OpenGL ES GLSL ES 3.20
• GL_EXT_framebuffer_blit: yes
• GL_EXT_texture_format_BGRA8888: yes
[✓] Connected device (2 available) [279ms]
• Linux (desktop) • linux • linux-x64 • Kali GNU/Linux Rolling 6.11.2-amd64
• Chrome (web) • chrome • web-javascript • Google Chrome 130.0.6723.69
[✓] Network resources [1,219ms]
• All expected network resources are available.
! Doctor found issues in 1 category.
```
Contributor guide
Research direction
Start by reproducing the provided SearchAnchor.bar sample in a release web build on Android Desktop Mode, using the listed Chrome and Firefox setup. Trace the SearchAnchor view and focus behavior after the search bar is clicked. Done means the view stays open and typing does not overwrite unexpectedly selected text.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- frontend, mobile-dev, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100