Belki bir fikir verir.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage>
with SingleTickerProviderStateMixin {
TabController tabController;
@override
void initState() {
// TODO: implement initState
super.initState();
tabController = TabController(length: 3, vsync: this);
}
tabBak() {
tabController.addListener(
() {
setState(() {
tabController.index.toString();
});
},
);
}
@override
final benVeriTabanindanGeldim1 = "Veri Tabanindan Geldim1";
final benVeriTabanindanGeldim2 = "Veri Tabanindan Geldim2";
final benVeriTabanindanGeldim3 = "Veri Tabanindan Geldim3";
yazi() {
String degisken = "00";
switch (tabController.index.toString()) {
case "0":
{
degisken = "İlk Başlık Seçildi";
}
break;
case "1":
{
degisken = "İkinci Başlık Seçildi";
}
break;
case "2":
{
degisken = "Üçüncü Başlık Seçildi";
}
break;
default:
{
return degisken = "Başlık Seçilmedi";
}
break;
}
setState(() {});
return Text(
degisken,
style: TextStyle(fontSize: 48),
);
}
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
bottom: TabBar(controller: tabController, tabs: [
Tab(
icon: Icon(Icons.filter_1),
text: benVeriTabanindanGeldim1,
child: tabBak(),
),
Tab(
icon: Icon(Icons.filter_2),
text: benVeriTabanindanGeldim2,
child: tabBak(),
),
Tab(
icon: Icon(Icons.filter_3),
text: benVeriTabanindanGeldim3,
child: tabBak(),
),
]),
),
body: TabBarView(
controller: tabController,
children: <Widget>[
Container(
color: Colors.greenAccent,
child: Center(
child: yazi(),
),
),
Container(
color: Colors.orangeAccent,
child: Center(
child: yazi(),
),
),
Container(
color: Colors.redAccent,
child: Center(
child: yazi(),
),
),
],
),
);
}
}