Customizable Flutter widget which syncronize ScrollView with PageView as tabs

Overview

scrollable_list_tab_scroller

Customizable Flutter widget which syncronize ScrollView with PageView as tabs.

Create a custom page view as tabs which synchronize with inner ScrollView. The page view follows the index of scroll view and vice-versa.

Demo

Installation

Add dependency for package on your pubspec.yaml:

dependencies:
    scrollable_list_tab_scroller: 
   

   

Usage

To use this widget we must first define how our tabs will look like.

ScrollableListTabScroller

Parameter Definition
int itemCount Quantity item that will be built.
IndexedWidgetBuilder itemBuilder Builder of list item.
IndexedActiveStatusWidgetBuilder tabBuilder Builder of tab with active status for customization.
HeaderBuilder? headerBuilder Optional header builder for costomization.
ItemScrollController? itemScrollController Optional controller for item list.
PageController? tabPageController Optional controller for tabs.
ItemPositionsListener? itemPositionsListener Optional listener of item list positions.
void Function(int)? tabChanged Optional listener of tab changes.
double minEdgeBeforeChangeTab Optional height percentage to change the index before the list item reaches the edge(default = 0).

Example

Text( data.keys.elementAt(index), style: !active ? null : TextStyle(fontWeight: FontWeight.bold, color: Colors.green), ), itemCount: data.length, itemBuilder: (BuildContext context, int index) => Column( children: [ Text( data.keys.elementAt(index), style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20), ), ...data.values .elementAt(index) .asMap() .map( (index, value) => MapEntry( index, ListTile( leading: Container( height: 40, width: 40, decoration: BoxDecoration( shape: BoxShape.circle, color: Colors.grey), alignment: Alignment.center, child: Text(index.toString()), ), title: Text(value), ), ), ) .values ], ), )); } } ">
import 'package:flutter/material.dart';
import 'package:scrollable_list_tab_scroller/scrollable_list_tab_scroller.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Scrollable List Tab Scroller',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Scrollable List Tab Scroller'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State
   
     {
  final data = {
    "Category A": [
      "Item 1 (A)",
      "Item 2 (A)",
      "Item 3 (A)",
      "Item 4 (A)",
    ],
    "Category B": [
      "Item 1 (B)",
      "Item 2 (B)",
    ],
    "Category C": [
      "Item 1 (C)",
      "Item 2 (C)",
      "Item 3 (C)",
      "Item 4 (C)",
      "Item 5 (C)",
    ],
    "Category D": [
      "Item 1 (D)",
      "Item 2 (D)",
      "Item 3 (D)",
      "Item 4 (D)",
      "Item 5 (D)",
      "Item 6 (D)",
      "Item 7 (D)",
      "Item 8 (D)",
      "Item 9 (D)",
    ],
  };

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        body: ScrollableListTabScroller(
          tabBuilder: (BuildContext context, int index, bool active) => Text(
            data.keys.elementAt(index),
            style: !active
                ? null
                : TextStyle(fontWeight: FontWeight.bold, color: Colors.green),
          ),
          itemCount: data.length,
          itemBuilder: (BuildContext context, int index) => Column(
            children: [
              Text(
                data.keys.elementAt(index),
                style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
              ),
              ...data.values
                  .elementAt(index)
                  .asMap()
                  .map(
                    (index, value) => MapEntry(
                      index,
                      ListTile(
                        leading: Container(
                          height: 40,
                          width: 40,
                          decoration: BoxDecoration(
                              shape: BoxShape.circle, color: Colors.grey),
                          alignment: Alignment.center,
                          child: Text(index.toString()),
                        ),
                        title: Text(value),
                      ),
                    ),
                  )
                  .values
            ],
          ),
        ));
  }
}

   

Limitations & Considerations

Tab scroller has a limitation, it is built with PageView, allowing less customization possibilities for tabs.

This widget is inspired in scrollable_list_tabview.

License

This project is licensed under the MIT license, additional knowledge about the license can be found here.

You might also like...

A Highly customizable Phone input Flutter widget that supports country code, validation and contact picker.

A Highly customizable Phone input Flutter widget that supports country code, validation and contact picker.

A Highly customizable Phone input Flutter widget that supports country code, validation and contact picker.

Jun 7, 2022

Widget to let the user search through a keyword string typed on a customizable keyboard in a single or multiple choices list presented as a dropdown in a dialog box or a menu.

Widget to let the user search through a keyword string typed on a customizable keyboard in a single or multiple choices list presented as a dropdown in a dialog box or a menu.

searchable_dropdown Widget to let the user search through a keyword string typed on a customizable keyboard in a single or multiple choices list prese

Sep 11, 2022

A highly customizable multiple selection widget with search functionality.

A highly customizable multiple selection widget with search functionality.

A highly customizable multiple selection widget with search functionality.

Dec 19, 2022

RFlutter Alert is super customizable and easy-to-use alert/popup dialogs for Flutter.

RFlutter Alert is super customizable and easy-to-use alert/popup dialogs for Flutter.

RFlutter Alert is super customizable and easy-to-use alert/popup dialogs for Flutter. You may create reusable alert styles or add buttons as much as you want with ease.

Jan 1, 2023

SKAlertDialog - A highly customizable, powerful and easy-to-use alert dialog for Flutter.

 SKAlertDialog - A highly customizable, powerful and easy-to-use alert dialog for Flutter.

SKAlertDialog A highly customizable, powerful and easy-to-use alert dialog for Flutter. GIF Screenshots SKAlertDialog Basic Alert Alert with buttons A

May 18, 2022

Sliding card is a highly customizable flutter package that will help you create beautiful Cards with a sliding animation effect.

Sliding Card Introduction Sliding card is a highly customizable flutter package that will help you create beautiful Cards with a sliding animation eff

Nov 4, 2022

Animated, highly customizable, open-source Flutter gauge indicator widgets

Animated, highly customizable, open-source Flutter gauge indicator widgets

Animated, highly customizable, open-source Flutter gauge indicator widgets. They use renderbox under the hood, thus ensuring high performance.

Jun 10, 2022

Customizable Material and Cupertino buttons with progress indicators and more

Customizable Material and Cupertino buttons with progress indicators and more

future_button Customizable Material and Cupertino buttons with progress indicators and more.

Oct 13, 2022

A customizable listview with A-Z side scrollbar to fast jump to the item of the selected character

A customizable listview with A-Z side scrollbar to fast jump to the item of the selected character

A customizable listview with A-Z side scrollbar to fast jump to the item of the selected character

Sep 21, 2022
Comments
  • Any way to implement this with SliverAppBar?

    Any way to implement this with SliverAppBar?

    Hi @railson-ferreira, looks like a great package thanks so much for your hard work. Do you have any ideas on the best way to implement this package with https://api.flutter.dev/flutter/material/SliverAppBar-class.html

    Many thanks.

    opened by Noteofman 0
Releases(v1.1.0)
Owner
Railson Ferreira de Souza
Railson Ferreira de Souza
Flutter pre-load PageView widget

PreloadPageView Like the name, this is the widget to support Pre-load function for PageView widget. For better user experience sometimes we need pre-l

Neil 106 Jan 6, 2023
Flutter ScrollView Observer - a library of widget that can be used to listen for child widgets those are being displayed in the scroll view

Flutter ScrollView Observer - a library of widget that can be used to listen for child widgets those are being displayed in the scroll view

林洵锋 67 Jan 6, 2023
Flutter | Snap physics for your scrollview

Snap Scroll Physics When building scrollable views, sometimes you would prefer that the scroll stopped at a given offset, or that it avoids to stop in

Jaime Blasco 46 Nov 21, 2022
A Flutter plugin to use Chrome Custom Tabs.

Flutter Custom Tabs Plugin With the Flutter Custom Tabs Plugin, you can use Custom Tabs as easily as url_launcher. This plugin is built as federated p

Shinya Kumagai 118 Nov 18, 2022
A vertical tabs package for flutter framework.

Vertical Tabs A vertical tabs package for flutter framework. Getting Started A simple example of usage. to get more examples see Examples directory. T

null 62 Dec 30, 2022
A dart package to display a horizontal bar of customisable toggle tabs. Supports iOS and Android.

toggle_bar A dart package to display a horizontal bar of customisable toggle tabs. Supports iOS and Android. Installation Depend on it. dependencies:

Prem Adithya 9 Jul 13, 2022
📸 Easy to use yet very customizable zoomable image widget for Flutter, Photo View provides a gesture sensitive zoomable widget.

?? Easy to use yet very customizable zoomable image widget for Flutter, Photo View provides a gesture sensitive zoomable widget. Photo View is largely used to show interacive images and other stuff such as SVG.

Blue Fire 1.7k Jan 7, 2023
Displays a highly customizable week view (or day view) which is able to display events, to be scrolled, to be zoomed-in & out and a lot more !

Displays a highly customizable week view (or day view) which is able to display events, to be scrolled, to be zoomed-in & out and a lot more !

Hugo Delaunay 196 Dec 2, 2022
Flutter reaction button plugin it is fully customizable widget such as Facebook reaction button

Flutter Reaction Button Flutter button reaction it is fully customizable widget such as Facebook reaction button. Preview Demo Usage Include 'flutter_

Abdelouahed Medjoudja 174 Dec 19, 2022
Flutter widget form select a date in horizontal timeline with customizable styles.

Flutter widget form select a date in horizontal timeline with customizable styles. Getting Started You can use this package when you need to add a dat

Jose Manuel Márquez 158 Dec 2, 2022