没有AppBar的Flutter应用程序设计 [英] Flutter application design without AppBar

查看:121
本文介绍了没有AppBar的Flutter应用程序设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用这种方法将我的所有UI(这里只有 Text )存储在下面状态栏,但没有 AppBar

  import 'package:flutter / material.dart'; 

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

这个问题已经被提出,与我的文字类似,但是



但我想看到以下内容:





现在要弄清楚我的问题和另一个问题的区别:我不是在寻找保证金,我正在寻找一种合法的惯用方式。我的意思可能是这样的:

  ScaffoldWithoutAppBar(body:... 

显然这不存在,但我不希望保证金修正

解决方案

将页面内容(文本或脚手架)包装在



 返回新的SafeArea(child:new Text('text widget') ); 


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:

But I want to see this:

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.

解决方案

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'));

这篇关于没有AppBar的Flutter应用程序设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆