Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tab Animation Sample Video #32177

Merged
merged 13 commits into from May 13, 2019
28 changes: 23 additions & 5 deletions packages/flutter/lib/src/material/tab_controller.dart
Expand Up @@ -21,6 +21,8 @@ import 'constants.dart';
/// ancestor, a [TabController] can be shared by providing a
/// [DefaultTabController] inherited widget.
///
/// {@animation 700 540 https://flutter.github.io/assets-for-api-docs/assets/material/tabs.mp4}
///
/// {@tool sample}
///
/// This widget introduces a [Scaffold] with an [AppBar] and a [TabBar].
Expand Down Expand Up @@ -64,7 +66,13 @@ import 'constants.dart';
/// body: TabBarView(
/// controller: _tabController,
/// children: myTabs.map((Tab tab) {
/// return Center(child: Text(tab.text));
/// final String label = tab.text.toLowerCase();
/// return Center(
/// child: Text(
/// 'This is the $label tab',
/// style: const TextStyle(fontSize: 36),
/// ),
/// );
/// }).toList(),
/// ),
/// );
Expand All @@ -76,7 +84,7 @@ class TabController extends ChangeNotifier {
/// Creates an object that manages the state required by [TabBar] and a
/// [TabBarView].
///
/// The [length] must not be null or negative. Typically its a value greater
/// The [length] must not be null or negative. Typically it's a value greater
/// than one, i.e. typically there are two or more tabs. The [length] must
/// match [TabBar.tabs]'s and [TabBarView.children]'s length.
///
Expand Down Expand Up @@ -135,8 +143,10 @@ class TabController extends ChangeNotifier {
Animation<double> get animation => _animationController?.view ?? kAlwaysCompleteAnimation;
final AnimationController _animationController;

/// The total number of tabs. Typically greater than one. Must match
/// [TabBar.tabs]'s and [TabBarView.children]'s length.
/// The total number of tabs.
///
/// Typically greater than one. Must match [TabBar.tabs]'s and
/// [TabBarView.children]'s length.
final int length;

void _changeIndex(int value, { Duration duration, Curve curve }) {
Expand Down Expand Up @@ -251,6 +261,8 @@ class _TabControllerScope extends InheritedWidget {
/// widgets are created by a stateless parent widget or by different parent
/// widgets.
///
/// {@animation 700 540 https://flutter.github.io/assets-for-api-docs/assets/material/tabs.mp4}
///
/// ```dart
/// class MyDemo extends StatelessWidget {
/// final List<Tab> myTabs = <Tab>[
Expand All @@ -270,7 +282,13 @@ class _TabControllerScope extends InheritedWidget {
/// ),
/// body: TabBarView(
/// children: myTabs.map((Tab tab) {
/// return Center(child: Text(tab.text));
/// final String label = tab.text.toLowerCase();
/// return Center(
/// child: Text(
/// 'This is the $label tab',
/// style: const TextStyle(fontSize: 36),
/// ),
/// );
/// }).toList(),
/// ),
/// ),
Expand Down
4 changes: 3 additions & 1 deletion packages/flutter/lib/src/material/tabs.dart
Expand Up @@ -1097,7 +1097,9 @@ class TabBarView extends StatefulWidget {
/// will be used.
final TabController controller;

/// One widget per tab. Its length must match the length of the [TabBar.tabs]
/// One widget per tab.
///
/// Its length must match the length of the [TabBar.tabs]
/// list, as well as the [controller]'s [TabController.length].
final List<Widget> children;

Expand Down