Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter application design without AppBar

Tags:

flutter

dart

I tried using this kind of approach to have all of my UI (here only a Text) in the application below the status bar, but without AppBar:

import 'package:flutter/material.dart';

void main() => runApp(MaterialApp(
      title: "example",
      home: Scaffold(
        body: Text("text widget"),
      ),
    ));

This question was already asked once similar to my text, but the answer to it (which is also accepted) only takes margin into account. This, to me, does not seem like a satisfying solution, especially because you need to access MediaQuery.of(context).padding, where I could not even figure out how to use context in my simple example.

My code gives me the following result:

get

But I want to see this:

want

Now to make the differenciation between my question and the other question clear: I am not searching for a margin, I am searching for a legitimate idiomatic way of doing this. What I mean with this might look like this:

ScaffoldWithoutAppBar(body: ...

Obviously this does not exist, but I do not want a margin fix.

like image 201
creativecreatorormaybenot Avatar asked Apr 29 '18 21:04

creativecreatorormaybenot


People also ask

Can we use drawer without AppBar in Flutter?

You have your own custom Menu button to open/close drawer. You don't want to use AppBar as well. In that case you can use GlobalKey<ScaffoldState>() object to open Drawer.

How do I get rid of AppBar Flutter?

The right and simplest way to remove back button on Appbar in Flutter is to set the automaticallyImplyLeading property of the AppBar to false and replace the old screen in a stack with the current/new screen.


1 Answers

Wrap your page content (Text or Scaffold) inside a SafeArea widget

A widget that insets its child by sufficient padding to avoid intrusions by the operating system.

return new SafeArea(child: new Text('text widget'));
like image 130
aqwert Avatar answered Oct 17 '22 16:10

aqwert