admin管理员组

文章数量:1244317

I want to extendBodyBehindAppBar with in SafeArea but it's not working. Here is the code:

import 'package:flutter/material.dart';

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      extendBodyBehindAppBar: true,
      appBar: AppBar(
        automaticallyImplyLeading: false,
        backgroundColor: Colors.transparent,
        actions: [
          IconButton(
            onPressed: () {},
            icon: const Icon(Icons.bug_report),
          )
        ],
      ),
      body: SafeArea(
        child: Container(
          width: double.infinity,
          height: 100,
          color: Colors.yellow,
        ),
      ),
    );
  }
}

If I remove the SafeArea, the body now covers the system bar. How do I extendBodyBehindAppBar within SafeArea?

I want to extendBodyBehindAppBar with in SafeArea but it's not working. Here is the code:

import 'package:flutter/material.dart';

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      extendBodyBehindAppBar: true,
      appBar: AppBar(
        automaticallyImplyLeading: false,
        backgroundColor: Colors.transparent,
        actions: [
          IconButton(
            onPressed: () {},
            icon: const Icon(Icons.bug_report),
          )
        ],
      ),
      body: SafeArea(
        child: Container(
          width: double.infinity,
          height: 100,
          color: Colors.yellow,
        ),
      ),
    );
  }
}

If I remove the SafeArea, the body now covers the system bar. How do I extendBodyBehindAppBar within SafeArea?

Share Improve this question edited Feb 17 at 6:51 Ravindra S. Patil 14.8k5 gold badges19 silver badges49 bronze badges asked Feb 17 at 0:38 Hisham SyedHisham Syed 1159 bronze badges 2
  • means you don't wanna cover the statusBar? – Md. Yeasin Sheikh Commented Feb 17 at 2:56
  • @Md.YeasinSheikh Yes – Hisham Syed Commented Feb 17 at 14:19
Add a comment  | 

1 Answer 1

Reset to default 0

As easy hack will be using SafeArea over the Scaffold.

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

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      // bottom: ,//if you want to play
      // maintainBottomViewPadding: ,
      child: Scaffold(

本文标签: flutterUse SafeArea with AppBar and extendBodyBehindAppBarStack Overflow