Skip to content

SearchAnchor.bar does not respect SearchBarThemeData.padding and SearchBarThemeData.leading #185889

Closed
flutter/packages
#13360

Description

@HeftyCoder

Steps to reproduce

Override the SearchBarTheme's padding property and place a SearchBar and a SearchAnchor.bar in the same screen.

Expected results

Both the SearchBar and SearchAnchor.bar should inherit the padding from the theme.

Actual results

SearchAnchor.bar does not respect the theme. Instead, when the barPadding property is null, it defaults to a const MaterialStatePropertyAll<EdgeInsets>(EdgeInsets.symmetric(horizontal: 16.0)), as seen in _SearchAnchorWithSearchBar.

That default value should be removed. However, I didn't know if this was indented, so I thought it best to report it as a potential bug from some older refactor.

Code sample

Code sample
SearchBarTheme(
  data: const SearchBarThemeData(
    padding: WidgetStatePropertyAll(EdgeInsets.all(16)),
  ),
  child: Column(
    children: [
      const SearchBar(),
      SearchAnchor.bar(
        suggestionsBuilder: (context, controller) => const [],
      ),
    ],
  ),
);

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[√] Flutter (Channel stable, 3.41.9, on Microsoft Windows [Version 10.0.26200.8246], locale en-US) [227ms]
    • Flutter version 3.41.9 on channel stable at C:\dev\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 00b0c91f06 (2 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, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration

Activity

  1. saurabh-mirajkar commented on May 4, 2026

    @saurabh-mirajkar
    Contributor

    @HeftyCoder Thanks for the report. Labelling for team-design to investigate further.

  2. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    team-designOwned by Design Languages team
    f: themingStyling widgets with a theme
    and removed
    in triagePresently being triaged by the triage team
    on May 4, 2026
  3. added
    P2Important issues not at the top of the work list
    triaged-designTriaged by Design Languages team
    on May 6, 2026
  4. MarlonJD commented on May 18, 2026

    @MarlonJD
    Contributor

    Proposed fix is in #186666. It is based on master, includes regression coverage for themed padding and explicit barPadding override, and local analyze/test passed. Current remaining blockers are review, CICD label, and Google testing.

  5. QuncCccccc commented on Jun 10, 2026

    @QuncCccccc
    Contributor

    This issue has been fixed by #186037. The PR is still open because we are in code freeze now so the PR cannot land it. That' said, we don't need more PRs for this one. Thanks everyone's contribution:)!

  6. added
    packageflutter/packages repository. See also p: labels.
    and removed
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Aug 17, 2026
  7. added a commit that references this issue on Nov 5, 2026
    3dbab32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listf: themingStyling widgets with a themehas reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagespackageflutter/packages repository. See also p: labels.team-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