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

Left aligned title for SlicerAppBar and FlexibleSpace #11951

Closed
balazsgerlei opened this issue Sep 6, 2017 · 18 comments · Fixed by #27623
Closed

Left aligned title for SlicerAppBar and FlexibleSpace #11951

balazsgerlei opened this issue Sep 6, 2017 · 18 comments · Fixed by #27623
Labels
f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. waiting for PR to land (fixed) A fix is in flight

Comments

@balazsgerlei
Copy link

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?

@Hixie Hixie added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels May 18, 2018
@Hixie Hixie added this to the Goals milestone May 18, 2018
@Hixie
Copy link
Contributor

Hixie commented May 18, 2018

cc @HansMuller

@hereisderek
Copy link

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

@DengKangKang
Copy link

Any solution?

@crushman1
Copy link

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

@hardypatel30
Copy link

hardypatel30 commented Dec 9, 2019

@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

@hardypatel30
Copy link

@Unfreeze-kk , @balazsgerlei Found the solution on my own and added answer there as well.

https://stackoverflow.com/questions/59243525/sliver-appbar-collapsing-toolbar-animate-title-from-left-to-center-in-flutter/59434248#59434248

Check it.

@xJon
Copy link

xJon commented Jun 1, 2020

@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

@lucasjinreal
Copy link

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

@xJon
Copy link

xJon commented Sep 16, 2020

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

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

@lucasjinreal
Copy link

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

@prazedotid
Copy link

prazedotid commented Sep 19, 2020

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

@lucasjinreal
Copy link

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

@percula
Copy link

percula commented Oct 29, 2020

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

@lucasjinreal
Copy link

@percula Do u have gif to post?

@percula
Copy link

percula commented Oct 30, 2020

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.

@lucasjinreal
Copy link

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

@DishitaShah
Copy link

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

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

@github-actions
Copy link

github-actions bot commented Aug 1, 2021

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. waiting for PR to land (fixed) A fix is in flight
Projects
None yet
Development

Successfully merging a pull request may close this issue.