Visibility widget not displayed in Flutter - flutter

If we have a Visibility widget on top of our screen and we click to display it at the end of our screen scrolling top manually, why still this hidden? Does this mean that we need to do something like this instead?:
showWidget == true ? Text("hi") : Container();
Because code above is failing as well.
Video of the error:
https://youtu.be/YQ7nZ3LAENo

Related

Dart/Flutter: resize widget on button click

I want to implement a dashboard that has 2 widgets: a menu panel and a panel where information is displayed.
I also want that if you click the top left button, the panel would collapse and the information panel would be 100% of the screen's width.
How can I resize a widget on button click?
Wrap you sidebar with an AnimatedContainer. Then, set the width property on that container to width: isExpanded ? 200 : 0, where isExpanded is a bool that specifies whether or not the sidebar should be expanded, and 200 is the width that you want the sidebar to be when expanded.
To toggle the sidebar to be expanded or not, simply call this:
setState(() { isExpanded = !isExpanded; });

How to make scrolling page continue even when tabBarView reaches the top? Flutter

The code I ran was the code that was given by Griffins here: How To Move The TabBarView in the Center to The Top of the Page?
Everything is the same as the code given by Griffins.
However, when the tabBar was scrolled to the top and locked there, the content under each widget stopped scrolling too.
I want the content of the widget page to continue scrolling to its end, even when the tabBar is locked at the top.
Even if pinned and floating of SliverPersistentHeader was declared false, all it does is just to make the tabBar scrolled up, the content of the tabBarView still ends at the similar position. This is occurring for both tabBarViews.
So I'm suspecting it has something to do with the sliverfillremaining taking up the remaining height. Is there a way to overcome this? and show all the content of the tabBar?
Solved.
I changed the SliverFillRemaining to
SliverToBoxAdapter(
child: AnimatedBuilder(
animation: tabController.animation,
builder: (ctx, child) {
if (tabController.index == 0) {
return Page1();
} else
return Page2();
}),
)

How to get present number of inserts/widgets in an overlay?

I have created flat buttons that hide or show widget by inserting and removing widget in overlay.
And if I keep pressing the hide button even after there are no more widgets left in overlay, I get
'_overlay != null': is not true.
Now, I wish to add a check in there but I didn't find any way to check present number of widgets in Overlay stack.
Any help?
void showOverlayEntry() {
createOverlayEntry();
Overlay.of(context).insert(overlayEntry);
}
void removeOverlayEntry() {
//wish to add a check here if there are no more inserts left to remove
overlayEntry.remove();
}

How switch from GridView to ListView on click of a button in flutter?

I am building a wallpaper app and want to implement a feature of switching views, like switching from GridView to ListView on the press of an IconButton in FLutter
would look something like this:
The only way I could think of implementing this feature is by changing the crossAxisCount value in the GridView.count() method by hooking up a counter to the crossAxisCount property and controlling it through a function on click of an IconButton, this works but I have to Hot Reload my application every time the counter is incremented or decremented,
Any Suggestions or fix to this problem is welcomed.
You can simply use ternary operators and setState() to achieve what you want.
First, declare a boolean above your widget build. Then you can use ternary operators to change it from gridview to listview.
bool isGridView=true;
#override
Widget build(BuildContext context) {
Scaffold(
body: isGridView ? GridView.builder():ListView.builder(),
);
}
In your onPressed(), you can call setState():
setState(() {
isGridView=false;
});

How to resize body when BottomSheet expands

I would like the body of my scaffold to change size when the bottom sheet is expanded similar to how the Google Maps app responds when it's bottomsheet is pulled up (the map shrinks to about half the height of the screen).
body: _isSheetExpanded ? _buildBodySize1() : _buildBodySize2()
In your isExpanded() [or some similar method] for the bottom sheet in expanded state:
setState(){
_isSheetExpanded = true;
}
In the isCollapsed() method:
setState(){
_isSheetExpanded = false;
}