length property

  1. @override
int get length
override

The total number of tabs.

Typically greater than one. Must match TabBar.tabs's and TabBarView.children's length.

Implementation

@override
int get length {
  ReactiveStatelessWidget.addToObs?.call(this);
  return _length;
}
  1. @override
set length (int l)
override

The number of tabs / pages. It can set dynamically

Example:

   // We start with 2 tabs
   final myInjectedTabPageView = RM.injectedTabPageView(length: 2);

  // Later on, we can extend or shrink the length of tab views.

  // Tab/page views are updated to display three views
  myInjectedTabPageView.length = 3

  // Tab/page views are updated to display one view
  myInjectedTabPageView.length = 1

Implementation

@override
set length(int l) {
  assert(l > 0);
  if (_length == l) {
    return;
  }
  _length = l;
  initialIndex = _page ?? index;
  if (initialIndex > l - 1) {
    initialIndex = l - 1;
  }
  if (_tabController != null) {
    _tabController!.index = initialIndex;
    _tabController!.dispose();
    _tabController = null;
    initializer();
  }
  index = initialIndex;
  snapValue = const SnapState<int>.none().copyToHasData(initialIndex);
  notify();
}