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

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

    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 {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: Stack(
            children: [
              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,
                ),
              ),
            ],
          ),
        );
      }
    }
    

提交回复
热议问题