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

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.

Related

How to make An AppBar with widget in app?

How can we make an Appbar like this which is auto adjustable ,can have this many widgets and items benwath it can be scrollable?
You Can use Sliver App Bar See many be

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

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

I want to add a buttombar to my application Contains only text flutter

I want to add a buttombar to my application Contains only just one text with background color .
I need it to write the copyright in my application, but I find just that I have to add At least a two-item
In the list,
I don't need this
Just i want to add a single one text with a background color
In your case you do not need a bottombar widget.
you can create a container with specific height and background color and center a text widget in the container.
If you are looking to add bottomNavigationBar with one item only you can just write your own widget in the bottom navigation bar like a Container and set a background of your choice and give it a child widget wrapped in an INKWELL or GESTUREDETECTOR and if it overlaps with the Phone's GUI you can wrap the inkwell with SAFEAREA 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.

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