flutter SafeArea hides system icons unexpectedly - flutter

I'm using SafeArea to avoid my display area clashing with the latest phones statusbar and camera notch. I use Scaffold without an AppBar.
Problem
Although the display area works as expected, a side-effect happens: the statusbar becomes a single-color region and all system icons include WIFI and battery disappear.
Attempts
I've tried various tips, including
Flutter - System bar colors with SafeArea
Flutter - How to set status bar color when AppBar not present
But all they do is set the color. The icons are still missing.
Question
Is this by design or am I missing any useful properties of SafeArea?

Try this
If you are using like this
Widget build(BuildContext context) { return SafeArea(...); }
then try this
Widget build(BuildContext context) { return AnnotatedRegion( value: SystemUiOverlayStyle.light, child:SafeArea(...);

Related

How can I measure the specific height in the flutter?

I have no idea to figure out this problem in flutter. I want to know the size without app bar size and tab bar size(up).
I use variable "vertical_size" as
var vertical_size = (MediaQuery.of(context).size.height -
AppBar().preferredSize.height -
MediaQuery.of(context).padding.top);
but I didn't figure out the tab bar size. It's mean there are oversized in Iphone. (Android is okay in now...)
Do you have any idea to measure tabbar height using Mediaquery? Or is there any idea to measure the actual using area?
You can always figure out the free space in any place you want in your layout with LayoutBuilder
In case of full usable screen height, you can use MediaQuery, but aparat from appbar's height and top padding, remember about bottom padding. You need to substract it as well
Hi and welcome to StackOverflow.
It's not oversized in iOS. What happens is that the AppBar will have in consideration the safe area, hence, its heigh will be bigger/smaller based on the device it is running on.
If you want to get the height of the screen without the AppBar heigh, just do it as the following:
Widget build() {
AppBar appBar = AppBar();
double vertical_size = MediaQuery.of(context).size.height - appBar.preferredSize.height;
return Scaffold(
appBar: appBar,
body: // your widget
);
}
The AppBar's height will have in consideration the device's status bar and so on, so there's no need to remove the inset padding manually.

What is this extra space above my appbar?

This is the default flutter application template with only some extra styling for the title.
EDIT:
Here is a better image without transparency. I am referring to the space above the Appbar
MaterialApp(
home: HomePage());
}
Use MaterialApp Not Scaffold();
This extra space is toolbar height that related to your virtual device model. please change your device and then see what happened. I guess the problem is virtual device screen.
Or you can use SafeArea Widget to solve your problem.

Should I always use a SafeArea at the top level of my flutter screens?

I am curious if I should always use a SafeArea widget at the top level of my screen. I mean....when would I want my content blocked by things like a notch? For me it seems like the answer is never.
So should I not just use SafeArea on every page? If so, should it be above or below the Scaffold widget?
You don't have to use SafeArea on every screen. It actually depends if an AppBar is used or not, because the AppBar automatically calculates the values and adds the required padding.
If you use it above a Scaffold the area where the padding is applied would be black. On the other hand, if you use it below the Scaffold the color of the area would depend on the app theme, probably the Scaffold background color.
If you won't add an app bar or add it. if you want to adjust the screen to be responsive using MediaQuery and you don't need any scroll inside the screen use it.
Use it as the first widget in the body of the scaffold.

Customize the App Bar from the phone's opened apps menu with Flutter

I am making an app with Flutter and I want to change the text and the color of the bar that appears on the opened apps menu on the phone.
For example, in the linked image below, change the text from "Pokemon Go" to something else, and change the color from grey to blue.
https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSyrJhMbO_QCYgVxInVT1Ff1QuP_9aHAvClIg&usqp=CAU
You can acheive this by wrapping your root Widget with MaterialApp(); and specifying the title of the material app like:MaterialApp(title: "Paco") and specifing the primary color: MaterialApp(title: "Paco",theme: ThemeData(primaryColor: Colors.blue),);

How to work with a CustomAppBar in flutter when the phone has a notch?

does anyone know how to use the SafeArea widget in a custom app bar. I am having a red overflow flex box appear on my custom app bar due to a notch in my emulator. I want to still show my custom app bar without the red overflow box in a way that looks presentable. When I tried surrounding my appbar in a safeArea widget I received an error in my Scaffold widget where I had placed my appBar. The code looked like this: Scaffold( appBar: customAppBar(context)). The error read: The argument type 'SafeArea' can't be assigned to the parameter type 'PreferredSizeWidget'. I believe that the Scaffold expects a PreferredSizeWidget but is receiving a safeArea widget instead. Please let me know if there are any other solutions out there other than using the SafeArea widget. Below is a photo of what my emulator looks like with the custom app bar and the red overflow box.
If you always want to make sure notches and punch holes don't get into your AppBar or UI, use the builder function from MaterialApp like this:
#override
Widget build(BuildContext context) {
return MaterialApp(
builder: (context, child) => SafeArea(child: child),
home: MyApp(),
);
}
Now every single Page/Screen will be safe from being cut on the top.