10000 `SliverAppBar` needs a custom widget area at the bottom of the layout · Issue #129868 · flutter/flutter · GitHub
[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SliverAppBar needs a custom widget area at the bottom of the layout #129868

Closed
2 tasks done
lukehutch opened this issue Jul 1, 2023 · 13 comments
Closed
2 tasks done

SliverAppBar needs a custom widget area at the bottom of the layout #129868

lukehutch opened this issue Jul 1, 2023 · 13 comments
Labels
c: new feature Nothing broken; request for a new capability c: proposal A detailed proposal for a change to Flutter f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. P2 Important issues not at the top of the work list team-design Owned by Design Languages team triaged-design Triaged by Design Languages team waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds

Comments

@lukehutch
Copy link
Contributor
lukehutch commented Jul 1, 2023

Is there an existing issue for this?

Use case

I want to add some custom dropdown controls below the title text in the SliverAppBar. There is no clean way to do this currently.

I have a SliverAppBar that contains a FlexibleSpaceBar with a cover image, a drawer, and some title text.

I tried adding these controls to the FlexibleSpaceBar, by hijacking background with a Column widget, but clearly the layout was not designed for this, and it's pretty much impossible to get the layout and animation right.

I added a SliverPersistentHeader, which does place the controls below the SliverAppBar, but there are several issues:

  • Really I just want the extra controls in the SliverPersistentHeader to appear as part of the SliverAppBar, not have their own hide/show semantics that are different from those of the SliverAppBar.
  • The pinning/floating behavior of SliverPersistentHeader is bizarre at best -- I want this header to appear whenever the SliverAppBar is maximized and I drag down, at any position in the wrapping CustomScrollView. However, SliverPersistentHeader seems to pin at an absolute position near the top of the CustomScrollView, so it only appears if I scroll the CustomScrollView nearly to the top. See floating behavior of SliverPersistentHeader does not match that of SliverAppBar #129869.
  • There is a tiny half-pixel gap between the SliverAppBar and the SliverPersistentHeader. This shows up as a faint white line occasionally, since both the app bar and the header have non-white backgrounds. See There is a half-pixel gap between SliverAppBar and SliverPersistentHeader #129870.

Proposal

Please add a SliverAppBar.footer field that allows the user to add a Widget to the bottom of the SliverAppBar.

It would also be great if this footer were dyamically-sizeable, so that content could be added to or removed from it, and it would take only as much vertical space as necessary to wrap the content.

@lukehutch
Copy link
Contributor Author

I just discovered bottom, a PreferredSizeWidget -- not sure how I missed that! Sorry...

@lukehutch
Copy link
Contributor Author

Actually I just tried bottom, and it doesn't have the desired behavior either:

  • Extra space is not added to the bottom of the SliverAppBar for the bottom widget, the widget is only bottom-aligned to the existing SliverAppBar. There is not much space below the title to show extra widgets.
  • If the preferredSize.height value is too large, it interferes with the scaling of the title text.
  • If the preferredSize.height value is too small, you get layout overflows.

I want to be able to simply add an extra widget area to the bottom of the SliverAppBar. (Reopening.)

@lukehutch lukehutch reopened this Jul 1, 2023
@darshankawar darshankawar added the in triage Presently being triaged by the triage team label Jul 3, 2023
@darshankawar
Copy link
Member

Thanks for the report @lukehutch
Can you provide us an example of the use case you are trying to achieve ?

@darshankawar darshankawar added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jul 3, 2023
@lukehutch
Copy link
Contributor Author

@darshankawar Sure, this is the UI I built using SliverAppBar with SliverPersistentHeader:

image

Each of the tabs on the bottom switches to a different page with a different SliverAppBar (with a different cover image at the top, etc.).

I want to be able to put filter controls on each of the 5 tab pages, that are relevant to that tab. Here I have two dropdown controls for the Social page.

SliverPersistentHeader is not a great solution to this, for the reasons I gave above. Additionally, there is a large gap between the title text ('Social') and the SliverPersistentHeader.

I want to add these two comboboxes directly to the bottom of the SliverAppBar. Other tabs may have several rows of filter controls. Also, the controls may need to be changed dynamically, and it would be awesome if the SliverAppBar could resize dynamically to fit in whatever widgets are added as a footer.

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jul 3, 2023
@darshankawar
Copy link
Member

Thanks for the update.

@darshankawar darshankawar added c: new feature Nothing broken; request for a new capability framework flutter/packages/flutter repository. See also f: labels. f: scrolling Viewports, list views, slivers, etc. c: proposal A detailed proposal for a change to Flutter f: material design flutter/packages/flutter/material repository. and removed in triage Presently being triaged by the triage team labels Jul 4, 2023
@HansMuller HansMuller self-assigned this Jul 5, 2023
@flutter-triage-bot flutter-triage-bot bot added multiteam-retriage-candidate team-design Owned by Design Languages team triaged-design Triaged by Design Languages team labels Jul 8, 2023
@Piinks Piinks added the P2 Important issues not at the top of the work list label Jul 10, 2023
@flutter-triage-bot flutter-triage-bot bot added the Bot is counting down the days until it unassigns the issue label Nov 27, 2023
@flutter-triage-bot
Copy link

This issue is assigned to @HansMuller but has had no recent status updates. Please consider unassigning this issue if it is not going to be addressed in the near future. This allows people to have a clearer picture of what work is actually planned. Thanks!

@flutter-triage-bot
8000
flutter-triage-bot bot removed the Bot is counting down the days until it unassigns the issue label Mar 6, 2024
@flutter-triage-bot flutter-triage-bot bot added the Bot is counting down the days until it unassigns the issue label Jul 11, 2024
@flutter-triage-bot
Copy link

This issue is assigned to @HansMuller but has had no recent status updates. Please consider unassigning this issue if it is not going to be addressed in the near future. This allows people to have a clearer picture of what work is actually planned. Thanks!

@flutter-triage-bot flutter-triage-bot bot removed the triaged-design Triaged by Design Languages team label Oct 27, 2024
@flutter-triage-bot
Copy link

This issue was assigned to @HansMuller but has had no status updates in a long time. To remove any ambiguity about whether the issue is being worked on, the assignee was removed.

@flutter-triage-bot flutter-triage-bot bot removed the Bot is counting down the days until it unassigns the issue label Oct 27, 2024
@justinmc justinmc added P3 Issues that are less important to the Flutter project triaged-design Triaged by Design Languages team labels Oct 30, 2024
@justinmc
Copy link
Contributor

@victorsanni to take a look from triage, thank you!

@justinmc justinmc removed the P3 Issues that are less important to the Flutter project label Oct 30, 2024
@victorsanni
Copy link
Contributor

It would also be great if this footer were dyamically-sizeable, so that content could be added to or removed from it, and it would take only as much vertical space as necessary to wrap the content.

The dynamically resizing feature is a duplicate of #18345. The problem with that is SliverAppBar uses SliverPersistentHeader under the hood, so it needs to know its max/min extents before build. But the child sizes are determined during build, and the max/min extents are dependent on the child size.

Extra space is not added to the bottom of the SliverAppBar for the bottom widget, the widget is only bottom-aligned to the existing SliverAppBar. There is not much space below the title to show extra widgets.

Under the hood, the SliverAppBar is wrapped with a column within which the bottom widget is inserted. My understanding is that gives the user full control as to the spacing available to the bottom widget?

Overall, it's still not clear to me what this issue is asking for. Can you expand a little more on it? Thanks @lukehutch @martipello

@lukehutch
Copy link
Contributor Author

@victorsanni Thanks for looking into this. I forgot to mention I'm using a FlexibleSpaceBar inside the SliverAppBar, and the FlexibleSpaceBar was where I was trying to add extra widgets at the bottom, as shown in the screenshot. I had to fork FlexibleSpaceBar to achieve this. Sorry for the confusion.

But based on what you're saying, I could have just added these to the SliverAppBar, rather than the nested FlexibleSpaceBar? If so, then it sounds like this is already doable.

@victorsanni
Copy link
Contributor
victorsanni commented Nov 7, 2024

But based on what you're saying, I could have just added these to the SliverAppBar, rather than the nested FlexibleSpaceBar?

As SliverAppBar.bottom.

Consider this code sample where I add a FlutterLogo at the bottom of a SliverAppBar with a FlexibleSpaceBar:

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

/// Flutter code sample for [FlexibleSpaceBar].

void main() => runApp(const MaterialApp(home: FlexibleSpaceBarExampleApp()));

class FlexibleSpaceBarExampleApp extends StatelessWidget {
  const FlexibleSpaceBarExampleApp({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: CustomScrollView(
        physics: const BouncingScrollPhysics(
            parent: AlwaysScrollableScrollPhysics()),
        slivers: <Widget>[
          SliverAppBar(
            bottom: PreferredSize(
              preferredSize: Size.fromHeight(20),
              child: FlutterLogo(),
            ),
            stretch: true,
            onStretchTrigger: () {
              // Function callback for stretch
              return Future<void>.value();
            },
            expandedHeight: 500.0,
            flexibleSpace: FlexibleSpaceBar(
              stretchModes: const <StretchMode>[
                StretchMode.zoomBackground,
                StretchMode.blurBackground,
                StretchMode.fadeTitle,
              ],
              centerTitle: true,
              title: const Text('Flight Report'),
              background: Stack(
                fit: StackFit.expand,
                children: <Widget>[
                  Image.network(
                    'https://flutter.github.io/assets-for-api-docs/assets/widgets/owl-2.jpg',
                    fit: BoxFit.cover,
                  ),
                  const DecoratedBox(
                    decoration: BoxDecoration(
                      gradient: LinearGradient(
         
A76C
               begin: Alignment(0.0, 0.5),
                        end: Alignment.center,
                        colors: <Color>[
                          Color(0x60000000),
                          Color(0x00000000),
                        ],
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ),
          SliverList.builder(
            itemCount: 20,
            itemBuilder: (BuildContext context, int index) {
              return ListTile(
                leading: Icon(Icons.wb_sunny),
                title: Text('Day $index'),
                subtitle: Text('sunny, h: 80, l: 65'),
              );
            },
          ),
        ],
      ),
    );
  }
}

Is this sort of what you're looking for here? If so, then I think this issue can be closed.

@victorsanni victorsanni added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 24, 2025
Copy link

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now.
If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones.
Thanks for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: new feature Nothing broken; request for a new capability c: proposal A detailed proposal for a change to Flutter f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. P2 Important issues not at the top of the work list team-design Owned by Design Languages team triaged-design Triaged by Design Languages team waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds
Projects
None yet
Development

No branches or pull requests

7 participants
0