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

后端 未结 9 1441
滥情空心
滥情空心 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 12:59

    You can Try this This code work for me

    @override
      Widget build(BuildContext context) {
        _buildContext = context;
        sw = MediaQuery.of(context).size.width;
        sh = MediaQuery.of(context).size.height;
    
        return new Container(
          child: new Stack(
            children: [
              new Container(
                child: Stack(
                  children: [
                    Container(
                      padding: EdgeInsets.all(20.0),
                      decoration: BoxDecoration(image: backgroundImage),
                    ),
                  ],
                ),
              ),
              new Scaffold(
                backgroundColor: Colors.transparent,
                appBar: new AppBar(
                  title: new Text(Strings.page_register),
                  backgroundColor: Colors.transparent,
                  elevation: 0.0,
                  centerTitle: true,
                ),
                body: SingleChildScrollView(
                  padding: EdgeInsets.all(20.0),
                  physics: BouncingScrollPhysics(),
                  scrollDirection: Axis.vertical,
                  child: new Form(
                    key: _formKey,
                    autovalidate: _autoValidate,
                    child: FormUI(),
                  ),
                ),
              )
            ],
          ),
        );
      }
    

    backgroundImage

    DecorationImage backgroundImage = new DecorationImage(
      image: new ExactAssetImage('assets/images/welcome_background.png'),
      fit: BoxFit.cover,
    );
    

提交回复
热议问题