Unverified Commit 9545c5d1 authored by Shi-Hao Hong's avatar Shi-Hao Hong Committed by GitHub

Tab Animation Sample Video (#32177)

* Improve tabs documentation regarding matching lengths

* Add Tabs animation to docs
parent c4d52712
...@@ -21,6 +21,8 @@ import 'constants.dart'; ...@@ -21,6 +21,8 @@ import 'constants.dart';
/// ancestor, a [TabController] can be shared by providing a /// ancestor, a [TabController] can be shared by providing a
/// [DefaultTabController] inherited widget. /// [DefaultTabController] inherited widget.
/// ///
/// {@animation 700 540 https://flutter.github.io/assets-for-api-docs/assets/material/tabs.mp4}
///
/// {@tool sample} /// {@tool sample}
/// ///
/// This widget introduces a [Scaffold] with an [AppBar] and a [TabBar]. /// This widget introduces a [Scaffold] with an [AppBar] and a [TabBar].
...@@ -64,7 +66,13 @@ import 'constants.dart'; ...@@ -64,7 +66,13 @@ import 'constants.dart';
/// body: TabBarView( /// body: TabBarView(
/// controller: _tabController, /// controller: _tabController,
/// children: myTabs.map((Tab tab) { /// 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(), /// }).toList(),
/// ), /// ),
/// ); /// );
...@@ -76,7 +84,7 @@ class TabController extends ChangeNotifier { ...@@ -76,7 +84,7 @@ class TabController extends ChangeNotifier {
/// Creates an object that manages the state required by [TabBar] and a /// Creates an object that manages the state required by [TabBar] and a
/// [TabBarView]. /// [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 /// than one, i.e. typically there are two or more tabs. The [length] must
/// match [TabBar.tabs]'s and [TabBarView.children]'s length. /// match [TabBar.tabs]'s and [TabBarView.children]'s length.
/// ///
...@@ -134,8 +142,10 @@ class TabController extends ChangeNotifier { ...@@ -134,8 +142,10 @@ class TabController extends ChangeNotifier {
Animation<double> get animation => _animationController?.view; Animation<double> get animation => _animationController?.view;
AnimationController _animationController; AnimationController _animationController;
/// The total number of tabs. Typically greater than one. Must match /// The total number of tabs.
/// [TabBar.tabs]'s and [TabBarView.children]'s length. ///
/// Typically greater than one. Must match [TabBar.tabs]'s and
/// [TabBarView.children]'s length.
final int length; final int length;
void _changeIndex(int value, { Duration duration, Curve curve }) { void _changeIndex(int value, { Duration duration, Curve curve }) {
...@@ -251,6 +261,8 @@ class _TabControllerScope extends InheritedWidget { ...@@ -251,6 +261,8 @@ class _TabControllerScope extends InheritedWidget {
/// widgets are created by a stateless parent widget or by different parent /// widgets are created by a stateless parent widget or by different parent
/// widgets. /// widgets.
/// ///
/// {@animation 700 540 https://flutter.github.io/assets-for-api-docs/assets/material/tabs.mp4}
///
/// ```dart /// ```dart
/// class MyDemo extends StatelessWidget { /// class MyDemo extends StatelessWidget {
/// final List<Tab> myTabs = <Tab>[ /// final List<Tab> myTabs = <Tab>[
...@@ -270,7 +282,13 @@ class _TabControllerScope extends InheritedWidget { ...@@ -270,7 +282,13 @@ class _TabControllerScope extends InheritedWidget {
/// ), /// ),
/// body: TabBarView( /// body: TabBarView(
/// children: myTabs.map((Tab tab) { /// 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(), /// }).toList(),
/// ), /// ),
/// ), /// ),
......
...@@ -1115,7 +1115,9 @@ class TabBarView extends StatefulWidget { ...@@ -1115,7 +1115,9 @@ class TabBarView extends StatefulWidget {
/// will be used. /// will be used.
final TabController controller; 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]. /// list, as well as the [controller]'s [TabController.length].
final List<Widget> children; final List<Widget> children;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment