I want to add a logo image on the left side of my AppBar, as following: https://i.stack.imgur.com/qGIbb.png
This is my current code:
main.dart:
import 'package:flutter/material.dart';
import 'home_page.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(title: "Chat App", home: new LoginPage());
}
}
home_page.dart:
import 'package:flutter/material.dart';
class LoginPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Smart ID',
home: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/background.png"), fit: BoxFit.cover)),
child: Scaffold(
backgroundColor: Colors.transparent,
appBar: AppBar(
elevation: 0,
backgroundColor: Color(0xff05B068),
centerTitle: true,
title: Text('SMARTID', style: TextStyle(fontFamily: 'Open Sans', fontWeight: FontWeight.bold)),
),
),
)
);
}
}
How do I apply the logo image?
Do it like,
appBar: AppBar(
leading: Padding(
padding: const EdgeInsets.all(8.0),
child: Image.asset(
"assets/images/appicon.png",
),
),
Output
Add your logo in assets folder like this,
Then open pubspec.yaml and add your logo,
At last, press get packages,
There is a parameter called leading
that takes a widget
and places it on the left side of your AppBar
.
Replace the Icon
that i put with your logo:
AppBar(
elevation: 0,
backgroundColor: Color(0xff05B068),
centerTitle: true,
leading: Icon(Icons.arrow_forward_ios),
title: Text('SMARTID', style: TextStyle(fontFamily: 'Open Sans', fontWeight: FontWeight.bold)),
),
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