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 witho
You can wrap the Scaffold
into SafeArea
, as below:
import 'package:flutter/material.dart';
void main() => runApp(MyApp(
textInput: Text("Text Widget"),
));
class MyApp extends StatefulWidget {
final Widget textInput;
MyApp({this.textInput});
@override
State<StatefulWidget> createState() => MyAppState();
}
class MyAppState extends State<MyApp> {
bool checkBoxValue = false;
@override
Widget build(BuildContext ctxt) {
return new MaterialApp(
home: SafeArea(
child: Scaffold(
body: new Center(
child: new Column(
children: <Widget>[
widget.textInput,
Checkbox(
value: checkBoxValue,
onChanged: (bool newValue){
setState(() {
checkBoxValue = newValue;
});
}
)
],
))),
),
);
}
}
About the opposite, in case you do not need to keep repeating the AppBar
in your multiple screens, you can create separate widget:
import 'package:flutter/material.dart';
import 'state.dart';
AppBar commonAppBar(String title, void action()) {
return new AppBar(
title: new Text(title),
actions: [
new IconButton(icon: new Icon(Icons.flip), onPressed: action),
new IconButton(icon: new Icon(Icons.exit_to_app), onPressed: () {
new StateSubject().switchToLogin();
}),
],
);
}
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'));