Skip to content

Left aligned title for SlicerAppBar and FlexibleSpace #11951

Closed

Description

@balazsgerlei

Hi!

I'm trying to implement a "Collapsing Toolbar", or the "Flexible space with image" scrolling technique from the Material Design spec, but I don't have a back button or navigation drawer. So I would like the title to be near the left edge, without any left padding/space. When I use the SliverAppBar and FlexibleSpace I can only get it to display the title with a considerable left padding, which when collapsed gives space to a back button or navigation drawer (hamburger) icon. This is not the behaviour I want, I would like to do something similar to the Android Contacts app:

example1

Is this possible (without implementing my new SicerAppBar and FlexibleSpace class from scratch), and if so, how to do it?

Activity

  1. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    on May 18, 2018
  2. added this to the milestone on May 18, 2018
  3. Hixie commented on May 18, 2018

    @Hixie
    Contributor
  4. hereisderek commented on Sep 21, 2018

    @hereisderek

    this is brought up a year ago, and I'd still very much like to see this

  5. Paul5823 commented on Dec 6, 2018

    @Paul5823

    Any solution?

  6. crushman1 commented on Jul 1, 2019

    @crushman1

    In FlexibleSpaceBar set titlePadding: EdgeInsets.all(0.0),

  7. hardypatel30 commented on Dec 9, 2019

    @hardypatel30

    @crushman1 this solution would overlap title and left icon in the appbar. We need to find another solution for the same.

    I asked question in s.o also .
    https://stackoverflow.com/questions/59243525/sliver-appbar-collapsing-toolbar-animate-title-from-left-to-center-in-flutter

  8. hardypatel30 commented on Dec 21, 2019

    @hardypatel30
  9. xJon commented on Jun 1, 2020

    @xJon

    @crushman1's answer actually fits the request of @balazsgerlei, but a more flexible option is possible with a scroll controller:

    https://stackoverflow.com/a/62137478/7885980

  10. lucasjinreal commented on Sep 16, 2020

    @lucasjinreal

    @Hixie @xJon Any standard solution to get the exactly same effect?

  11. xJon commented on Sep 16, 2020

    @xJon

    @Hixie @xJon Any standard solution to get the exactly same effect?

    See my answer over https://stackoverflow.com/a/62137478

  12. lucasjinreal commented on Sep 17, 2020

    @lucasjinreal

    @xJon I tried your anwser, it's nto work like this, not smooth..

  13. prazedotid commented on Sep 19, 2020

    @prazedotid

    @Hixie @xJon Any standard solution to get the exactly same effect?

    See my answer over https://stackoverflow.com/a/62137478

    Unfortunately, this answer does not work for SliverAppBar with kExpandedHeight value of less than around 250.

  14. lucasjinreal commented on Sep 21, 2020

    @lucasjinreal

    @prazeblaze Do u have a better solution on this? my kExpandedHeight actually less than 250, (100)

  15. percula commented on Oct 29, 2020

    @percula

    @prazeblaze Do u have a better solution on this? my kExpandedHeight actually less than 250, (100)

    Checkout my solution at https://stackoverflow.com/a/64583870/6591585. It only rebuilds what is necessary and will work for smaller expanded heights.

  16. lucasjinreal commented on Oct 29, 2020

    @lucasjinreal

    @percula Do u have gif to post?

  17. percula commented on Oct 30, 2020

    @percula

    No gif, just copy/paste.

    I ended up creating a better solution that utilizes the transformations already happening within the FlexibleSpaceBar. Just provide a titlePaddingTween such as

    titlePaddingTween: EdgeInsetsTween(begin: EdgeInsets.only(left: 16.0, bottom: 16), end: EdgeInsets.only(left: 72.0, bottom: 16))

    instead of titlePadding.

    I also added a foreground parameter that displays above the title and background, but doesn't transform as they do.

  18. lucasjinreal commented on Oct 30, 2020

    @lucasjinreal

    @percula Can u make it a github repo or pub.dev lib for quickly usage?

  19. DishitaShah commented on May 21, 2021

    @DishitaShah

    To left align your SliverAppBar title, just use property "centerTitle" of SliverAppBar

    SliverAppBar(
    centerTitle: false,
    title: Text('Title'),
    ),

  20. github-actions commented on Aug 1, 2021

    @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.

  21. locked as resolved and limited conversation to collaborators on Aug 1, 2021
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

    frameworkflutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packageswaiting for PR to land (fixed)A fix is in flight

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions