How can I replace the AppBar
title with image logo in Flutter?
To add the background image to AppBar widget, we can use the flexibleSpace option of the widget. The flexibleSpace property of AppBar accepts a widget as its value, so we can pass a Container widget as its value and set an image background to the Container.
Use leading to set a widget before appBar title and use actions to specify list of widgets in appBar which appears on right side of appBar title. AppBar( leading: Image. asset('yourImage'), // you can put any Widget title: Text ("Title"), actions: [ Icon(Icons. shopping_cart), Icon(Icons.
Step 2: Inside the AppBar widget, find the Text widget inside the title parameter. Step 3: Inside the Text widget, add the style parameter and add the TextStyle widget. Step 4: Inside the TextStyle widget, add the color parameter and assign the appropriate color. Step 5: Run the app.
The title
property takes a Widget
, so you can pass any widget to it.
For example, an image added to assets
Scaffold( appBar: AppBar( title: Image.asset('assets/title.png', fit: BoxFit.cover), ), body: ... )
More info
appBar: AppBar( title: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( 'assets/logo.png', fit: BoxFit.contain, height: 32, ), Container( padding: const EdgeInsets.all(8.0), child: Text('YourAppTitle')) ], ), )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With