Skip to content

Instantly share code, notes, and snippets.

@Roaa94
Created December 16, 2021 12:39
Show Gist options
  • Save Roaa94/5734f774a8ce028a4666b45946a7523b to your computer and use it in GitHub Desktop.
Save Roaa94/5734f774a8ce028a4666b45946a7523b to your computer and use it in GitHub Desktop.
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