Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between NestedScrollView and CustomScrollView?

Tags:

I having hard to understand the difference between NestedScrollView and CustomScrollView?

like image 585
Sagar Bahadur Tamang Avatar asked Nov 18 '18 14:11

Sagar Bahadur Tamang


People also ask

What is NestedScrollView?

NestedScrollView is just like ScrollView , but it supports acting as both a nested scrolling parent and child on both new and old versions of Android. Nested scrolling is enabled by default.

When should I use CustomScrollView?

A CustomScrollView lets you supply slivers directly to create various scrolling effects, such as lists, grids, and expanding headers. For example, to create a scroll view that contains an expanding app bar followed by a list and a grid, use a list of three slivers: SliverAppBar, SliverList, and SliverGrid.

What is NestedScrollView in flutter?

A scrolling view inside of which can be nested other scrolling views, with their scroll positions being intrinsically linked.

How do you use custom scroll view in flutter?

Now lets start implementation of CustomScrollView in Flutter First of all, create a basic project and return a Custom Scroll View widget. Then, add a silver app bar and then add a silver grid. Here we only used two child widgets in the custom scroll view. The Entry point of code.


1 Answers

CustomScrollView - is the most customizable way to build any "scroll" based layouts using Sliver objects. SingleChildScrollView and NestedScrollView are both build on top of it.

NestedScrollView - is a Wiget provided for a very particular use-case - to put One Scrollable object inside another (in most case - where the directions are not same).

This is what is mentioned in the doc for NestedScrollView

A scrolling view inside of which can be nested other scrolling views, with their scroll positions being intrinsically linked.

The beauty of flutter is that it is open source, you can check the source code to know what is going on under the hood.

Souce Code:

  • CustomScrollView
  • NestedScrollView
like image 52
Harsh Bhikadia Avatar answered Sep 20 '22 01:09

Harsh Bhikadia