Flutter, in nested scrollview (consisting of header and tabview ) the scrolling should not happen if the tabview has less or no data - flutter

I have a header widget and then a tab view. I have been able to make them scroll as one using a nestedscrollview. But I want the scrolling to not happen if tab view data is not present.

Disable scroll if total child length < scroll height:
NestedScrollView(
physics: (sumHeight>scrollHeight) ? AlwaysScrollableScrollPhysics() : NeverScrollableScrollPhysics()
)

Related

How can I add pages to a flutter listview builder?

Instead of infinite scrolling in a Listview.builder.
I want to be able to see x amount of items in my ListView and then going on to the next page should show the next x amount of items.
What I have so far is just a standard ListView.builder:
Listview.Builder(
itemCount: data.length
itemBuilder:(context, index){
return Card(
child: ListTile(
title: data[index]
)
);
}
)
You can use a PageController to control which page is visible in the view. In addition to being able to control the pixel offset of the content inside the PageView, a PageController also lets you control the offset in terms of pages, which are increments of the viewport size.
The PageController can also be used to control the PageController.initialPage, which determines which page is shown when the PageView is first constructed, and the PageController.viewportFraction, which determines the size of the pages as a fraction of the viewport size.
Refer to :
geeksforgeeks
Flutter Docs
Hope this helps. Happy Coding :)

Flutter: I need to make the widgets scrollable so that whenever i'm scrolling with list view they will follow

I have 2 rows in my screen, the first row is consist of dropdown button and elevation button and the second row is where the stream builder located, I used flexible so that the stream builder is scrollable. What I want is every time I scroll the stream builder I want the first row to follow the scroll not stay in the screen.
This is how my widget set:
Scaffold
-Column
-Row
-Dropdown button
-Elevated buton
-Flexible
-Streambuilder
-stack
-listview
Just like in facebook everytime you scroll down the "what's in your mind" controller disappers too, not floating like an app bar
Inside Listview add physics: NeverScrollableScrollPhysics()
//
Listview(
physics: NeverScrollableScrollPhysics(),
return .....;
)
//
Follow this pattern.
If you want that widget to disappear when you scroll, you need to wrap your Column in a SingleChildScrollView which you will need to wrap in a Flxible
Code:
Flexible(
child: SingleChildScrollView(
child: Column(
//your normal code insode Column
Depending on your code, you may also need to make the ListView not scroll (as suggested by Rafid):
Listview( physics: NeverScrollableScrollPhysics()

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 can I disable scroll in GridView?

I have a GridView whose parent is ListView. How can I disable scroll in GridView so users can scroll the ListView?
I can't find any attribute in GridView to disable scroll even the content is fully rendered.
I think you can disable it by setting primary property as below:
GridView.count(
shrinkWrap: true,
primary: true,
children: <Widget>[],
// ...
)
Or if you want to disable it entirely:
hysics: new NeverScrollableScrollPhysics()

How to remove Scrollbar from a widgets scrolling children

I have a ScrollBar surrounding a CupertinoPageScaffold child Widget.
Inside this contains a few horizontal scrolling ListViews which should not show scrollbars but due the parent ScrollBar being present, every scrolling widget below has a scroll bar attached to it.
Is there a Widget to wrap scrolling Widgets that removes the scrollbar?
I've looked for Widgets that may be called NoScrollbar but these don't exist.
If I remove the parent ScrollBar then the scrollbars are removed
If you wrap the ListViews for which you don't want scroll bars for in a NotificationListener in the following manner:
NotificationListener<ScrollNotification>(
onNotification: (_) => true,
child: ListView(....)
)
I think those ListViews will not have scrollbars.
You can use ScrollConfiguration to hide the scrollbars.
ScrollConfiguration(
behavior: ScrollConfiguration.of(context).copyWith(scrollbars: false),
child: ListView(....)
)
You can use this with any scrollable widget.