Flutter Exception: ScrollController attached to multiple scroll views

If on your case, you have many ListViews on a same views, you will get this error too. And to solve it you just need to add the following property into each listView builder: controller: ScrollController(), After you will have : ListView.builder( controller: ScrollController(),//just add this line itemCount: items.length, itemBuilder: (context, index) { return ListTile( … Read more

Flutter How to check if Sliver AppBar is expanded or collapsed?

You can use LayoutBuilder to get sliver AppBar biggest height. When biggest.height = MediaQuery.of(context).padding.top + kToolbarHeight, it actually means sliver appbar is collapsed. Here is a full example, in this example MediaQuery.of(context).padding.top + kToolbarHeight = 80.0: import ‘package:flutter/material.dart’; void main() => runApp(MaterialApp( home: MyApp(), )); class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); … Read more

Differences between SliverList vs ListView in Flutter

There’s almost no difference. ListView is a SliverList. Same with GridView, which is a SliverGrid. They are doing exactly the same thing. The only difference between them is that SliverList is a sliver, not a widget. Which means it’s used inside a ScrollView, usually CustomScrollView. ListView is nothing else but a biding of SliverList to … Read more

Horizontally scrollable cards with Snap effect in flutter

Use PageView and ListView: import ‘package:flutter/material.dart’; main() => runApp(MaterialApp(home: MyHomePage())); class MyHomePage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(‘Carousel in vertical scrollable’), ), body: ListView.builder( padding: EdgeInsets.symmetric(vertical: 16.0), itemBuilder: (BuildContext context, int index) { if(index % 2 == 0) { return _buildCarousel(context, index ~/ 2); } else { … Read more