Created
December 16, 2021 12:39
-
-
Save Roaa94/5734f774a8ce028a4666b45946a7523b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
class TabBarDemo extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: DefaultTabController( | |
length: 2, | |
child: Scaffold( | |
appBar: AppBar( | |
title: const Text('TabBar Demo'), | |
bottom: const TabBar(tabs: [Tab(text: 'Tab Item'), Tab(text: 'Tab Item')]), | |
), | |
body: TabBarView( | |
children: [ | |
TabBarViewItem(), | |
TabBarViewItem(), | |
], | |
), | |
), | |
), | |
); | |
} | |
} | |
class TabBarViewItem extends StatefulWidget { | |
@override | |
_TabBarViewItemState createState() => _TabBarViewItemState(); | |
} | |
class _TabBarViewItemState extends State<TabBarViewItem> with AutomaticKeepAliveClientMixin { | |
@override | |
Widget build(BuildContext context) { | |
super.build(context); | |
return const Center(child: Text('Tab Bar View Item Content')); | |
} | |
@override | |
bool get wantKeepAlive => true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment