I have added AppBar in my flutter application. My screen already have a background image, where i don't want to set appBar color or don't want set separate background image to appBar.
I want show same screen background image to appBar also.
I already tried by setting appBar color as transparent but it shows color like gray.
Example code:
appBar: new AppBar(
centerTitle: true,
// backgroundColor: Color(0xFF0077ED),
elevation: 0.0,
title: new Text(
"DASHBOARD",
style: const TextStyle(
color: const Color(0xffffffff),
fontWeight: FontWeight.w500,
fontFamily: "Roboto",
fontStyle: FontStyle.normal,
fontSize: 19.0
)),
)
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.
The default AppBar's appearance will show solid background color with drop shadow. Default AppBar appearance. To make the AppBar transparent, we need to change backgroundColor and elevation properties. You can easily support sarunw.com by checking out this sponsor.
How to make AppBar/Navigation Bar transparent in Flutter 1 Background Color. You can change the background color of the AppBar by modifying the backgroundColor property. ... 2 Elevation. We can control the elevation distance with the elevation property. ... 3 Solution. ...
Add the appBar into a Stack within the Scaffold's body. Add another Container to fill the screen to the Stack. Add all the components into that Container. That's it. You may now add background blur to the appBar and it works like a charm. Worked for me Body extending behind AppBar is now supported by Scaffold.
1 1 This won't make the AppBaras big as your image, it will clip the image. – Michel Feinstein Feb 11 '20 at 2:00 Add a comment | 9
This is supported by Scaffold now (in stable - v1.12.13+hotfix.5).
extendBodyBehindAppBar
to true,elevation
to 0 to get rid of shadow,backgroundColor
transparency as needed. @override
Widget build(BuildContext context) {
return Scaffold(
extendBodyBehindAppBar: true,
backgroundColor: Colors.red,
appBar: AppBar(
// backgroundColor: Colors.transparent,
backgroundColor: Color(0x44000000),
elevation: 0,
title: Text("Title"),
),
body: Center(child: Text("Content")),
);
}
you can use Stack widget to do so. Follow below example.
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Home(),
);
}
}
class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: <Widget>[
Scaffold(
backgroundColor: Colors.transparent,
appBar: new AppBar(
title: new Text(
"Hello World",
style: TextStyle(color: Colors.amber),
),
backgroundColor: Colors.transparent,
elevation: 0.0,
),
body: new Container(
color: Colors.red,
),
),
],
),
);
}
}
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