Flutter SnackBar leaves an invisible padding in the Scaffold - flutter

I am showing a log in button in a page. Once the user has logged in, the SnackBar will display "Logged In with Google" for example. While the SnackBar is still showing, the body of the Scaffold is being build to a new page, the one accessible by logged in users. However, building the page while the Snackbar is still showing somehow leaves a padding in the Scaffold, in the area used by the SnackBar, so the underlying Scaffold body is still visible, yet you cannot interact with it. If there is a button at the bottom of that body, the button is not tapped because the invisible padding left behind by the (already closed) SnackBar blocks the content underneath.
What am I missing? Is there another way to produce the desired result?

I wrapped the Scaffold with a ScaffoldMessenger in every page and now seems to work. I will elaborate on the answer later on.

Related

Screenshot Controller flutter - capture method returns a null Uint8List when record is added

On the home screen on my app :
I have a list view with a bunch of card widgets and a screenshot action associated with each card widget. When I click on the screenshot action it captures the screenshot of that widget as it’s supposed to.
I have a floating action button which when clicked takes me to an add screen where I add data and save it to the database. Once saved a snackbar message is displayed and screen is popped out. The list view now displays the new record as a card widget.
PROBLEM :
After adding the record, when I click the screenshot action no widget screenshot is captured and on debugging I noticed the “Uint8List? image” is null.
Now if I scroll the list view and perform the screenshot action again everything seems to work.
It sounds to me that this might be a widget tree rebuild issue, but I am not sure how to go about with it. I have other actions, edit and delete on the card widget and they work without any issue.
Package used: screenshot 1.2.3

I want to make a container under app bar which works like a secondary App Bar where I can put my back icon button and title in the center in flutter

I have tried everything. But I can't find a permanent solution How to put the title in the center while my back icon button on the left side. I want to use this secondary app bar on every screen of my app.
Please check the image below for a better understanding.
This is the problem that I am facing
Take a ListView Widget at body of Scaffold and in its children put first widget as a ListTile that comes under AppBar. So that there will be a leading icon and title in center. After that take a Column and add your needed widgets for every page.

Show Global SnackBar regardless of page

I am trying to show a SnackBar that appears regardless of where in the app I am. I did set up and GlobalKey on my root Scaffold, and I am able to call it to show a snackbar from anywhere in my code BUT since I am inside other Scaffolds, it does not show on these pages. The only way to view it is to pop the routes and go back to the main screen, where the root Scaffold is.
Is there any way I could show a SnackBar that's above every single widget?
This I am trying to do to be able to show a message for notifications received when the app is in foreground

How to route to page, without removing BottomNavigationBar in flutter?

I'm creating my first app in flutter, and i'm having issues with state management. I have a MainPage.dart with BottomNavigationBar, and body: with tabPages[MainTab, ...]. In the MainTab i have a ListView, and when i click ListView item, it should open details, however BottomNavigationBar shouldn't be removed.
Below i have a design.(I'm using Scoped Model).
I tried these solutions
https://gist.github.com/HansMuller/0e76c54b1f2d4423efbdc2c185e761ef and How to route to page, without removing BottomNavigationBar in flutter?
But in those cases, i can't route to page without bottom navigation. When i click on FLoatingActionButton: it should open new page without bottom navigation (BottomNavigationBar stay always at the bottom, even if i don't want it)
https://medium.com/#daniyargilimov/lutter-bottomnavigationbar-with-multiple-navigators-725ff013489c
here is the working example...

Flutter overlay is moving

I'm asking how to disable Overlays to move when a Scaffold.of(context).showSnackBar is called like on my video below.
The same thing is happening when the keyboard appear. Sometime the blue floattingButton (+) don't come back to it's original position :-(
Thx in advance.
Problem animation
The FloatingActionButton going up when the Scaffold is displayed is something common to all default implementations.
Give a look to the "Bootom app bar" demo in the Gallery app. Press on the search button and you will see it coming up. Or just add a Scaffold to the app that is built with flutter create command.
This happens because of the way the FAB button is placed on the screen and the effect of displaying the Snackbar by the Scaffold.
The FAB button is displayed at the bottom of the content area of the Scaffold content. When the content area is shrinked to include the BottomAppBar, the FAB goes up with it. It has nothing to do with Overlay.
You have two options:
Either you create your own versión of the FAB which is not
controlled by the Scaffold.
Or you hack the Scaffold so the size of the SnackBar is not taken
into account.
For this second option you can try the following:
Go to the file /lib/src/material/scaffold.dart in your flutter installation and look for the line with the code snackBarSize: snackBarSize, inside the _ScaffoldLayout class.
Replace it with snackBarSize: Size(0.0, 0.0),
You will see that the FAB stays in its place.