Sanjib Sinha posted: " Photo by Wilmer Martinez on Unsplash We've been discussing scrolling widgets in a series of articles. Today our topic revolves around Custom Scroll View. Before we use CustomScrollView, let's know what it is. The CustomScrollView is a ScrollVi"
We've been discussing scrolling widgets in a series of articles.
Today our topic revolves around Custom Scroll View.
Before we use CustomScrollView, let's know what it is. The CustomScrollView is a ScrollView that uses slivers. And the slivers create various scrolling effects.
How the slivers create various scrolling effects, we'll see in a minute.
Let's see the first screenshot.
If we check the code of this flutter app, we'll find that we've used AppBar and besides, we've also used SliverAppBar inside the CustomScrollViewslivers. As a result, when we press the plus button in the AppBar, the items are being added in the inner space and as we scroll down, the SliverAppBar shrinks.
The AppBar remains at its place and, SliverAppBar starts working as a collapsing toolbar.
Let's go through the code from the very beginning, so that we can understand how the CustomScrollView works.
We've used the latest Provider package to maintain our state and increment the item's index.
import 'package:flutter/foundation.dart'; class Counter with ChangeNotifier { int _count = 0; int get count => _count; void increment() { _count++; notifyListeners(); } }
Next, we've used Scaffold and through the body parameter we use a CustomScrollView.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.