How to create button on the left in Appbar [flutter]
Asked Answered
N

2

7

I tried to make the button[that pop new screen]on the left of the app-bar but I found only drawer that is not what I want.

what I want in AppBar:

------------------------------------------------<br>
| button |----------text----------| button |<br>
------------------------------------------------<br>

what I have now:

------------------------------------------------<br>
----------------text----------------| button | <- form actions in AppBar<br>
------------------------------------------------<br>
Nonsuch answered 21/3, 2021 at 15:22 Comment(1)
Relavent code snippet will help me to answer your question.Sweater
F
9

If I understand correctly, you want to add a left button to your AppBar. You can achieve that by using the leading property, like this:

AppBar(
  title: Text("AppBar with leading button"),
  automaticallyImplyLeading: false,
  leading: IconButton (
                 icon: Icon(Icons.arrow_back), 
                 onPressed: () { 
                       /** Do something */ 
                 },
            ),
)
Frequently answered 21/3, 2021 at 15:41 Comment(0)
A
6

To insert a widget on the left side of an Appbar, you must use the property: "leading", in addition to this, you can increase the width of this widget with the property: "leadingWidth"

appbar: AppBar(
  leading: Widget(),
  leadingWidth: 100
 )
Aftergrowth answered 21/3, 2021 at 15:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.