A powerful official extension library of Tab/TabBar/TabView, which support to scroll ancestor or child Tabs when current is overscroll, and set scroll direction and cache extent.

Overview

extended_tabs

pub package GitHub stars GitHub forks GitHub license GitHub issues flutter-candies

Language: English | 中文简体

A powerful official extension library of Tab/TabBar/TabView, which support to scroll ancestor or child Tabs when current is overscroll, and set scroll direction and cache extent.

Web demo for ExtendedTabs

Usage

dependencies:
  flutter:
    sdk: flutter
  extended_tabs: any

CarouselIndicator

Show tab indicator as Carousel style

   CarouselIndicator(
     controller: _controller,
     selectedColor: Colors.white,
     unselectedColor: Colors.grey,
     strokeCap: StrokeCap.round,
     indicatorPadding: const EdgeInsets.all(5),
   ),

ColorTabIndicator

Show tab indicator with color fill

    TabBar(
      indicator: ColorTabIndicator(Colors.blue),
      labelColor: Colors.black,
      tabs: [
        Tab(text: "Tab0"),
        Tab(text: "Tab1"),
      ],
      controller: tabController,
    )

Link

  /// if link is true and current tabbarview over scroll,
  /// it will check and scroll ancestor or child tabbarView.
  /// default is true
  final bool link;
  
  ExtendedTabBarView(
    children: <Widget>[
      List("Tab000"),
      List("Tab001"),
      List("Tab002"),
      List("Tab003"),
    ],
    controller: tabController2,
    link: true,
  )

ScrollDirection

  /// The axis along which the tab bar and tab view scrolls.
  ///
  /// Defaults to [Axis.horizontal].
  final Axis scrollDirection;

  Row(
    children: <Widget>[
      ExtendedTabBar(
        indicator: const ColorTabIndicator(Colors.blue),
        labelColor: Colors.black,
        scrollDirection: Axis.vertical,
        tabs: const <ExtendedTab>[
          ExtendedTab(
            text: 'Tab0',
            scrollDirection: Axis.vertical,
          ),
          ExtendedTab(
            text: 'Tab1',
            scrollDirection: Axis.vertical,
          ),
        ],
        controller: tabController,
      ),
      Expanded(
        child: ExtendedTabBarView(
          children: <Widget>[
            const ListWidget(
              'Tab1',
              scrollDirection: Axis.horizontal,
            ),
            const ListWidget(
              'Tab1',
              scrollDirection: Axis.horizontal,
            ),
          ],
          controller: tabController,
          scrollDirection: Axis.vertical,
        ),
      )
    ],
      )

CacheExtent

  /// cache page count
  /// default is 0.
  /// if cacheExtent is 1, it has two pages in cache
  final int cacheExtent;
  
  ExtendedTabBarView(
    children: <Widget>[
      List("Tab000"),
      List("Tab001"),
      List("Tab002"),
      List("Tab003"),
    ],
    controller: tabController2,
    linkWithAncestor: true,
    cacheExtent: 1,
  )  
Comments
  • Laggy swiping between tabs

    Laggy swiping between tabs

    I'm building a news app(wordpress as a backend) that has 15 tabs(categories) in ExtendedTabBarView and when I set cache_extent=15, swiping(sliding with finger) between tabs is very smooth but the scrolling is laggy(probably due to high memory usage because it has to preload and cache 15 tabs with 10 post per tab), BUT when I set cache_extent=2, app works fine but swiping between tabs is laggy at the end of animation(transition), while when I TAP on single tab transition between tabs is always smooth, both on cache_extent 2 and 15. What can be the issue with this, I'm not saying thats your plugin a problem, but I need help, I'm struggling with this whole week. :D :D

    If you need code sample or anything, just ask I will respond immediately. Keep up the good work. (:

    opened by aleksandar-radivojevic 19
  • 三级Tab,有出现第一级不能滚动切换到情况

    三级Tab,有出现第一级不能滚动切换到情况

    提供的Demo是三级Tab的,滚动切换是正常的,这是同一children仅有一个孩子有多个分页。 但是,当同一children的孩子同时有多个分页就会在最后位置卡住,滚动切换不到另一级页面。 不知道是不是真正存在这个问题?

    如下是正常的:

    1 TAB0
    1.1 - TAB00
     1.1.1 - - TAB000
     1.1.2 - - TAB001
    1.2 - TAB01
    2 TAB1
    

    如下是会卡住的:

    1 TAB0
    1.1 - TAB00
    1.1.1 - - TAB000
    1.1.2 - - TAB001
    1.2 - TAB01
    1.2.1 - - TAB010
    1.2.2 - - TAB011
    2 TAB1
    
    opened by CarrySniper 12
  • ExtendedTabBarView height problem?

    ExtendedTabBarView height problem?

    There is some existed issue in TabBarView about the height. see https://github.com/flutter/flutter/issues/55464, https://github.com/flutter/flutter/issues/54968. Can we fix this in ExtendedTabBarView?

    opened by liudonghua123 4
  • BouncingScrollPhysics not working

    BouncingScrollPhysics not working

    I'm trying to apply BouncingScrollPhysics when moving through the tabs but ClampingScrollPhysics is applied instead.

    flutter doctor -v [√] Flutter (Channel stable, 1.22.5, on Microsoft Windows [versão 10.0.19041.746], locale pt-BR) • Flutter version 1.22.5 at C:\src\flutter • Framework revision 7891006299 (6 weeks ago), 2020-12-10 11:54:40 -0800 • Engine revision ae90085a84 • Dart version 2.10.4

    [√] Android toolchain - develop for Android devices (Android SDK version 30.0.0-rc4) • Android SDK at C:\Users\HTCF\AppData\Local\Android\sdk • Platform android-30, build-tools 30.0.0-rc4 • ANDROID_HOME = C:\Users\HTCF\AppData\Local\Android\sdk • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01) • All Android licenses accepted.

    [√] Android Studio (version 4.0) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin version 47.1.2 • Dart plugin version 193.7361 • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

    [√] IntelliJ IDEA Community Edition (version 2019.3) • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.3.2 • Flutter plugin version 45.1.2 • Dart plugin version 193.7547

    [√] VS Code (version 1.52.1) • VS Code at C:\Users\HTCF\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.18.1

    [√] Connected device (1 available) • Moto G Play (mobile) • 0026091935 • android-arm • Android 7.1.1 (API 25)

    • No issues found!

    opened by hyungtaecf 3
  • 关于2.8.1的tab加了height属性这回事

    关于2.8.1的tab加了height属性这回事

      /// The height of the [Tab].
      ///
      /// If null, the height will be calculated based on the content of the [Tab].  When `icon` is not
      /// null along with `child` or `text`, the default height is 72.0 pixels. Without an `icon`, the
      /// height is 46.0 pixels.
      final double? height;
    

    看到就可以close了(手动狗头)

    opened by xxssd-awsl 2
  • Active Tab

    Active Tab

    Hello,

    I have 4 tabs in my module, i want to open a tab by default based on a user variable. If user is admin i want to open firstly on the last tab,...

    How can i do that?

    Thank you

    stack overflow 
    opened by acamenhas 2
  • ExtendedTabBarView嵌套ExtendedTabBarView联动滑动bug

    ExtendedTabBarView嵌套ExtendedTabBarView联动滑动bug

    在英语环境没问题,啊语环境有问题,看了一下源码,应该是_handleAncestorOrChild里面处理手势方向有问题,没有兼容啊语的手势方向 /// 这里的判断有问题 if ((delta < 0 && _position!.extentAfter == 0 && state!._position!.extentAfter != 0) || (delta > 0 && _position!.extentBefore == 0 && state!._position!.extentBefore != 0))

    enhancement 
    opened by wtwsky 1
  • [BUG] indicator 在特定情况下绘制错误

    [BUG] indicator 在特定情况下绘制错误

    运行环境

    Flutter: 2.5.0 extended_tabs: 2.3.0

    问题描述

    主要的问题是 indicator 并没有按照指定的 indicatorSize 参数生效,还有 mainAxisAlignment 在不为 null 的情况下 indicator 也会有问题,详细看下方的测试部分。

    测试

    demo code
    import 'package:flutter/material.dart';
    
    import 'package:extended_tabs/extended_tabs.dart';
    
    class ExtendedTabPage extends StatefulWidget {
      const ExtendedTabPage({Key? key}) : super(key: key);
    
      @override
      State<ExtendedTabPage> createState() => _ExtendedTabPageState();
    }
    
    class _ExtendedTabPageState extends State<ExtendedTabPage> with SingleTickerProviderStateMixin {
    
      late TabController _tabController;
    
      @override
      void initState() {
        super.initState();
        _tabController = TabController(length: 3, vsync: this);
      }
    
      @override
      void dispose() {
        _tabController.dispose();
        super.dispose();
      }
    
      @override
      Widget build(BuildContext context) {
        // 测试参数
        var textDirection = TextDirection.ltr;
        var isScrollable = false;
        var labelPadding = EdgeInsets.symmetric(horizontal: 16);
        var indicatorSize = TabBarIndicatorSize.label;
        var mainAxisAlignment = null;
    
        // 固定参数
        final indicator = BoxDecoration(
          borderRadius: BorderRadius.circular(26),
          color: Colors.blue,
        );
        final labelColor = Colors.black;
        final unselectedLabelColor = Colors.black54;
        final labelStyle = TextStyle(fontSize: 14, fontWeight: FontWeight.bold);
        final unselectedLabelStyle = TextStyle(fontSize: 14);
    
        return Scaffold(
          appBar: AppBar(
            title: const Text('Extended Tab Page'),
          ),
          body: Directionality(
            textDirection: textDirection,
            child: Column(
              children: [
                TabBar(
                  controller: _tabController,
                  isScrollable: isScrollable,
                  labelPadding: labelPadding,
                  indicatorSize: indicatorSize,
                  indicator: indicator,
                  labelColor: labelColor,
                  unselectedLabelColor: unselectedLabelColor,
                  labelStyle: labelStyle,
                  unselectedLabelStyle: unselectedLabelStyle,
                  tabs: const [
                    Tab(text: 'F Tab 1'),
                    Tab(text: 'F Tab 2'),
                    Tab(text: 'F Tab 3'),
                  ],
                ),
                Container(height: 16, color: Colors.black12,),
                ExtendedTabBar(
                  controller: _tabController,
                  isScrollable: isScrollable,
                  labelPadding: labelPadding,
                  indicatorSize: indicatorSize,
                  indicator: indicator,
                  labelColor: labelColor,
                  unselectedLabelColor: unselectedLabelColor,
                  labelStyle: labelStyle,
                  unselectedLabelStyle: unselectedLabelStyle,
                  mainAxisAlignment: mainAxisAlignment,
                  tabs: const [
                    Tab(text: 'E Tab 1'),
                    Tab(text: 'E Tab 2'),
                    Tab(text: 'E Tab 3'),
                  ],
                ),
    
                Expanded(
                  child: ExtendedTabBarView(
                    controller: _tabController,
                    children: [
                      for (var i = 1; i <= 3; i++)
                        buildPage(i, textDirection, isScrollable, labelPadding, indicatorSize, mainAxisAlignment),
                    ],
                  ),
                ),
              ],
            ),
          ),
        );
      }
    
      Widget buildPage(
        int id,
        TextDirection textDirection,
        bool isScrollable,
        EdgeInsetsGeometry? labelPadding,
        TabBarIndicatorSize indicatorSize,
        MainAxisAlignment? mainAxisAlignment,
      ) {
        return Container(
          color: Colors.black12,
          alignment: Alignment.center,
          child: Text(
            'Page $id\n\n'
            'textDirection:               $textDirection\n'
            'labelPadding:               $labelPadding\n'
            'isScrollable:                 $isScrollable\n'
            'indicatorSize:              $indicatorSize\n'
            'mainAxisAlignment:   $mainAxisAlignment',
          ),
        );
      }
    }
    
    测试 上面的 `F Tab` 用的是flutter官方 `TabBar`, 下面的 `E Tab` 用的是 `ExtendedTabBar`

    除了参数mainAxisAlignment 只有 ExtendedTabBar 中有,其他参数一致

    用demo里的代码 两边tab效果一致 Screenshot_2022-05-26-18-10-59-935_com example flutter_test my_flutter_test

    indicatorSize 改为 TabBarIndicatorSize.tab E Tab 中的 indicator 并不是 tab 的尺寸而是 label 的尺寸 Screenshot_2022-05-26-18-11-15-575_com example flutter_test my_flutter_test

    indicatorSize 改为 TabBarIndicatorSize.tab mainAxisAlignment 改为 MainAxisAlignment.start E Tab 中的 indicator 前2个tab尺寸正常,但是最后一个tab的右边界有问题 Screenshot_2022-05-26-18-13-14-544_com example flutter_test my_flutter_test Screenshot_2022-05-26-18-13-16-102_com example flutter_test my_flutter_test

    indicatorSize 改为 TabBarIndicatorSize.label mainAxisAlignment 改为 MainAxisAlignment.start E Tab 中的 indicator 并不是 label 的尺寸而是 tab 的尺寸,最后一个tab也一样有问题 Screenshot_2022-05-26-18-14-00-325_com example flutter_test my_flutter_test Screenshot_2022-05-26-18-14-02-264_com example flutter_test my_flutter_test

    indicatorSize 改为 TabBarIndicatorSize.label mainAxisAlignment 改为 MainAxisAlignment.end E Tab 中的 indicator 并不是 label 的尺寸而是 tab 的尺寸,但是最后一个tab正常 Screenshot_2022-05-26-18-14-22-481_com example flutter_test my_flutter_test

    isScrollable 改为 true indicatorSize 改为 TabBarIndicatorSize.tab 同测试3 Screenshot_2022-05-26-18-14-57-644_com example flutter_test my_flutter_test

    isScrollable 改为 true labelPadding 改为 EdgeInsets.symmetric(horizontal: 8) indicatorSize 改为 TabBarIndicatorSize.tab mainAxisAlignment 改为 MainAxisAlignment.center 和测试3的问题一样 Screenshot_2022-05-26-18-20-12-607_com example flutter_test my_flutter_test

    isScrollable 改为 true labelPadding 改为 EdgeInsets.symmetric(horizontal: 32) indicatorSize 改为 TabBarIndicatorSize.tab mainAxisAlignment 改为 MainAxisAlignment.center 同上 Screenshot_2022-05-26-18-21-03-748_com example flutter_test my_flutter_test Screenshot_2022-05-26-18-20-59-105_com example flutter_test my_flutter_test

    textDirection 改为 TextDirection.rtl indicatorSize 改为 TabBarIndicatorSize.tab mainAxisAlignment 改为 MainAxisAlignment.end 同测试3 Screenshot_2022-05-26-18-23-05-093_com example flutter_test my_flutter_test

    垂直滚动暂时还没有时间测,不知道有没有问题。

    其他

    问题应该是出在 _IndicatorPainter 里的 indicatorRect方法,看起来是为了适配 mainAxisAlignment,看 mainAxisAlignment 的注释,应该只会影响 isScrollable = false 时的样式,但是在上述的一些情况下会造成负面效果。

    bug 
    opened by shenjingfs 1
  • tab切换,生命周期

    tab切换,生命周期

    当存在有tab0,tab1,tab2,tab3,四个tab时: 从tab0->tab3时,调用为: tab3.initState tab0.dispose 然后从tab3->tab1时,调用为: tab2.initState tab2.dispose tab1.initState tab3.dispose 这里有办法不然他调用到tab2的initState和dispose方法吗?

    opened by sanjin123 1
  • Error when cacheExtent set to null

    Error when cacheExtent set to null

    By set cacheExtent to null, the error occurred when swiping between tab.

    ════════ Exception caught by rendering library ═════════════════════════════════════════════════════
    The following NoSuchMethodError was thrown during performLayout():
    The method '_greaterThanFromInteger' was called on null.
    Receiver: null
    Tried calling: _greaterThanFromInteger(2)
    
    User-created ancestor of the error-causing widget was: 
      ExtendedTabBarView file:///Users/alex/Documents/OpenJMU/lib/pages/home/AppsPage.dart:203:20
    When the exception was thrown, this was the stack: 
    #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
    #1      int.> (dart:core-patch/integers.dart:101:18)
    #2      RenderSliverFixedExtentBoxAdaptor._calculateTrailingGarbage (package:flutter/src/rendering/sliver_fixed_extent_list.dart:158:45)
    #3      RenderSliverFixedExtentBoxAdaptor.performLayout (package:flutter/src/rendering/sliver_fixed_extent_list.dart:189:35)
    #4      RenderObject.layout (package:flutter/src/rendering/object.dart:1701:7)
    
    opened by AlexV525 1
  • Calling null when set cacheExtent to null.

    Calling null when set cacheExtent to null.

    As cacheExtent provide null setter to make all pages cached, the code didn't handle null properly, as the code goes: https://github.com/fluttercandies/extended_tabs/blob/2be7c5212b14222daf3ab3af72b132287c916b82/lib/src/page_view.dart#L222 null value will failed at here and the code will never goes to else. But after added widget.cacheExtent != null, it will goes wrong with Infinity or NaN toInt with the value set to double.infinity, so it needs some further handle.

    good first issue 
    opened by AlexV525 0
Owner
FlutterCandies
Custom Flutter candies (packages) for you to build your Flutter app easily. Enjoy it!
FlutterCandies
Flutter Navigation - all types of navigation in flutter run main.tabBar.dart to see tabBar, and run main.dart to see the otheres

pop_up_bar A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if th

Michael Odumosu 0 Jan 1, 2022
Add beautiful and trending tab indicators directly to your default Flutter TabBar

Add beautiful and trending tab indicators directly to your default Flutter TabBar. Features ?? Supports Android, iOS, Web Can be directly added to the

Adar 51 Dec 23, 2022
A most easily usable cache management library in Dart. With CacheStorage, you can easily manage cache on your application.

A most easily usable cache management library in Dart! 1. About 1.1. Introduction 1.1.1. Install Library 1.1.2. Import It 1.1.3. Use CacheStorage 1.2.

Kato Shinya 1 Dec 13, 2021
Memory Cache is simple, fast and global in-memory cache with CRUD features.

Memory Cache Memory Cache is simple, fast and global in-memory cache. Features Create, read, update, delete and invalidate cache. Expirable Cache Gett

Gökberk Bardakçı 6 Dec 25, 2022
⚡ Cache Manager A tidy utility to handle cache of your flutter app like a Boss.

⚡ Cache Manager A tidy utility to handle cache of your flutter app like a Boss. It provides support for both iOS and Android platforms (offcourse). ??

Abhishek Chavhan 10 Oct 25, 2022
Declaratively switch child widgets based on the current `Router` location.

Features Declaratively switch child widgets based on the current Router location. class SideBar extends StatelessWidget { Widget build(_){ re

gskinner team 7 Dec 12, 2022
A Fluter tabview that text color can change with animation and bg color change with animation

float_tab A Fluter tabview that text color can change with animation and bg color change with animation Getting Started This project is a starting poi

ventureli 1 Dec 8, 2021
The application contains the Noble Qur’an, Qur’an radio stations, morning and evening remembrances, and some supplications that a Muslim needs in his life, as well as prayer times, the direction of the qiblah, and the Forty-Nawawi book

The application contains the Noble Qur’an, Qur’an radio stations, morning and evening remembrances, and some supplications that a Muslim needs in his life, as well as prayer times, the direction of the qiblah, and the Forty-Nawawi book

Mohamed Ayad 14 Dec 15, 2022
A Flutter widget for Scrollview, pop when overscroll

overscroll_pop A Flutter widget for Scrollview, pop when overscroll like Instagram, Pinterest, ... Getting Started Include the package to your project

null 22 Dec 21, 2022
A font loader to download, cache and load web fonts in flutter with support for Firebase Cloud Storage.

Dynamic Cached Fonts A simple, easy to use yet customizable font loader to use web fonts. Demo: https://sidrao2006.github.io/dynamic_cached_fonts ?? I

Aneesh Rao 18 Dec 21, 2022
An extension to the bloc state management library which automatically persists and restores bloc states.

⚠️ Attention: This repository has been moved to https://github.com/felangel/bloc and is now read-only! An extension to the bloc state management libra

Felix Angelov 189 Nov 17, 2022
An extension to the bloc state management library which lets you create State Machine using a declarative API

An extension to the bloc state management library which lets you create State Machine using a declarative API

null 25 Nov 28, 2022
Library to create custom Toggle / Tab on your apps

Flutter Tab Toggle A Beautiful and Simple Tab/Toggle switch widget. It can be fully customized with desired icons, width, colors, text, corner radius

Mudassir 11 Sep 6, 2022
A customizable carousel slider widget in Flutter which supports inifinte scrolling, auto scrolling, custom child widget, custom animations and built-in indicators.

flutter_carousel_widget A customizable carousel slider widget in Flutter. Features Infinite Scroll Custom Child Widget Auto Play Horizontal and Vertic

NIKHIL RAJPUT 7 Nov 26, 2022
A flutter widget which renders its child outside the original widget hierarchy.

overlay_container A flutter widget which renders its child outside the original widget hierarchy. Demo. This demo is present as an example here. You c

Mustansir Zia 30 Jun 10, 2022
FLUTTER API: It's powerful navigation by gestures and taps. You can scroll from left to right or tap on the navigation icons.

scroll_navigation My other APIs Video Viewer Video Editor Helpers Features Fancy animations. Customizable colors. Works with the back button. Scrollin

Luis Felipe Murguia Ramos 14 Jun 14, 2022
Tabbed sliverlist - A simple flutter plugin to setup sliverlist with TabBar with minimal code.

tabbed_sliverlist A package to simplify initialization of TabBar with ListView builder implemented using sliverappbar and sliverlist. Scroll position

Akshay A S 1 Jan 3, 2022
Flashy_tab_bar - One another nice animated tabbar

One another nice animated tabbar (Inspired by Cuberto) Getting Started Add the dependency at pubspec.yaml:

TheBrio 9 Nov 16, 2022
Nimbostratus is a reactive data-fetching and client-side cache management library built on top of Cloud Firestore.

Nimbostratus ?? Nimbostratus is a reactive data-fetching and client-side cache management library built on top of Cloud Firestore. The Cloud Firestore

Dan Reynolds 13 Dec 15, 2022