0

I need to use the property of AppBar, but I need the app bar to be the same color as the body. As if there is no appbar. I used the same color to the body and appBar but the appBar have a darker color!

Material App code:

class MyApp extends StatelessWidget {
  const MyApp();
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'AppName',
      theme: ThemeData(
        backgroundColor: Color(pagesBackgroundColor),
        appBarTheme: AppBarTheme(
          color: Color(pagesBackgroundColor),
        ),
      ),
      home: const HomePage(),
    );
  }
}

Home Page Code:

class HomePage extends StatelessWidget {
  const HomePage();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Color(pagesBackgroundColor),
        title: Text(
          "What's up!",
          style: TextStyle(color: Colors.black),
        ),
        elevation: 0.0,
      ),
      body: Column(),
    );
  }
}

enter image description here

Md. Yeasin Sheikh
  • 54,221
  • 7
  • 29
  • 56
  • Why not just remove the appBar? Also check [this](https://stackoverflow.com/questions/53080186/make-appbar-transparent-and-show-background-image-which-is-set-to-whole-screen) – tomerpacific Sep 08 '21 at 17:50

2 Answers2

3

set appbar color to transparent:

return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.transparent,
        title: Text(
          "What's up!",
          style: TextStyle(color: Colors.black),
        ),
        elevation: 0.0,
      ),
      body: Column(),
    );
Anas Nadeem
  • 779
  • 6
  • 10
0

I suggest removing the appBar completely and use the Align widget to place your other widget on top of the page like it was the appBar.

If you do remove the appBar, make sure to place your Scaffold inside a SafeArea widget.

I hope this helps until someone else can show how to make the appBar background color invisible.

return SafeArea(
  child: Scaffold(
    body: ListView(
      children: [
        Align(
          alignment: Alignment.topLeft,
          child: TextButton(),
        )
      ],
    ),
  ),
);
0m3r
  • 12,286
  • 15
  • 35
  • 71
Milford P
  • 48
  • 6