Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase width of AppBar leading property

Tags:

flutter

dart

I'm trying to put text (custom text button) into leading property of AppBar. However when the text get too long then the text end up in multiple lines

Scaffold(
      appBar: AppBar(
        centerTitle: true,
        leading: Text('Go back to'),
      ),
    )

enter image description here

How do I increase width of AppBar leading property?

I don't want to use title because it makes centering title a PITA.

Scaffold(
      appBar: AppBar(
        centerTitle: true,
        title: Row(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          children: <Widget>[Text('go back to'), Text('My center title')],
        ),
      ),
    )

enter image description here

Is there any way to change it without messing with title property?

like image 325
delmin Avatar asked Oct 31 '25 09:10

delmin


1 Answers

You can set a custom leading width by using the leadingWidth property in the appBar:

Scaffold(
      appBar: AppBar(
        leadingWidth: 400,
        leading: Text('Go back to'),
        centerTitle: true,
        title: Text('Center title'),
      ),
)
like image 173
Masfour Avatar answered Nov 02 '25 22:11

Masfour