How to prevent widgets from being hidden behind the system status bar - flutter

So I am creating a new flutter widget and I am unable to understand how my app looks because of the space on top of the screen in my emulator,
As you can see there is a shaded area on top and my widgets are under it, is there any way to remove it?

Use Safe Area.
SafeArea is basically a glorified Padding widget. If you wrap another widget with SafeArea, it adds any necessary padding needed to keep your widget from being blocked by the system status bar, notches, holes, rounded corners, and other "creative" features by manufacturers.
Check this link for more.

Wrap your code with the SafeArea.
more info about SafeArea class

Related

How to use SizeTransition with Text inside a Row without overflows

Problem summary
I'm building simple animation in which, simply, a panel expands to the right on a onTap event. The layout can be summarized as follows:
The panel has many tiles. Each tile has its own:
leading icon
title text
trailing icon
Each tile, when expanded, shows the three widgets above
Each tile, when shrinked, just shows the leading icon
The panel is scrollable to hold many icons such as these
At the end of the panel there's a simple icon which, when tapped, triggers the "expand" or "shrink" animation
The animation is built with an AnimatedContainer on the panel and a SizeTransition on the single tiles (via one single controller on the parent class)
The problem is simple: when the tiles shrink, their inner text overflows in the row.
Sample code
I just made this reproducible example on DartPad.
The obvious solution isn't helping me out
The most obvious solution is to simply wrap the Text inside a Flexible Widget: this advised by Flutter's docs and it makes sense, but unluckily it completely breaks my Layout.
Flexible introduces a flex factor that in this context is 100% unwanted.
I want my leading icons to be always at the end of the row, so my Spacer widget should "prevail" there.
I can't just play with flex factors there, as it would unintendedly hide text depending on its value.
Another code smell
Another thing I really don't like is the fact that I have to build a controller on the parent class, but I'm not actually using it on the parent class (I'm just exploiting it so I can give it to the children).
I'm new to animations in Flutter so I'm kinda confused on how I should orchestrate the whole thing here.
Any help will be appreciated / upvoted / accepted. Thank you!
As far as I understood you in a right way you just need set sizes for Row inside of SizeTransition instead of Container sizes
Here is your modified sample https://dartpad.dev/?id=a2408d29a1e8c6ce7a1cef8f21e7491d
I'd try an OverflowBox or a FittedBox (wrapping your text), depending on the result you want to achieve.

Scrollbar + any scroll widget bug on scrolling in web

I need to use Scrollbar widget for web as it enables scrollbar always on AND the ability to edit its size and width. I also have to use it with a child that is scrollable (singlechildescrollview, listview, etc), but after updating to flutter 2.2, I've seen that 2 scrollbars appear on screen and keeps buging the experience (can be seen when changing the size of the scrollbar in the parent).
I've tryed to disable the scrolling in the child, but its scrollbar still shows. I cant use the default scrollbar in the child, as its more geared towards mobile.
Fixed using rawascrollbar. It removes any padding when pressing on the side of the screen, and gives the ability to change the color of scrollbar (that way hides the child scroll). Better then the Scrollbar widget.

Scaffold instead of Container

Scaffold occupies the available space to it, and sometimes Container can be replaced with Scaffold.
By using Scaffold instead of Container gives any performance issue ?
There's no performance issue here.
Scaffold is used as a root of a screen to get access to setting Appbar, FloatingActionButton, BottomNavigationBar, showing Snackbar, etc.
Whereas a Container is just a simple... well a Container where you can define custom shape & constraints.
Also, a Continer won't always take up entire space, for that you can either use Expanded or a Spacer widget.
Scaffold will take whole screen space as it is meant to be used as a root of a widget screen.
A Scaffold should not be used instead of a Container unless you want to explicitly use Scaffold's properties.

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.

How to disable animation at the edges of PageView?

I want users to scroll between pages in PageView, but I don't want to show them an animation when they try to scroll before first and after last page. I can switch between colorful animation, black animation and no scrolling, but I could not find any possibility to disable the animation at all.
If there is no such possibility, how can I change the color of that animation or make it transparent at least?
Based on your screenshot, I can say that you are using BouncingScrollPhysics for your PageView. This behavior is commonly used by iOS devices. Nonetheless, I have also reviewed the entire source code you have provided here.
What went wrong
You have added PageView without accompanying it with a Scaffold or Material widget at the top level that's why the background behind the children of the PageView is color black.
https://dartpad.dev/c709e410d0a68248ac5b387b3bc6af93
From the documentation:
Scaffold implements the basic material design visual layout structure.
Without this widget, you'll notice that your app may occupy the entire screen of your device, including the notification bar, because it (PageView) does not know where is the status bar is located in the screen.
What you can do
I noticed that all of the children added inside the PageView has individual Scaffold and AppBar, it's not really necessary to nest scaffolds and you may want to use TabBarView instead of PageView, and let the parent widget handle the AppBar changes via TabController.
But if you think it'll cost you too much effort to refactor, feel free to review the following options that require minimal changes which will suit your needs:
Option 1. You can wrap your widget inside a Scaffold widget.
https://dartpad.dev/4620ff91444353f5e000d2063594bd96
Option 2. Given that nesting Scaffold widgets is not a good practice, you can just use the plain Material widget to wrap your PageView with children wrapped with Scaffold widget.
https://dartpad.dev/43f8730e5592ce1f96193fc01f08a29c
These solutions will change the background color of the PageView from black to white.
Option 3. If you really want to get rid of the animation, the easiest way to hack it is changing your scroll physics:
physics: ClampingScrollPhysics(),
However, this still has a glowing or ripple effect when you try to swipe at the end of the screen.
To further get rid of this effect, I'll share with you these SO answers:
How to remove scroll glow? (works for Android)
How to remove overscroll on ios? (works for iOS)
Further reading
https://api.flutter.dev/flutter/widgets/ScrollPhysics-class.html
https://medium.com/flutter-community/custom-scroll-physics-in-flutter-3224dd9e9b41