Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make AppBar transparent and show background image which is set to whole screen

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
            )),
      )

enter image description here

like image 794
Rahul Mahadik Avatar asked Oct 31 '18 09:10

Rahul Mahadik


People also ask

How do I add an image to the leading AppBar flutter?

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.

How to make the appbar transparent?

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?

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. ...

How to add background blur to the appbar?

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.

Will appbaras make my image as big as my image?

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


2 Answers

This is supported by Scaffold now (in stable - v1.12.13+hotfix.5).

  • Set Scaffold extendBodyBehindAppBar to true,
  • Set AppBar elevation to 0 to get rid of shadow,
  • Set AppBar 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")),
    );
  }
like image 181
gswierczynski Avatar answered Oct 08 '22 23:10

gswierczynski


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,
            ),
          ),
        ],
      ),
    );
  }
}
like image 78
Viren V Varasadiya Avatar answered Oct 08 '22 23:10

Viren V Varasadiya