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

后端 未结 9 1405
滥情空心
滥情空心 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:00

    In my case I did it as follows:

    Additional create an app bar with a custom back button (in this case with a FloatingActionButton). You can still add widgets inside the Stack.

    class Home extends StatefulWidget {
      @override
      _EditProfilePageState createState() => _EditProfilePageState();
    }
    
    class _HomeState extends State< Home > {
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: Stack(
            children: [
              this._backgroundImage(), // --> Background Image
              Positioned( // --> App Bar
                child: AppBar(
                  backgroundColor: Colors.transparent,
                  elevation: 0.0,
                  leading: Padding( // --> Custom Back Button
                    padding: const EdgeInsets.all(8.0),
                    child: FloatingActionButton(
                      backgroundColor: Colors.white,
                      mini: true,
                      onPressed: this._onBackPressed,
                      child: Icon(Icons.arrow_back, color: Colors.black),
                    ),
                  ),
                ),
              ),
              // ------ Other Widgets ------
            ],
          ),
        );
      }
    
      Widget _backgroundImage() {
        return Container(
          height: 272.0,
          width: MediaQuery.of(context).size.width,
          child: FadeInImage(
            fit: BoxFit.cover,
            image: NetworkImage(
                'https://images.unsplash.com/photo-1527555197883-98e27ca0c1ea?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&w=1000&q=80'),
            placeholder: AssetImage('assetName'),
          ),
        );
      }
    
      void _onBackPressed() {
        Navigator.of(context).pop();
      }
    }
    

    In the following link you can find more information Link

提交回复
热议问题