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

后端 未结 9 1438
滥情空心
滥情空心 2020-12-28 12:42

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 separat

相关标签:
9条回答
  • 2020-12-28 13:11

    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")),
        );
      }
    
    0 讨论(0)
  • 2020-12-28 13:13

    None of these seem to work for me, mine went something like this:

    return Scaffold(
      extendBodyBehindAppBar: true,
      appBar: AppBar(
        backgroundColor: Colors.transparent,
        iconTheme: IconThemeData(color: Colors.white),
        elevation: 0.0,
        brightness: Brightness.dark,
      ),
      body: Stack(
        children: <Widget>[
          Container(
            decoration: BoxDecoration(
              image: DecorationImage(
                image: NetworkImage(
                    'https://images.unsplash.com/photo-1517030330234-94c4fb948ebc?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1275&q=80'),
                fit: BoxFit.cover,
              ),
            ),
            child: Padding(
              padding: const EdgeInsets.fromLTRB(0, 100, 0, 0),
              child:
              // Column of widgets here...
            ),
           ),
         ],
       ),
     );
    
    0 讨论(0)
  • 2020-12-28 13:21

    use stack

    • set background image
      • Another Scaffold()
        • set background color transperant
        • set custom appbar
        • use column with singleChildScrollView or ListView

    @override   Widget build(BuildContext context) {
            return Scaffold(
              body: Stack(
                children: <Widget>[
                  backgroundBGContainer(),
                  Scaffold(
                    backgroundColor: Colors.transparent,
                    appBar: appBarWidgetCustomTitle(context: context, titleParam: ""),
                    body: SingleChildScrollView(
                      child: Column(
                        children: <Widget>[
                          _spaceWdgt(),
                          Center(
                            child: Stack(
                              children: <Widget>[
                                new Image.asset(
                                  "assets/images/user_icon.png",
                                  width: 117,
                                  height: 97,
                                ),
                              ],
                            ),
                          ),
    
    
    
    
      Widget backgroundBGContainer() {
          return Container(
            decoration: new BoxDecoration(
                image: new DecorationImage(
                  image: new AssetImage("assets/images/ground_bg_image.png"),
                  fit: BoxFit.cover,
                ),
                color: MyColor().groundBackColor),
          );
        }
    
    0 讨论(0)
提交回复
热议问题