Skip to content

Can't make the status bar transparent when using NavigationDrawer,AnnotatedRegion not work #169251

@maxfrees

Description

@maxfrees

Steps to reproduce

Can't make the status bar transparent when using NavigationDrawer, AnnotatedRegion not work

Code sample

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Transparent Status Bar NavigationDrawer',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  void initState() {
    super.initState();
    // Set the status bar to be transparent.
    SystemChrome.setSystemUIOverlayStyle(
      const SystemUiOverlayStyle(
        statusBarColor: Colors.transparent,
        statusBarIconBrightness: Brightness.dark, // Use dark icons for better visibility
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      drawer: NavigationDrawer(
        children: <Widget>[
          GestureDetector(
            onTap: () => {},
            child: UserAccountsDrawerHeader(
              accountEmail: Text('Acc'),
              decoration: BoxDecoration(
                gradient: LinearGradient(
                  begin: Alignment.topCenter,
                  end: Alignment.bottomCenter,
                  colors: [
                    Colors.blue.withValues(alpha: 0.8),
                    Colors.blue.withValues(alpha: 0.6),
                    Colors.blue,
                  ],
                ),
              ),
              currentAccountPictureSize: Size(170, 72),
              accountName: Text('Acc'),
            ),
          ),
          Padding(
            padding: const EdgeInsets.fromLTRB(28, 0, 16, 10),
            child: ListTile(
              leading: const Icon(Icons.settings),
              title: const Text('Settings'),
              onTap: () {
                Navigator.pop(context);
              },
            ),
          ),
        ],
      ),
      body: Container(
        child: const Center(
          child: Text(
            'Content goes here!',
            style: TextStyle(fontSize: 24, color: Colors.white),
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

Video Screenshot
Screenrecorder-2025-05-22-11-45-47-13.mp4
Image

I hope to make the status bar transparent, but it seems that all methods I've tried fail to achieve this.

Flutter Doctor output

[!] Flutter (Channel stable, 3.32.0, on Microsoft Windows [ 10.0.19045.5854], locale zh-CN) [923ms]
    • Flutter version 3.32.0 on channel stable at E:\flutter\default
    ! Warning: `flutter` on your path resolves to E:\flutter\versions\stable\bin\flutter, which is not inside your
      current Flutter SDK checkout at E:\flutter\default. Consider adding E:\flutter\default\bin to the front of your
      path.
    ! Warning: `dart` on your path resolves to E:\flutter\versions\stable\bin\dart, which is not inside your current
      Flutter SDK checkout at E:\flutter\default. Consider adding E:\flutter\default\bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision be698c48a6 (2 days ago), 2025-05-19 12:59:14 -0700
    • Engine revision 1881800949
    • Dart version 3.8.0
    • DevTools version 2.45.1
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly
      to perform update checks and upgrades.

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listfound in release: 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyteam-androidOwned by Android platform teamtriaged-androidTriaged by Android platform team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions