union_tabs 1.0.0+4

  • Readme
  • Changelog
  • Example
  • Installing
  • 61

union_tabs #

Screenshot

A nested TabBarView overscroll event unites outer TabBarView scroll event

Getting Started #

1.Install

dependencies:
  union_tabs: ^1.0.0+3

2.Import

import 'package:union_tabs/union_tabs.dart';

3.Usage

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
          bottom: TabBar(
              controller: _controller,
              tabs: tabsText.map((it) => Tab(text: it)).toList()),
        ),
        body: UnionOuterTabBarView( /// outerTabBarView
          controller: _controller,
          children: _createTabContent(),
        ));
  }

  List<Widget> _createTabContent() {
    List<Widget> tabContent = List();
    tabContent.add(Center(child: Text(tabsText[0])));
    final child = Column(
      children: <Widget>[
        TabBar(
            labelColor: Colors.black,
            unselectedLabelColor: Colors.black45,
            controller: _childController,
            tabs: secondTabsText.map((it) => Tab(text: it)).toList()),
        Expanded(
          child: UnionInnerTabBarView( /// innerTabBarView
              controller: _childController,
              children:
                  secondTabsText.map((it) => Center(child: Text(it))).toList()),
        )
      ],
    );
    tabContent.add(child);
    tabContent.add(Center(child: Text(tabsText[2])));
    return tabContent;
  }

More detail see example: main.dart

1.0.0+4 #

  • fix nested TabBarView overscrolling then scroll reversely, the UI stuck.

1.0.0+3 #

  • add Demo Comments.

1.0.0+2 #

  • Clear flutter warnings.

1.0.0+1 #

  • A nested TabBarView overscroll event unites outer TabBarView scroll event.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:union_tabs/union_tabs.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

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

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

class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
  List<String> tabsText = ["一", "二", "三"];
  List<String> secondTabsText = ["one", "two", "three"];
  TabController _controller;
  TabController _childController;

  @override
  void initState() {
    _controller = TabController(length: tabsText.length, vsync: this);
    _childController =
        TabController(length: secondTabsText.length, vsync: this);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
          bottom: TabBar(
              controller: _controller,
              tabs: tabsText.map((it) => Tab(text: it)).toList()),
        ),

        /// outer tabTarView which receives  OverscrollNotification of inner tabBarView.
        body: UnionOuterTabBarView(
          controller: _controller,
          children: _createTabContent(),
        ));
  }

  List<Widget> _createTabContent() {
    List<Widget> tabContent = List();
    tabContent.add(Center(child: Text(tabsText[0])));
    final child = Column(
      children: <Widget>[
        TabBar(
            labelColor: Colors.black,
            unselectedLabelColor: Colors.black45,
            controller: _childController,
            tabs: secondTabsText.map((it) => Tab(text: it)).toList()),
        Expanded(
          /// convert inner tabBarView OverscrollNotification to UnionOverscrollNotification to notify outer tabBarView.
          child: UnionInnerTabBarView(
              controller: _childController,
              children:
                  secondTabsText.map((it) => Center(child: Text(it))).toList()),
        )
      ],
    );
    tabContent.add(child);
    tabContent.add(Center(child: Text(tabsText[2])));
    return tabContent;
  }

  @override
  void dispose() {
    _controller.dispose();
    _childController.dispose();
    super.dispose();
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  union_tabs: ^1.0.0+4

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:union_tabs/union_tabs.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
21
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
61
Learn more about scoring.

We analyzed this package on May 24, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.1
  • pana: 0.13.8-dev
  • Flutter: 1.17.0

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
cupertino_icons ^0.1.2 0.1.3
flutter 0.0.0
vector_math ^2.0.8 2.0.8
Transitive dependencies
collection 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
Dev dependencies
flutter_test