Unverified Commit 802ba9ac authored by Ayush Bherwani's avatar Ayush Bherwani Committed by GitHub

adds interactive example (#59251)

parent 222c2cb0
......@@ -85,6 +85,59 @@ import 'constants.dart';
/// }
/// ```
/// {@end-tool}
///
/// {@tool dartpad --template=stateless_widget_material}
///
/// This example shows how to listen to page updates in [TabBar] and [TabBarView]
/// when using [DefaultTabController].
///
/// ```dart preamble
/// final List<Tab> tabs = <Tab>[
/// Tab(text: 'Zeroth'),
/// Tab(text: 'First'),
/// Tab(text: 'Second'),
/// ];
/// ```
///
/// ```dart
/// Widget build(BuildContext context) {
/// return DefaultTabController(
/// length: tabs.length,
/// // The Builder widget is used to have a different BuildContext to access
/// // closest DefaultTabController.
/// child: Builder(
/// builder: (BuildContext context) {
/// final TabController tabController = DefaultTabController.of(context);
/// tabController.addListener(() {
/// if (!tabController.indexIsChanging) {
/// // Your code goes here.
/// // To get index of current tab use tabController.index
/// }
/// });
/// return Scaffold(
/// appBar: AppBar(
/// bottom: TabBar(
/// tabs: tabs,
/// ),
/// ),
/// body: TabBarView(
/// children: tabs.map((Tab tab){
/// return Center(
/// child: Text(
/// tab.text + ' Tab',
/// style: Theme.of(context).textTheme.headline5,
/// ),
/// );
/// }).toList(),
/// ),
/// );
/// }
/// ),
/// );
/// }
/// ```
/// {@end-tool}
///
class TabController extends ChangeNotifier {
/// Creates an object that manages the state required by [TabBar] and a
/// [TabBarView].
......
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