flutter 全屏背景圖(包括appbar和狀態欄)


flutter全屏背景圖(包括appbar和狀態欄)以及沉浸狀態欄的設置

上面這個主要思路: 用一個  Container 組件 設置一張背景圖, 包裹  Scaffold 組件, 在 Scaffold 組件中設置 背景色 和 appbar 背景色 都為透明,然后設置 appbar 沒有陰影 

即: elevation: 0, 最后設置沉浸式狀態欄, 記錄一下,以前用過,忘記了

class _HomeState extends State<Home> {
  @override
  Widget build(BuildContext context) {
    SelfAdapt _adapt = SelfAdapt.init(context);
    return Container(
      width: _adapt.width,
      height: _adapt.height,
      decoration: BoxDecoration(
        image: DecorationImage(
          image: NetworkImage('https://img.zcool.cn/community/0372d195ac1cd55a8012062e3b16810.jpg'),
          fit: BoxFit.cover,
        ),
      ),
      child: Scaffold(
        backgroundColor: Colors.transparent,
        appBar: AppBar(
          elevation: 0,
          backgroundColor: Colors.transparent,
          // title: Text('首頁'),
        ),
        drawer: MyDrawer(),
        body: Container(
          width: _adapt.width,
          padding: _adapt.setfromLTRB(100, 0, 100, 0),
          child: Text('hello'),
        ),
      ),
    );
  }
}

 

 

flutter設置沉浸式狀態欄

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM