flutter如何实现导航状态栏透明?

发布于 1 年前 作者 phonegap100 375 次浏览 最后一次编辑是 1 年前 来自 问答

flutter如何实现导航状态栏透明

一、Flutter透明状态栏设置

import 'package:flutter/services.dart';

void main() {
   //flutter修改状态栏的颜色
  SystemUiOverlayStyle systemUiOverlayStyle = const SystemUiOverlayStyle(statusBarColor: Colors.transparent);
  SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
  ...
}

二、 Flutter透明顶部导航

Appbar 通过 elevation: 0 消除阴影, 通过backgroundColor: Colors.transparent 可以配置Flutter透明顶部导航

 Positioned(
              top: 0,
              left: 0,
              right: 0,
              child: AppBar(
                title: const Text('CategoryView'),
                centerTitle: true,
                backgroundColor: Colors.transparent,
                elevation: 0, //消除阴影
 ))
回到顶部