Flutter 设置AppBar为透明

C39A7397-C6B5-453E-A87C-2554C5DBE330.png
  1. 将Scaffold设置extendBodyBehindAppBar为true,
  2. 将AppBar设置elevation为0以消除阴影,
  3. backgroundColor根据需要设置AppBar的透明度。
@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")),
    );
  }

你可能感兴趣的:(Flutter 设置AppBar为透明)